Assembling Pi

A.3 Verknüpfungen von Basic Blocks

3.2.4 Kontrollstrukturen: If-then elseif-then

Pseudocode:

```
if(Condition1) then... else if(Condition2) then... else
```

Beispiel in ARM-Assembler:

        MOV r0, #111
        MOV r1, #222
        MOV r2, #0

@ Kontrollstruktur if then... elsif... - else...     
        CMP r0, r1      @ check(r0 == r1) - condition 1
        BEQ iftrue  
        CMP r0, r2      @ check(r0 == r2) - condition 2
        BEQ elsif

@ else...        
else:
        MOV r0, #123
        B endif

@ elsif...
elsif:
        MOV r0, #110
        B endif

@ if...
iftrue:
        MOV r0, #0x32

@ Ende Kontrollstruktur
endif:
        MOV r0, #00

Der Kontrollflussgraph zum Beispiel:

Screenshot of Example Program

Betrachtet man den Controlflow-graph dieser Kontrollstruktur in einem Disassembler, ergibt sich folgendes Bild:

If-then elseif-then

zurück Hauptmenü weiter
3.2 Kontrollstrukturen
3.2.1 Intro
3.2.2 If-not-then
3.2.3 If-elseIf-then
3.2.4 If-then elseif-then
3.2.5 Switch-Case
3.2.6 While-Schleifen
3.2.7 Do-While-Schleifen
3.2.8 Zustandsautomaten