#3684 - regularkid - Wed Mar 05, 2003 3:45 am
Hi!
I am trying to access an array in asm code and can't seem to do it without using a multiply. There has to be a better way of doing this! So, say I want to translate this C code into ASM, I would do:
C Code:
ASM Code:
This still works, however I have a feeling that there is a much quicker way of doing this. So, I put in the -S compiler option and this is what the above C code translated into:
I have no idea what this is trying to do! Can someone help me try to understand this code or maybe just help me find a quick way to access an element from an array? Thanks so much!
_________________
- RegularKid
I am trying to access an array in asm code and can't seem to do it without using a multiply. There has to be a better way of doing this! So, say I want to translate this C code into ASM, I would do:
C Code:
Code: |
int x = 10; myArray[10] = 5; |
ASM Code:
Code: |
ldr r0, =myArray mov r1, #4 mov r2, #10 mul r3, r1, r2 add r0, r0, r2 ldr r0, [r0] |
This still works, however I have a feeling that there is a much quicker way of doing this. So, I put in the -S compiler option and this is what the above C code translated into:
Code: |
mov ip, sp stmfd sp!, {fp, ip, lr, pc} sub fp, ip, #4 sub sp, sp, #4 |
I have no idea what this is trying to do! Can someone help me try to understand this code or maybe just help me find a quick way to access an element from an array? Thanks so much!
_________________
- RegularKid