Diskrete mathematik und algorithmen
This presentation is the property of its rightful owner.
Sponsored Links
1 / 20

Diskrete Mathematik und Algorithmen PowerPoint PPT Presentation


  • 89 Views
  • Uploaded on
  • Presentation posted in: General

Diskrete Mathematik und Algorithmen. Dipl.-Ing. (FH) Christian V. Madritsch University of Applied Science Electronics and Equipment Engineering. Übersicht. CPU Architekturen Pentium Architektur Programmierbeispiel Integer Lösung mit Assemblercode Floating Point Lösung mit Assemblercode

Download Presentation

Diskrete Mathematik und Algorithmen

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Diskrete mathematik und algorithmen

Diskrete Mathematik und Algorithmen

Dipl.-Ing. (FH) Christian V. Madritsch

University of Applied Science

Electronics and Equipment Engineering

(c) 2006 Christian V. Madritsch, FH Kärnten


Bersicht

Übersicht

  • CPU Architekturen

    • Pentium Architektur

      • Programmierbeispiel

        • Integer Lösung mit Assemblercode

        • Floating Point Lösung mit Assemblercode

    • C167 Architektur

      • Programmierbeispiel

        • Integer Lösung mit Assemblercode

        • Floating Point Lösung mit Assemblercode

  • Diskussion

(c) 2006 Christian V. Madritsch, FH Kärnten


Intel pentium architektur

intel Pentium Architektur

(c) 2006 Christian V. Madritsch, FH Kärnten


Integer calculation i

Integer Calculation (i)

void main (void){

int f1, f2, erg;

f1 = 3.1415;

f2 = 2.7;

erg = f1 + f2;

while(1){

erg = f1 + f2;

if(erg > 2)

f1 = 0;

else

f2 = 0;

}

}

(c) 2006 Christian V. Madritsch, FH Kärnten


Integer calculation ii

Integer Calculation (ii)

1: void main (void){

2: int f1, f2, erg;

3: f1 = 3.1415;

00401028 mov dword ptr [ebp-4],3

4: f2 = 2.7;

0040102F mov dword ptr [ebp-8],2

5: erg = f1 + f2;

00401036 mov eax,dword ptr [ebp-4]

00401039 add eax,dword ptr [ebp-8]

0040103C mov dword ptr [ebp-0Ch],eax

6: while(1){

0040103F mov ecx,1

00401044 test ecx,ecx

00401046 je main+59h (00401069)

7: erg = f1 + f2;

00401048 mov edx,dword ptr [ebp-4]

0040104B add edx,dword ptr [ebp-8]

0040104E mov dword ptr [ebp-0Ch],edx

8: if(erg > 2)

00401051 cmp dword ptr [ebp-0Ch],2

00401055 jle main+50h (00401060)

9: f1 = 0;

00401057 mov dword ptr [ebp-4],0

10: else

0040105E jmp main+57h (00401067)

11: f2 = 0;

00401060 mov dword ptr [ebp-8],0

12: }

00401067 jmp main+2Fh (0040103f)

(c) 2006 Christian V. Madritsch, FH Kärnten


Floating point calculation i

Floating Point Calculation (i)

void main (void){

double f1, f2, erg;

f1 = 3.1415;

f2 = 2.7;

erg = f1 + f2;

while(1){

erg = f1 + f2;

if(erg > 2)

f1 = 0;

else

f2 = 0;

}

}

(c) 2006 Christian V. Madritsch, FH Kärnten


Floating point calculation ii

Floating Point Calculation (ii)

1: void main (void){

2: double f1, f2, erg;

3: f1 = 3.1415;

00401028 mov dword ptr [ebp-8],0C083126Fh

0040102F mov dword ptr [ebp-4],400921CAh

4: f2 = 2.7;

00401036 mov dword ptr [ebp-10h],9999999Ah

0040103D mov dword ptr [ebp-0Ch],40059999h

5: erg = f1 + f2;

00401044 fld qword ptr [ebp-8]

00401047 fadd qword ptr [ebp-10h]

0040104A fstp qword ptr [ebp-18h]

6: while(1){

0040104D mov eax,1

00401052 test eax,eax

00401054 je main+7Fh (0040108f)

7: erg = f1 + f2;

00401056 fld qword ptr [ebp-8]

00401059 fadd qword ptr [ebp-10h]

0040105C fstp qword ptr [ebp-18h]

8: if(erg > 2)

0040105F fld qword ptr [ebp-18h]

00401062 fcomp qword ptr [[email protected]@40008000000000000000 (00423020)]

00401068 fnstsw ax

0040106A test ah,41h

0040106D jne main+6Fh (0040107f)

9: f1 = 0;

0040106F mov dword ptr [ebp-8],0

00401076 mov dword ptr [ebp-4],0

10: else

0040107D jmp main+7Dh (0040108d)

11: f2 = 0;

0040107F mov dword ptr [ebp-10h],0

00401086 mov dword ptr [ebp-0Ch],0

(c) 2006 Christian V. Madritsch, FH Kärnten


Infineon c167 cs block diagram

Infineon C167-CS Block Diagram

(c) 2006 Christian V. Madritsch, FH Kärnten


C166 core block diagram

16-Bit CPU

Van Neumann

4-Stage Pipeline

80ns Instruction Cycle @ 25MHz

400ns Multiplication (16x16bit),

800ns Division (32/16bit)

No native Floating Point support

C166 Core Block Diagram

(c) 2006 Christian V. Madritsch, FH Kärnten


Keil c166 development system

Keil C166 Development System

(c) 2006 Christian V. Madritsch, FH Kärnten


Integer calculation i1

Integer Calculation (i)

void main (void){

int f1, f2, erg;

f1 = 3.1415;

f2 = 2.7;

erg = f1 + f2;

while(1){

erg = f1 + f2;

if(erg > 2)

f1 = 0;

else

f2 = 0;

}

}

(c) 2006 Christian V. Madritsch, FH Kärnten


Integer calculation ii1

Integer Calculation (ii)

1: void main (void) {

2: int f1, f2, erg;

3: f1 = 3.1415;

00010002 E035 MOV R5,#0x03

4: f2 = 2.7;

00010004 E027 MOV R7,#0x02

5: erg = f1 + f2;

00010006 E056 MOV R6,#0x05

6: while(1){

7: erg = f1 + f2;

00010008 F065 MOV R6,R5

0001000A 0067 ADD R6,R7

8: if(erg > 2)

0001000C 4862 CMP R6,#2

0001000E BD02 JMPR CC_SLE,0x010014

9: f1 = 0;

10: else

00010010 E005 MOV R5,#0x00

00010012 0DFA JMPR CC_UC,0x010008

11: f2 = 0;

00010014 E007 MOV R7,#0x00

12: }

00010016 0DF8 JMPR CC_UC,0x010008

(c) 2006 Christian V. Madritsch, FH Kärnten


Floating point calculation i1

Floating Point Calculation (i)

void main (void){

double f1, f2, erg;

f1 = 3.1415;

f2 = 2.7;

erg = f1 + f2;

while(1){

erg = f1 + f2;

if(erg > 2)

f1 = 0;

else

f2 = 0;

}

}

(c) 2006 Christian V. Madritsch, FH Kärnten


Floating point calculation ii1

1: void main (void) {

2: double f1, f2, erg;

000101CC 2804 SUB R0,#4

3: f1 = 3.1415;

000101CE E6F4560E MOV R4,#0x0E56

000101D2 E6F54940 MOV R5,#0x4049

000101D6 B840 MOV [R0],R4

000101D8 C4500200 MOV [R0+#0x0002],R5

4: f2 = 2.7;

000101DC E6FECDCC MOV R14,#0xCCCD

000101E0 E6FF2C40 MOV R15,#0x402C

5: erg = f1 + f2;

000101E4 E6FC92ED MOV R12,#0xED92

000101E8 E6FDBA40 MOV R13,#0x40BA

6: while(1){

7: erg = f1 + f2;

000101EC A840 MOV R4,[R0]

000101EE D4500200 MOV R5,[R0+#0x0002]

000101F2 F06E MOV R6,R14

000101F4 F07F MOV R7,R15

000101F6 CA000600 CALLA CC_UC,?C_FPADD(0x10006)

000101FA F0C4 MOV R12,R4

000101FC F0D5 MOV R13,R5

8: if(erg > 2)

000101FE E006 MOV R6,#0x00

00010200 E6F70040 MOV R7,#0x4000

00010204 CA00EA00 CALLA CC_UC,?C_FPCMP(0x100EA)

00010208 BD05 JMPR CC_SLE,0x010214

9: f1 = 0;

10: else

0001020A E004 MOV R4,#0x00

0001020C B840 MOV [R0],R4

0001020E C4400200 MOV [R0+#0x0002],R4

00010212 0DEC JMPR CC_UC,0x0101EC

11: f2 = 0;

00010214 E00E MOV R14,#0x00

00010216 E00F MOV R15,#0x00

12: }

00010218 0DE9 JMPR CC_UC,0x0101EC

Floating Point Calculation (ii)

(c) 2006 Christian V. Madritsch, FH Kärnten


C167fps lib i

C167FPS.LIB (i)

  • FP_ADD

    • calls: FP_GETOPN

    • calls: FG_XSUB

      • calls: FP_OPRSL

        • calls: FP_RSLNR

    • calls: FP_NOERR

(c) 2006 Christian V. Madritsch, FH Kärnten


C167fps lib ii

C167FPS.LIB (ii)

?C_FPADD:

00010006 CA006801 CALLA CC_UC,?C_FPGETOPN(0x10168)

0001000A 46FAFF00 CMP R10,#0x00FF

0001000E 3D10 JMPR CC_NZ,0x010030

00010010 46F78000 CMP R7,#0x0080

00010014 3D13 JMPR CC_NZ,0x01003C

00010016 46F9FF00 CMP R9,#0x00FF

0001001A 3D07 JMPR CC_NZ,0x01002A

0001001C 46F58000 CMP R5,#0x0080

00010020 3D0D JMPR CC_NZ,0x01003C

00010022 2AF2F280 BCMP R2.0,R2.8

00010026 6D0A JMPR CC_N,0x01003C

00010028 0D0B JMPR CC_UC,0x010040

0001002A 4AF2F280 BMOV R2.0,R2.8

0001002E 0D08 JMPR CC_UC,0x010040

00010030 46F9FF00 CMP R9,#0x00FF

00010034 3D07 JMPR CC_NZ,?C_FPXSUB(0x10044)

00010036 46F58000 CMP R5,#0x0080

0001003A 2D02 JMPR CC_Z,0x010040

0001003C EA008E01 JMPA CC_UC,?C_FPNANRSL(0x1018E)

00010040 EA009601 JMPA CC_UC,?C_FPINFRSL(0x10196)

20 LOCs

(c) 2006 Christian V. Madritsch, FH Kärnten


C167fps lib iii

C167FPS.LIB (iii)

?C_FPGETOPN:

00010168 F095 MOV R9,R5

0001016A 5C19 SHL R9,#0x01

0001016C 4A88F210 BMOV R2.0,C

00010170 7C89 SHR R9,#0x08

00010172 3A88F537 BMOVN R5.7,Z

00010176 E003 MOV R3,#0x00

00010178 E10B MOVB RH5,#0x00

0001017A F0A7 MOV R10,R7

0001017C 5C1A SHL R10,#0x01

0001017E 4A88F218 BMOV R2.8,C

00010182 7C8A SHR R10,#0x08

00010184 3A88F737 BMOVN R7.7,Z

00010188 E008 MOV R8,#0x00

0001018A E10F MOVB RH7,#0x00

0001018C CB00 RET

15 LOCs

(c) 2006 Christian V. Madritsch, FH Kärnten


C167fps lib iv

?C_FPXSUB:

00010044 48A0 CMP R10,#0

00010046 2D06 JMPR CC_Z,0x010054

00010048 4890 CMP R9,#0

0001004A 3D06 JMPR CC_NZ,0x010058

0001004C F057 MOV R5,R7

0001004E F046 MOV R4,R6

00010050 F09A MOV R9,R10

00010052 F145 MOVB RL2,RH2

00010054 EA00B801 JMPA CC_UC,?C_FPNOERR(0x101B8)

00010058 409A CMP R9,R10

0001005A 9D0C JMPR CC_NC,0x010074

0001005C F015 MOV R1,R5

0001005E F057 MOV R5,R7

00010060 F071 MOV R7,R1

00010062 F014 MOV R1,R4

00010064 F046 MOV R4,R6

00010066 F061 MOV R6,R1

00010068 F019 MOV R1,R9

0001006A F09A MOV R9,R10

0001006C F0A1 MOV R10,R1

0001006E F124 MOVB RL1,RL2

00010070 F145 MOVB RL2,RH2

00010072 F152 MOVB RH2,RL1

00010074 F019 MOV R1,R9

00010076 201A SUB R1,R10

00010078 2D0B JMPR CC_Z,0x010090

0001007A 46F11900 CMP R1,#0x0019

0001007E 9DEA JMPR CC_NC,0x010054

00010080 5AF6F80F BOR R8.15,R6.0

00010084 7C16 SHR R6,#0x01

70 LOCs

00010086 4AF7F60F BMOV R6.15,R7.0

0001008A 7C17 SHR R7,#0x01

0001008C 2811 SUB R1,#1

0001008E 3DF8 JMPR CC_NZ,0x010080

00010090 2AF2F280 BCMP R2.0,R2.8

00010094 6D0E JMPR CC_N,0x0100B2

00010096 0038 ADD R3,R8

00010098 1046 ADDC R4,R6

0001009A 1057 ADDC R5,R7

0001009C 9AF50780 JNB R5.8,0x0100AE

000100A0 0891 ADD R9,#1

000100A2 5AF4F30F BOR R3.15,R4.0

000100A6 7C14 SHR R4,#0x01

000100A8 4AF5F40F BMOV R4.15,R5.0

000100AC 7C15 SHR R5,#0x01

000100AE EA00A201 JMPA CC_UC,?C_FPOPRSL(0x101A2)// jump

000100B2 2038 SUB R3,R8

000100B4 3046 SUBC R4,R6

000100B6 3057 SUBC R5,R7

000100B8 EA20C601 JMPA CC_Z,?C_FPZERRSL(0x101C6)

000100BC 9D07 JMPR CC_NC,0x0100CC

000100BE B140 CPLB RL2

000100C0 9130 CPL R3

000100C2 9140 CPL R4

000100C4 9150 CPL R5

000100C6 0831 ADD R3,#1

000100C8 1840 ADDC R4,#0

000100CA 1850 ADDC R5,#0

000100CC 8AF5EF70 JB R5.7,0x0100AE

000100D0 0033 ADD R3,R3

000100D2 1044 ADDC R4,R4

000100D4 1055 ADDC R5,R5

000100D6 2891 SUB R9,#1

000100D8 8AF50570 JB R5.7,0x0100E6

000100DC 0044 ADD R4,R4

000100DE 1055 ADDC R5,R5

000100E0 2891 SUB R9,#1

000100E2 9AF5FB70 JNB R5.7,0x0100DC

000100E6 EA00AE01 JMPA CC_UC,?C_FPRSLNR(0x101AE)

C167FPS.LIB (iv)

(c) 2006 Christian V. Madritsch, FH Kärnten


C167fps lib v

C167FPS.LIB (v)

?C_FPOPRSL:

000101A2 9AF304F0 JNB R3.15,?C_FPRSLNR(0x101AE)

000101A6 0841 ADD R4,#1

000101A8 19A0 ADDCB RL5,#0

000101AA 9D01 JMPR CC_NC,?C_FPRSLNR(0x101AE)

000101AC 0891 ADD R9,#1

?C_FPRSLNR:

000101AE 4890 CMP R9,#0

000101B0 BD0A JMPR CC_SLE,?C_FPZERRSL(0x101C6)

000101B2 46F9FF00 CMP R9,#0x00FF

000101B6 DDEF JMPR CC_SGE,?C_FPINFRSL(0x10196)

?C_FPNOERR:

000101B8 66F57F00 AND R5,#0x007F

000101BC 5C79 SHL R9,#0x07

000101BE 4AF2F90F BMOV R9.15,R2.0

000101C2 7059 OR R5,R9

000101C4 CB00 RET

14 LOCs

(c) 2006 Christian V. Madritsch, FH Kärnten


Diskussion

Diskussion

  • Der C166 Core unterstützt nur Integer (16-Bit) Operationen.

  • Floating Point (float, double) Operationen werden in Software nachgebildet.

  • Daraus folgt:

    • Floating Point Operationen sind (durchschnittlich) um den Faktor 100 langsamer als Integer Operationen

    • Der Speicherplatzbedarf für Daten und Programm ist um den den Faktor 150 - 200 größer als bei Integer Operationen

      • Dies relativiert sich, da die Bibliothek C167FPS.lib nur einmal eingebunden wird

(c) 2006 Christian V. Madritsch, FH Kärnten


  • Login