Hallo, guten Tag. wie kann man dieses de bitte nach jeder Runde um 16 erhöhen? Danke. ------------------------- ld b,15 draw_loop4: push bc ld de,16..32..38..64..??? ld hl,$e000 add hl,de ld b,16 draw_loop3: push bc ld b,16 ld a,224 draw_loop2: ld (hl), a inc hl djnz draw_loop2 pop bc ld de,240 add hl,de djnz draw_loop3 pop bc djnz draw_loop4 ------------------------
Peter B. schrieb: > wie kann man dieses de bitte nach jeder Runde um 16 erhöhen? du setzt es vor draw_loop4 auf 0, statt "ld de,16..32..38..64..???" machst du ein "add ld,16" und innerhalb der draw_loop2, wo der Wert von de nochmal überschrieben wird, musst du es irgendwo zwischenspeichern, z.B. push/pop. Oder dort ein anderes register nehmen.
1 | ld hl,$0e00 |
2 | ld (addr),hl |
3 | ld b,15 |
4 | |
5 | draw_loop4: |
6 | push bc |
7 | ld hl,(addr) |
8 | ld de,16 |
9 | add hl,de |
10 | ld (addr),hl |
11 | ld b,16 |
12 | |
13 | draw_loop3: |
14 | push bc |
15 | ld b,16 |
16 | ld a,224 |
17 | |
18 | draw_loop2: |
19 | ld (hl), a |
20 | inc hl |
21 | djnz draw_loop2 |
22 | |
23 | pop bc |
24 | ld de,240 |
25 | add hl,de |
26 | djnz draw_loop3 |
27 | |
28 | pop bc |
29 | djnz draw_loop4 |
"addr" muss als Variable im RAM angelegt sein, je nach Assembler als "dw ?" oder "ds 2" oder ähnlich.
Optimierte Version, ohne Stack- und Speichernutzung:
1 | ld hl,$e010 |
2 | |
3 | draw_loop1: |
4 | ld b,16 |
5 | |
6 | draw_loop2: |
7 | ld (hl),224 |
8 | inc hl |
9 | djnz draw_loop2 |
10 | ld de,0f0h |
11 | add hl,de |
12 | ld a,h |
13 | cp 0f0h |
14 | jr c,draw_loop1 |
15 | ld de,0f010h |
16 | add hl,de |
17 | ld a,h |
18 | cp 0f0h |
19 | jr c,draw_loop1 |
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.