#170077 - Seahawk - Fri Aug 28, 2009 4:16 am
I am learning how to write ASM code for GBA. Leaving it to the compiler to make code for me is probably better, but I still want to try.
I've noticed a difference in the "style" of how the compiler generates code for loading data into an I/O port location.
For instance, if I use the C-way of loading a register
devkitPro generates the following code, viewed through VBA disassembler window.
The way I wrote it was:
My code uses 1 non sequential accesses on ROM and 9 sequential accesses. Devkitpro's code uses 6 nonsequential accesses and 1 sequential.
Which version would be faster generally? I know sequential access on ROM is faster, but would the greater amount of statements to process in my code negate this advantage?
I've noticed a difference in the "style" of how the compiler generates code for loading data into an I/O port location.
For instance, if I use the C-way of loading a register
Code: |
WAIT_CONTROL = 0x4003; |
devkitPro generates the following code, viewed through VBA disassembler window.
Code: |
080005ee ldr r2, [$080005f8] (=$00004003) 080005f0 ldr r3, [$080005fc] (=$04000204) 080005f2 strh r2, [r3, #0x0] 080005f4 b $080005f |
The way I wrote it was:
Code: |
080005ee mov r0, #0x80 080005f0 lsl r0, r0, #0x7 080005f2 add r0, #0x3 080005f4 mov r1, #0x80 080005f6 lsl r1, r1, #0x0a 080005f8 add r1, #0x1 080005fa lsl r1, r1, #0x7 080005fc add r1, #0x1 080005fe lsl r1, r1, #0x02 08000600 strh r0, [r1, #0x0] |
My code uses 1 non sequential accesses on ROM and 9 sequential accesses. Devkitpro's code uses 6 nonsequential accesses and 1 sequential.
Which version would be faster generally? I know sequential access on ROM is faster, but would the greater amount of statements to process in my code negate this advantage?