Thread: [Tutorial] GBA ASM Programming
View Single Post
  #48    
Old January 6th, 2011 (6:44 PM).
Xenesis's Avatar
Xenesis Xenesis is offline
Syogun Changer
     
    Join Date: May 2006
    Location: Australia
    Nature: Sassy
    Posts: 55

    Quote:
    Originally Posted by NintendoBoyDX View Post
    If I'm not mistaken though and directly edits the contents of one register, so it only requires one register as well.

    Yes, that's correct.

    However, you can't AND an immediate value in code, you have to AND two registers.

    Eg, you can't go:

    AND r0, #0x3

    because the hardware doesn't support it.

    You have to go something like:

    MOV r1, #0x3
    AND r0, r1

    Which requires two free registers. If you want to clear bits, you can just do something like:

    lsl r0, r0, #0x19
    lsr r0, r0, #0x19

    Which only requires one free register.

    Quote:
    Originally Posted by colcolstyles View Post
    Plus, I think that the "mov" instruction takes up more cycles than logical shifts so it'll save you a nanosecond or two. :D

    The difference between the two is generally rather minor. You're unlikely to add much bloat to the game's code as is unless you start abusing swi operations relentlessly.

    Reply With Quote