SOCS

157
1 SOCS Hoofdstuk 1 Computerarchitect uur

description

SOCS. Hoofdstuk 1 Computerarchitectuur. Computerarchitectuur. Uitgangspunt: Computer Logische bouwstenen Werking/mogelijkheden/beperkingen Primitieve Opdrachten. Inhoud. Basisstructuur Inleiding tot C Modelcomputer DRAMA Programma´s voor DRAMA. 1.1 Basisstructuur. - PowerPoint PPT Presentation

Transcript of SOCS

Page 1: SOCS

1

SOCS

Hoofdstuk 1

Computerarchitectuur

Page 2: SOCS

2

Computerarchitectuur

Uitgangspunt:

Computer Logische bouwstenen Werking/mogelijkheden/beperkingen Primitieve Opdrachten

Page 3: SOCS

3

Inhoud

1. Basisstructuur

2. Inleiding tot C

3. Modelcomputer DRAMA

4. Programma´s voor DRAMA

Page 4: SOCS

4

Inwendige van de computer

1.1 Basisstructuur

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Page 5: SOCS

5

Inwendige van de computer

Invoerorgaan

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary MemoryG

egev

ens

prog

ram

ma

Toetsenbord Muis, stuurpook Ponskaart-, ponsbandlezer Lichtpen Digitaliseertafel Microfoon Camera Sensor, Meettoestel

Page 6: SOCS

6

Inwendige van de computer

Uitvoerorgaan

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Beeldscherm (monitor) Drukapparaten Tekentafels, plotters Luidsprekers Ponskaart/band- eenheid Stuurkabel (elektrisch stuursignaal)

Page 7: SOCS

7

Inwendige van de computer

Processor

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Reken-orgaan

Controle-orgaan

Registers

Opslag van: tussenresultaten operanden

Uitvoeren van bewerkingen zeer elementair rekenkundig, logisch, …

Bevelen in juiste volgorde uitgevoerd

Page 8: SOCS

8

Inwendige van de computer

Geheugen

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Direct toegankelijk

Bewaren

Page 9: SOCS

9

Inwendige van de computer

Centraal Geheugen (werkgeheugen)

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

123123

124124

125125

126126

01010101

11100001

00000001

01111101

…Inhoud(geen interpretatie)

Adres0 .. Max (2n)

Eenheid Hoeveel

1 k

1 M

1 G

1 T

210 = 1024

220 = 1.048.576

230 = 1.073.741.824

240

Page 10: SOCS

10

Inwendige van de computer

Centraal Geheugen (werkgeheugen)

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

CentraalGeheugenCPU

CentraalGeheugenCPU

Lees AdresLees AdresInhoud (waarde)Inhoud (waarde)

Schrijf Adres WaardeSchrijf Adres Waarde

Page 11: SOCS

11

Inwendige van de computer

Centraal Geheugen (werkgeheugen)

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Geheugen met onmiddellijke toegang (Random Access Memory, RAM)

toegangstijd is onafhankelijk van het adres

cyclustijdcyclustijd

toegangstijdtoegangstijd

lees-lees-opdrachtopdracht resultaatresultaat

volgendevolgendeopdrachtopdracht

tijd

Page 12: SOCS

12

Inwendige van de computer

Hulpgeheugen

Centraal Verwerkingsorgaan (Processor)Centraal Verwerkingsorgaan (Processor)Central Processing Unit (CPU)

InvoerorgaanInvoerorgaanInput Device

UitvoerorgaanUitvoerorgaanOutput DeviceCentraal GeheugenCentraal Geheugen

Main Memory

HulpgeheugensHulpgeheugensSecondary Memory

Eigenschappen: Grote capaciteit Bestendig: langere tijd bewaren Lezen (+ soms Schrijven) Goedkoper, trager

Voorbeelden: (Harde/Soepele) Schijven Magneetbanden, -cassettes CD-ROM, CD-R, CD-RW DVD, DVD-RAM, DVD-R, DVD-RW, DVD+R, DVD-RW … Magneto-Optische Schijf, ZIP, JAZ, …

Page 13: SOCS

13

Inhoud

1. Basisstructuur

2. Inleiding tot C

3. Modelcomputer DRAMA

4. Programma´s voor DRAMA

Page 14: SOCS

14

1.2 Inleiding tot C

Kenmerken van C Doelstelling Overzicht Eenvoudige programma´s

CCProgrammeertaal C

Page 15: SOCS

15

Kenmerken van C

Hogere programmeertaal Grote verzameling types, (strenge) type controle Zelf nieuwe types definiëren Klassieke controle-structuren Functies

Assembleertaal Operatoren met equivalent op machine-niveau Bewerkingen op adressen mogelijk

Basis voor … C++, Java, C#, …

CC

Page 16: SOCS

16

Doelstelling

Passieve kennis van C Begrijpen maar niet zelf kunnen schrijven

Voorbeelden: Steunen op kennis van Java Stijgende complexiteit

CC

Page 17: SOCS

17

Overzicht

Eenvoudig C Arrays Functies Records Dynamische gegevenstructuren

CC

Page 18: SOCS

18

Overzicht

Eenvoudig C Declaraties, main, operatoren, opdrachten, in- en uitvoer

Voorbeeld 1-1 if, while, samengestelde opdracht

Voorbeeld 1-5 Switch opdracht

Arrays Functies Records Dynamische gegevenstructuren

CC

Page 19: SOCS

19

Main – Globale variabelen Voorbeeld 1-1

int a, b, somk;

main() {a = getint();b = getint();somk = a * a + b * b;printint (somk);

}

CC

Page 20: SOCS

20

Main – Globale variabelen Voorbeeld 1-1

int a, b, somk;

main() {a = getint();b = getint();somk = a * a + b * b;printint (somk);

}

• Globale variabelen

• Type int = integer

• Declaratie vereist

CC

Page 21: SOCS

21

Types

Standaard types

intint : voor gehele waarde C voorziet verschillende groottes

• short• int • long

Niet noodzakelijk verschillend

Geen type voor logische waarde logische waarde verwacht:

0 false 0 true

CC

Page 22: SOCS

22

Main – Globale variabelen Voorbeeld 1-1

int a, b, somk;

main() {a = getint();b = getint();somk = a * a + b * b;printint (somk);

}

• Hoofdprogramma main

• Tussen ( ) : Parameters

• Tussen { } : Lichaam

Opdrachten

• In voorbeelden:

geen parameters

geen lokale variabelen

CC

Page 23: SOCS

23

Operatoren

Uitdrukkingen

Rekenkundige operatoren (zoals Java)+ * / %

Relationele operatoren (zoals Java)> >= < <= == !=

Logische operatoren&& tweede operand niet berekend indien eerste = 0 (false)

| | tweede operand niet berekend indien eerste 0 (true)

CC

Page 24: SOCS

24

Operatoren

Uitdrukkingen

Toekenningsoperator: i = 5 UITDRUKKING! Met waarde: 5 Met neveneffect: waarde i is 5 Klassieke fout

• i = 5• i == 5

j = i = k = 5

Samengestelde toekenningsoperatoren i *= j – 3 i = i * ( j – 3 ) += -= *= /= %=

CC

j = (i = (k = 5))

altijd waar!

Page 25: SOCS

25

Opdrachten Opdracht

Uitdrukking gevolgd door ;

Invoer en uitvoer C definieert geen opdrachten In C worden functies uit bibliotheken gebruikt Wij gebruiken

getint() leest geheel getal in en

geeft dit als resultaat terug

printint ( <uitdrukking>) drukt geheel getal af

If, while, switch, …

CC

Page 26: SOCS

26

Voorbeeld 1-1

int a, b, somk;

main() {a = getint();b = getint();somk = a * a + b * b;printint (somk);

}

CC

10–30

1000

Page 27: SOCS

27

If while Voorbeeld 1-5

int a, abs, i;

main() {i = 1;while (i <= 10) {

a = getint ();if ( a > 0 ) abs = a;else abs = -a;printint (a, abs);i = i + 1;

}}

CC

Page 28: SOCS

28

If while Voorbeeld 1-5

int a, abs, i;

main() {i = 1;while (i <= 10) {

a = getint ();if ( a > 0 ) abs = a;else abs = -a;printint (a, abs);i = i + 1;

}}

if ( voorwaarde )

opdracht

if ( voorwaarde )

opdracht1

else

opdracht2

CC

Page 29: SOCS

29

If while Voorbeeld 1-5

Opdracht Uitdrukking gevolgd door ;

Samengestelde opdracht (zonder afsluitende ;)

{

opdracht

}

If, while, …

CC

Page 30: SOCS

30

If while Voorbeeld 1-5

int a, abs, i;

main() {i = 1;while (i <= 10) {

a = getint ();if ( a > 0 ) abs = a;else abs = -a;printint (a, abs);i = i + 1;

}}

while ( voorwaarde )

opdracht

CC

Page 31: SOCS

31

Switch-opdracht

switch (i - 7) {

case 0:

case 1:

a = 0;

break;

case 2:

a = 1;

break;

default:

a = 2;

break;

}

??

?

switch ( uitdrukking ){

case waarde1 :

opdrachten1

case waarde2 :

opdrachten2 …

default:

opdrachten

}

CC

Page 32: SOCS

32

Switch-opdracht

switch (i - 7) {

case 0:

case 1:

a = 0;

break;

case 2:

a = 1;

break;

default:

a = 2;

break;

}

CC

i == 9

a = 1

i == 5

a = 2

Page 33: SOCS

33

Switch-opdracht

switch (i - 7) {

case 0:

case 1:

a = 0;

break;

case 2:

a = 1;

break;

default:

a = 2;

break;

}

CC

i == 8

a = 0

i == 9

a = 1a = 2

Page 34: SOCS

34

Inhoud

1. Basisstructuur

2. Inleiding tot C

3. Modelcomputer DRAMA

4. Programma´s voor DRAMA

Page 35: SOCS

35

1.3 Modelcomputer

Verantwoording: Basiskennis ( details) binding commercieel beschikbare processor

DRAMA Decimale RekenAutomaat met Meerdere Accumulatoren Decimaal ( echte computer: binair)

Compacter, Leesbaarder voor menselijke gebruiker

DRAMADRAMA Reële ComputerReële Computer

Page 36: SOCS

36

DRAMA-computerProcessor

1234567890

0000001235

8234872348

R0R0

R1

R9R9

1234 BTBT

1 CCCC

Accumulatoren(Registers) Conditiecode

Bevelenteller

Werkgeheugen

1234567890

8271683928

7362516278

00000000

00010001

99999999Nooit leeg!

Page 37: SOCS

37

DRAMA: Getalvoorstelling

Gehele getallen 10-complement (negatief: 1010 - |x| ) Positief: 0 4.999.999.999

0000000000 4999999999 Negatief: 5.000.000.000 -1

5000000000 9999999999

0000001234

9999998766

1234

-1234

In voorbeelden:Inwendig:

+1234 ?

1234 ?

Page 38: SOCS

38

DRAMA: Bevelenset

Bevel = (meestal) 3 delen

FUNCODE ACC,OPERANDFUNCODE ACC,OPERAND

Functiecode (3 letters): vb. HIAHIA Eventueel interpretatieveld: vb. HIA.wHIA.w

Naam van Accumulator: vb. R0R0 Operand:

Geheugenadres: vb. 12091209 Geheel getal vb. 1515 Naam van Accumulator vb. R7R7

Page 39: SOCS

39

DRAMA: Bevelenset

Transportbevelen geheugenregisters accumulatoren

HIAHIA = Haal In Accumulator HIAHIA R7,123R7,123 | R7

GeheugenReg[123] HIA.wHIA.w R6,10R6,10 | R6 10 HIAHIA R8,R7R8,R7 | R8 R7

BIGBIG = Berg In Geheugen BIGBIG R7,123R7,123 | GeheugenReg[123]

R7

Page 40: SOCS

40

DRAMA: Bevelenset

Rekenkundige bevelen Basisbewerkingen: +, , , /, %

OPT, AFT, VER, DEL, MODOPT, AFT, VER, DEL, MOD

Zelfde varianten als HIAHIA OPTOPT R7,123R7,123 | R7 R7 +

GeheugenReg[123] AFTAFT.w.w R6,10R6,10 | R6 R6 10 VERVER R8,R7R8,R7 | R8 R8 R7

Page 41: SOCS

41

DRAMA: Bevelenset

Invoer / Uitvoer Vereenvoudigd: gehele getallen lezen/schrijven

LEZLEZ = Lezen LEZLEZ | R0 InvoerOrgaanInvoerOrgaan

DRUDRU = Drukken DRUDRU | UitvoerOrgaanUitvoerOrgaan R0

NWLNWL = Nieuwe Lijn NWLNWL | UitvoerOrgaanUitvoerOrgaan

Page 42: SOCS

42

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

Page 43: SOCS

43

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002

Page 44: SOCS

44

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002

LEZBIG R0,1000

Page 45: SOCS

45

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000

LEZBIG R0,1001

Page 46: SOCS

46

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001

HIA R1,1000VER R1,1000

Page 47: SOCS

47

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001HIA R1,1000VER R1,1000

HIA R2,1001VER R2,R2

Page 48: SOCS

48

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001HIA R1,1000VER R1,1000HIA R2,1001VER R2,R2

OPT R1,R2

Page 49: SOCS

49

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001HIA R1,1000VER R1,1000HIA R2,1001VER R2,R2OPT R1,R2

BIG R1,1002

Page 50: SOCS

50

Voorbeeld

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001HIA R1,1000VER R1,1000HIA R2,1001VER R2,R2OPT R1,R2BIG R1,1002 HIA R0,1002DRU

Page 51: SOCS

51

Voorbeeld

12 DRAMA-bevelen Kan efficienter! Maar:

Correctheid is belangrijker Optimisatie kan later Aanpasbaarheid?

| geheugenreservaties| a 1000| b 1001| somk 1002LEZBIG R0,1000LEZBIG R0,1001HIA R1,1000VER R1,1000HIA R2,1001VER R2,R2OPT R1,R2BIG R1,1002HIA R0,1002DRU

Page 52: SOCS

52

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0

Page 53: SOCS

53

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0

LEZHIA R1,R0LEZHIA R2,R0

Page 54: SOCS

54

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0LEZHIA R1,R0LEZHIA R2,R0

HIA R3,R1VER R3,R1

Page 55: SOCS

55

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0LEZHIA R1,R0LEZHIA R2,R0HIA R3,R1VER R3,R1

VER R0,R0

Page 56: SOCS

56

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0LEZHIA R1,R0LEZHIA R2,R0HIA R3,R1VER R3,R1VER R0,R0

OPT R0,R3

Page 57: SOCS

57

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0LEZHIA R1,R0LEZHIA R2,R0HIA R3,R1VER R3,R1VER R0,R0OPT R0,R3

DRU

Page 58: SOCS

58

Voorbeeld (bis)

int a, b, somk;main() {

a = getint();

b = getint();

somk = a * a + b * b;

printint (somk);}

| geheugenreservaties| a R1| b R2| somk R0LEZHIA R1,R0LEZHIA R2,R0HIA R3,R1VER R3,R1VER R0,R0OPT R0,R3DRU

c = getint();

, c;

LEZHIA R4,R0

c R4

Page 59: SOCS

59

DRAMA: Bevelenset

Conditieregister Resultaat van vorige bewerking

00 (==0), 11 (>0), 22 (<0) Alle transportbevelen, rekenkundige bevelen,

in/uitvoer, vergelijk-bevel

VGLVGL = Vergelijk VGLVGL R7,123R7,123 | KR R7

GeheugenReg[123] VGLVGL.w.w R6,10R6,10 | KR R6 10 VGLVGL R8,R7R8,R7 | KR R8 R7

Kladregister

Page 60: SOCS

60

DRAMA: Bevelenset

Organisatorische bevelen Uitvoeringsvolgorde, …

SPRSPR = onvoorwaardelijke Sprong SPRSPR 345345 | Ga verder bij bevel met

| volgnr 345 VSPVSP = Voorwaardelijke Sprong

VSPVSP vwvw,123,123 | Ga verder bij bevel met| volgnr 123 als vw

voldaan| zoniet: volgend bevel

STPSTP = Stop STPSTP | Stop uitvoering

Page 61: SOCS

61

DRAMA: Bevelenset

Organisatorische bevelen Voorwaarden

VoorwaardeVoorwaarde Voldaan als CCVoldaan als CC

NUL 0

POS 1

NEG 2

NNUL

NPOS

NNEG

Page 62: SOCS

62

DRAMA: Bevelenset

Organisatorische bevelen Voorwaarden

VoorwaardeVoorwaarde Voldaan als CCVoldaan als CC

NUL 0

POS 1

NEG 2

NNUL 1 of 2

NPOS 0 of 2

NNEG 0 of 1

Page 63: SOCS

63

DRAMA: Bevelenset

Organisatorische bevelen Voorwaarden

VoorwaardeVoorwaarde VoorwaardeVoorwaarde Voldaan als CCVoldaan als CC

NUL GEL 0

POS GR 1

NEG KL 2

NNUL NGEL 1 of 2

NPOS KLG 0 of 2

NNEG GRG 0 of 1

Page 64: SOCS

64

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

Page 65: SOCS

65

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3

Page 66: SOCS

66

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3

Volgnummer: 0, 1, 2, …Volgnummer: 0, 1, 2, …

0:0: HIA.w R3,1

Page 67: SOCS

67

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1

1:1: VGL.w R3,102:2: VSP GR,aaaaaa

Lich

aam

v/d

Whi

le-lu

s

Page 68: SOCS

68

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa

3:3: LEZ4:4: HIA R1,R0

Page 69: SOCS

69

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0

5:5: VSP NPOS,bbbbbb

Page 70: SOCS

70

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,bbbbbb

6:6: HIA R2,R17:7: SPR cccccc

8 8

Page 71: SOCS

71

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,8 6:6: HIA R2,R1 7:7: SPR cccccc

8:8: HIA R2,R19:9: VER.w R2,-1

10 10

Page 72: SOCS

72

Voorbeeld 2int a, abs, i; main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,8 6:6: HIA R2,R1 7:7: SPR 10 8:8: HIA R2,R1 9:9: VER.w R2.-1

10:10: HIA R0,R111:11: DRU12:12: HIA R0,R213:13: DRU14:14: NWL

Page 73: SOCS

73

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,8 6:6: HIA R2,R1 7:7: SPR 1010 8:8: HIA R2,R1 9:9: VER.w R2.-110:10: HIA R0,R111:11: DRU12:12: HIA R0,R213:13: DRU14:14: NWL

15:15: OPT.w R3,1

Page 74: SOCS

74

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,aaaaaa 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,8 6:6: HIA R2,R1 7:7: SPR 1010 8:8: HIA R2,R1 9:9: VER.w R2.-110:10: HIA R0,R111:11: DRU12:12: HIA R0,R213:13: DRU14:14: NWL15:15: OPT.w R3,1 16:16: SPR 1

17 17

Page 75: SOCS

75

Voorbeeld 2int a, abs, i;main() {

i = 1;while (i <= 10) {

a = getint();if (a > 0)abs = a;elseabs = -a;

printint (a, abs);

i = i + 1;}

}

| a R1 | abs R2 | i R3 0:0: HIA.w R3,1 1:1: VGL.w R3,10 2:2: VSP GR,17 3:3: LEZ 4:4: HIA R1,R0 5:5: VSP NPOS,8 6:6: HIA R2,R1 7:7: SPR 1010 8:8: HIA R2,R1 9:9: VER.w R2.-110:10: HIA R0,R111:11: DRU12:12: HIA R0,R213:13: DRU14:14: NWL15:15: OPT.w R3,116:16: SPR 11 17:17: STP

Page 76: SOCS

76

RAM

Volgordebesturingint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

volgnummer = geheugenadres

Page 77: SOCS

77

Processor

Volgordebesturing

0000BTBT

0

CCCC

0, -7, 3InvoerInvoer

0000123456

R0R0

UitvoerUitvoer

BRBR

RAM

00000000

00010001

00020002

00030003

In uitvoering

Page 78: SOCS

78

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0000BTBT

0

CCCC

0, -7, 3InvoerInvoer

0000123456

R0R0

UitvoerUitvoer

BRBR

Page 79: SOCS

79

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0000BTBT

0

CCCC

0, -7, 3InvoerInvoer

0000123456

R0R0

UitvoerUitvoer

LEZBRBR

Page 80: SOCS

80

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

0

CCCC

0, -7, 3InvoerInvoer

0000123456

R0R0

UitvoerUitvoer

LEZBRBR

Page 81: SOCS

81

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

0

CCCC

0, -7, 3InvoerInvoer

0000123456

R0R0

UitvoerUitvoer

0000000003 1

0, -7

LEZBRBR

Page 82: SOCS

82

Processor

LEZ

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NUL,7BRBR

Page 83: SOCS

83

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NUL,7BRBR

Page 84: SOCS

84

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NUL,7BRBR

Page 85: SOCS

85

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NUL,7BRBR VSP NNEG,4

Page 86: SOCS

86

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0003BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NNEG,4BRBR

Page 87: SOCS

87

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0003BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NNEG,4BRBR

Page 88: SOCS

88

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0004BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

VSP NNEG,4BRBR

Page 89: SOCS

89

Processor

VSP NNEG,4

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0004BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

DRUBRBR

Page 90: SOCS

90

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

DRUBRBR

Page 91: SOCS

91

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

DRU

3

BRBR

Page 92: SOCS

92

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

UitvoerUitvoer

3

DRUBRBR LEZ

Page 93: SOCS

93

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

1

CCCC

0, -7 InvoerInvoer

0000000003

R0R0

3 UitvoerUitvoer

LEZBRBR

Page 94: SOCS

94

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

LEZBRBR

Page 95: SOCS

95

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

LEZBRBR SPR 1

Page 96: SOCS

96

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

SPR 1BRBR

Page 97: SOCS

97

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

SPR 1BRBR

Page 98: SOCS

98

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

SPR 1BRBR

Page 99: SOCS

99

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

SPR 1BRBR VSP NUL,7

Page 100: SOCS

100

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NUL,7BRBR

Page 101: SOCS

101

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NUL,7BRBR

Page 102: SOCS

102

Processor

VSP NUL,7

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NNEG,4BRBR

Page 103: SOCS

103

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0003BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NNEG,4BRBR

Page 104: SOCS

104

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0003BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NNEG,4BRBR

Page 105: SOCS

105

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0003BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VSP NNEG,4BRBR VER.w R0,-1

Page 106: SOCS

106

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0004BTBT

2

CCCC

0 InvoerInvoer

9999999993

R0R0

3 UitvoerUitvoer

VER.w R0,-1BRBR

Page 107: SOCS

107

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0004BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

3 UitvoerUitvoer

VER.w R0,-1BRBR

Page 108: SOCS

108

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0004BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

3 UitvoerUitvoer

VER.w R0,-1BRBR DRU

Page 109: SOCS

109

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

3 UitvoerUitvoer

DRUBRBR

Page 110: SOCS

110

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

7, 3 UitvoerUitvoer

DRUBRBR

Page 111: SOCS

111

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0005BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

7, 3 UitvoerUitvoer

DRUBRBR LEZ

Page 112: SOCS

112

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

1

CCCC

0 InvoerInvoer

0000000007

R0R0

7, 3 UitvoerUitvoer

LEZBRBR

Page 113: SOCS

113

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

LEZBRBR

Page 114: SOCS

114

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0006BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

LEZBRBR SPR 1

Page 115: SOCS

115

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

SPR 1BRBR

Page 116: SOCS

116

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

SPR 1BRBR

Page 117: SOCS

117

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

SPR 1BRBR

Page 118: SOCS

118

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0001BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

SPR 1BRBR VSP NUL,7

Page 119: SOCS

119

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

VSP NUL,7BRBR

Page 120: SOCS

120

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0002BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

VSP NUL,7BRBR

Page 121: SOCS

121

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

VSP NUL,7BRBR

Page 122: SOCS

122

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0007BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

VSP NUL,7BRBR STP

Page 123: SOCS

123

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0008BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

STPBRBR

Page 124: SOCS

124

Processor

Volgordebesturing | a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

0008BTBT

0

CCCC

InvoerInvoer

0000000000

R0R0

7, 3 UitvoerUitvoer

STP

Uitvoering StoptUitvoering Stopt

BRBR

Page 125: SOCS

125

Volgordebesturing

Uitvoering van een programma: Opeenvolging van bevelencycli:

Ophalen van het volgende bevel (BT)BT BT + 1

Analyse van het bevel

Uitvoeren van het bevelSPR (VSP) BT nieuwe waarde

Page 126: SOCS

126

Interne voorstelling van bevelen

Centraal geheugen getallen Bevel getalvorm Uitwendige machinetaal

OPT.w R2,1012 Inwendige machinetaal

2111201012

operandidxaccmodefc

41122#cijfers:

functiecode accumulator

Interpretatie, …

Page 127: SOCS

127

Interne voorstelling van bevelen

Functiecodes operandidxaccmodefc

Bevel Functiecode

HIA 11

BIG 12

OPT 21

AFT 22

VER 23

… …

Page 128: SOCS

128

Interne voorstelling van bevelen

Modecijfers

Afhankelijk van de interpretatie Verzuimwaarde: .dHIA R1,123 HIA.d R1,123

operandidxaccmodefc

Inter-pretatie

Eerstemodecijfer Voor bevelen:

.w 1 Alle bevelen (als .w mogelijk)

.d 3 HIA, OPT, AFT, …, MOD, VGL

.d 2 BIG, SPR, VSP

Page 129: SOCS

129

Interne voorstelling van bevelen

Accumulatorcijfer

R0 0, R1 1, … Voor VSP wordt daar de voorwaarde bijgehouden

operandidxaccmodefc

Voorwaarde Voorstelling

NUL 1

NNUL 8

POS 6

NPOS 2

NEG 7

… …

Page 130: SOCS

130

Interne voorstelling van bevelen

Index-veld

Register operand Voorbeeld:

HIA R1,R2

operandidxaccmodefc

Page 131: SOCS

131

Interne voorstelling van bevelen

Operandveld

Adres: vier cijfers van het adres

Constante (.w): 10-complement0 4999 0000 4999-5000 -1 5000 9999

Register: NIET IN OPERAND-VELD (wel in idx-veld)

operandidxaccmodefc

Page 132: SOCS

132

Interne voorstelling van de bevelen

7199999999

3321100007

3321200004

2311009999

7299999999

7199999999

3221900001

9999999999

LEZ

VSP NUL,7

VSP NNEG,4

VER.w R0,-1

DRU

LEZ

SPR 1

STP

Page 133: SOCS

133

Volgordebesturing

C-programma dat volgordebesturing simuleert

Variabelen van de processor: int BT; /* bevelenteller */ int stop; int BR; /* bevelenregister */ int fccode,mode,acc,idx,operand; /*velden*/ int waarde; /* hulpregister */

Functie: expandeer(getal): 4 cijfers 10 cijfers4999 00000049995800 9999995800

Page 134: SOCS

134

Volgordebesturing

BT = 0;

stop = 0;

while (! stop) {

/* haal bevel op */

BR = geheugen[BT];

BT = BT + 1;

/* analyseer bevel */

fccode = BR / 100000000;

mode = (BR%100000000)

/1000000;

acc = …;

idx = …;

operand = expandeer(BR % 10000);

/* voer bevel uit */

switch (fccode) {

case HIA:

if (mode ~ regOperand)

waarde = register[idx];

else {

if (mode ~ adresOperand)

waarde = geheugen[operand % 10000];

else

waarde = operand;

}

register[acc] = waarde;

break;

Niet C!

Page 135: SOCS

135

Volgordebesturing

BT = 0;

stop = 0;

while (! stop) {

/* haal bevel op */

BR = geheugen[BT];

BT = BT + 1;

/* analyseer bevel */

fccode = BR / 1000000000;

mode = (BR%100000000)

/1000000;

acc = …;

idx = …;

operand = expandeer(BR % 10000);

/* voer bevel uit */switch (fccode) {case HIA: …case BIG: …case OPT: ……case SPR:BT = operand % 10000;break;

case STP:stop = 1;

}}

Page 136: SOCS

136

Assembleertaal

Nadelen van uitwendige machinetaal:

Programmeur moet bevelen tellen

Tussenvoegen bevelen: adressen aanpassen

Programmeur moet zelf geheugenplaatsen toekennen aan variabelen

Page 137: SOCS

137

Volgordebesturingint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a R0

0:0: LEZ

1:1: VSP NUL,7 2:2: VSP NNEG,4 3:3: VER.w R0,-1

4:4: DRU 5:5: LEZ

6:6: SPR 1 7: 7: STP

a += 10;4:4: OPT.w R0,10

5:5:6:6:7:7:8:8:

8

Page 138: SOCS

138

Assembleertaal

Oplossing:

Symbolische adressen

Etiket (symbolisch adres) DEFINITIENAAM: …

Verwijzing (als operand) REFERENTIE… NAAM

Page 139: SOCS

139

Assembleertaal

Bevelen:

lus: HIA R2,123

SPR lus

VSP GEL,end

… …

end: HIA R1,123

Variabelen: RESGR = Reserveer

GeheugenRegister machinebevel = vertalerdirectief

HIA R2,a

a: RESGR 1

Achterwaartse referentie

# geheugen-registers

Voorwaartse referentie

Page 140: SOCS

140

Assembleertaal

Constante: Niet behorend tot interval [-5000,4999]

miljoen: 1000000

OPT R1,miljoen

Page 141: SOCS

141

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

Page 142: SOCS

142

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

Page 143: SOCS

143

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh

Page 144: SOCS

144

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

Page 145: SOCS

145

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1BIG R0,a

Page 146: SOCS

146

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

Page 147: SOCS

147

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

LEZBIG R0,a

Page 148: SOCS

148

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

LEZBIG R0,a

SPR while

Page 149: SOCS

149

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

LEZBIG R0,a

SPR while

endwh: STP

Page 150: SOCS

150

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

LEZBIG R0,a

SPR while

endwh: STP

a: RESGR 1

Page 151: SOCS

151

Voorbeeldint a;main() {

a = getint();while (a != 0) {

if (a < 0)a = -a;

printint (a);a = getint();

}}

| a in geheugen/R0

LEZBIG R0,a

while: VSP NUL,endwh VSP NNEG,endif

VER.w R0,-1

BIG R0,a

endif: DRU

LEZBIG R0,a

SPR while

endwh: STP

a: RESGR 1EINDPRVertaler-directief:

einde programma

Page 152: SOCS

152

Van C naar DRAMA

Omzetting door vertaler

Correct algoritme (in hogere programmeertaal: C)

Omzetting C DRAMA

Optimalisatie in laatste instantie

Page 153: SOCS

153

Van C naar DRAMA

Variabelen

In geheugenint a, b, c; a: RESGR 1

b: RESGR 1c: RESGR 1

In registers slechts een beperkt aantal

Page 154: SOCS

154

Van C naar DRAMA

Toekenning

a = b; BIG Rr,a

a = exp;BIG Rr,a

In registers slechts een beperkt aantal

HIA Rr,b

… code voor exp in Rr …

Page 155: SOCS

155

Van C naar DRAMA

If-opdracht

if (voorwaarde) S1;

else S2;

if (! voorwaarde) goto elsd;

S1;

goto naif;

elsd: S2;

naif: …

VSP niet-voorwaarde,elsd

… code voor S1 …

SPR naif

elsd:

… code voor S2 …

naif: …

Page 156: SOCS

156

Van C naar DRAMA

While-opdracht

while (voorwaarde) S;

test: if (! voorwaarde)

goto endwh;

S;

goto test;

endwh: …

test: VSP niet-voorwaarde,endwh

… code voor S …

SPR test

endwh:…

Page 157: SOCS

157

Cursustekst

Hoofdstuk 1: pag. 1 pag. 44