Conditional structures: Difference between revisions
Content added Content deleted
m (→if-else: make a sub-section of blz) |
(fix z80 sections to not clutter table of content) |
||
Line 7,944: | Line 7,944: | ||
The compare instruction is often used in combination with jumps, calls, and returns to implement high-level control structures. |
The compare instruction is often used in combination with jumps, calls, and returns to implement high-level control structures. |
||
==If-Then-Else== |
===If-Then-Else=== |
||
We'll look at this example in C and in Z80 Assembly: |
We'll look at this example in C and in Z80 Assembly: |
||
Line 7,986: | Line 7,986: | ||
If the accumulator didn't equal 20, no <code>CALL</code> will actually take place. |
If the accumulator didn't equal 20, no <code>CALL</code> will actually take place. |
||
==Switch== |
===Switch=== |
||
Switch cases can be implemented in a few ways. The simplest way is by checking each value individually. |
Switch cases can be implemented in a few ways. The simplest way is by checking each value individually. |
||
<lang Z80>ld a,(HL) ;switch (HL) |
<lang Z80>ld a,(HL) ;switch (HL) |