#11399 - davewelsh - Sat Oct 04, 2003 4:26 pm
I was following gbaguy's tutorials (although I'm using as instead of goldroad), and I've managed to get things working well, figuring out .EQU instead of @define, .text instead of @textarea, etc.
What I'm having trouble with is loops.
Here is code that works:
I'm not sure if the "B wait" works, but I assume it does for now.
Here is code that doesn't seem to work for me. The loop only executes once:
When I run this in VirtualBoyAdvance I get two red pixels at (0, 10) and (1, 10) but I figure I should get 8 more. I've also tried this with the labels on their own lines.
What I'm having trouble with is loops.
Here is code that works:
Code: |
.include "consts.s"
.ARM .ALIGN LDR r1,=REG_DISPCNT @ load into r1 ?? LDR r2,=(MODE_3|BG2_ENABLE) @ load graphics mode into into r2 STR r2, [r1] @ store r2 into [r1] (init graphics) LDR r1, =0xff00ff @ load colour into r1 (2 x red) LDR r2, =VRAM+2400 @ load initial location into r2 (0, 10) STR r1, [r2] @ plot two pixels at [r2] ADD r2, r2, #4 @ move forward STR r1, [r2] @ plot two pixels at [r2] ADD r2, r2, #4 @ move forward STR r1, [r2] @ plot two pixels at [r2] ADD r2, r2, #4 @ move forward STR r1, [r2] @ plot two pixels at [r2] ADD r2, r2, #4 @ move forward STR r1, [r2] @ plot two pixels at [r2] wait: B wait @ loop forever |
I'm not sure if the "B wait" works, but I assume it does for now.
Here is code that doesn't seem to work for me. The loop only executes once:
Code: |
.include "consts.s"
.ARM .ALIGN LDR r1,=REG_DISPCNT @ load into r1 ?? LDR r2,=(MODE_3|BG2_ENABLE) @ load graphics mode into into r2 STR r2, [r1] @ store r2 into [r1] (init graphics) LDR r1, =0xff00ff @ load colour into r1 (2 red pixels) LDR r2, =VRAM+2400 @ load initial location into r2 (0, 10) MOV r3, #5 loop: STR r1, [r2] @ plot two pixels at [r2] ADD r2, r2, #4 @ move forward SUBS r3, r3, #1 @ decrement loop register BPL loop @ loop while positive wait: B wait @ loop forever |
When I run this in VirtualBoyAdvance I get two red pixels at (0, 10) and (1, 10) but I figure I should get 8 more. I've also tried this with the labels on their own lines.