- 417
- Posts
- 10
- Years
- Seen Nov 20, 2016
What do you mean "wouldn't assemble?" What specifically happened, because you shouldn't ever not be able to push {lr}, and that also is (at least one of) the reason(s) it freezes - you took out the return.I had to take out the LR or it wouldn't assemble but it still just freezes the game.Code:start: push {r0-r5} mov r5, #0x3C mov r4, #0x86 lsl r4, r4, #0x4 add r4, r4, #0x7 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 bl flag_check cmp r0, #0x0 beq the_end add r5, r5, #0x5 add r4, r4, #0x1 b the_end the_end: ldrb r0, = 0x02024400 strb r5, [r0] pop {r0-r5} flag_check: mov r0, r4 ldr r1, = 0x809D790 +1 bx r1
Aside from that, a few things. When you use callasm, you don't need to push and pop {r0-r3}. They're scratch registers and assumed to be garbage by the function that calls your asm function. Another thing is I'd handle your flag checks with a loop.
loop:
mov r0, r4 @i'd move this up here; having it down there is a little weird imo
bl flag_check
cmp r0, #0x0
beq the_end
add r4, #0x1
add r5, #0x5
@edit: I misread your initial routine. You need to check against the final flag. Better would be initial flag + loop counter and compare against the loop counter.
b loop
You could save a bit more by changing the setup of the loop, but meh.
Last edited: