#1275 - animension - Thu Jan 16, 2003 4:00 am
I'm trying to access the BIOS divide utility (SWI 6) and I'm having trouble inlining the ASM calls. Here's the source code:
What I get from the compiler is:
A look at the asm file that is generated by the compiler shows:
Why is this in C++ inline ASM:
Turning into this in generated ASM:
Does anyone have any idea why the substitions aren't working? I'm totally new at inlining ASM so any help would be appreciated.
Thanks!
Code: |
void BIOSDIV( signed long numerator, signed long denominator, signed long *div, signed long *mod, signed long *abs ){ asm volatile( " @ SUBSTITUTION LIST @ 0: %0 @ 1: %1 @ 2: %2 @ 3: %3 @ 4: %4 ldr r0,=%3 @ Load the value of %3(numerator) into r0 ldr r1,=%4 @ Load the value of %4(denominator) into r1 swi 6 @ Call BIOS SWI 6 (DIV) str r0,[%0] @ Store value of r0 (numerator DIV denominator) into &div str r1,[%1] @ Store value of r1 (numerator MOD denominator) into &mod str r2,[%2] @ Store value of r2 (abs of numerator DIV denominator) into &abs " : "=r"(div), "=r"(mod),"=r"(abs) // OUTPUT LIST : "r"(numerator), "r"(denominator) // INPUT LIST : "r0","r1","r2","r3","r4","r5" // CLOBBER LIST ); } |
What I get from the compiler is:
Code: |
test.o: In function `BIOSDIV(long, long, long*, long*, long*)': test.o(.text+0x88): undefined reference to `lr' test.o(.text+0x8c): undefined reference to `ip' |
A look at the asm file that is generated by the compiler shows:
Code: |
_Z7BIOSDIVllPlS_S_: @ Function supports interworking. @ args = 4, pretend = 0, frame = 0 @ frame_needed = 0, current_function_anonymous_args = 0 stmfd sp!, {r4, r5, r6, lr} mov lr, r0 mov ip, r1 @ SUBSTITUTION LIST @ 0: lr @ 1: r6 @ 2: ip @ 3: lr @ 4: ip ldr r0,=lr @ Load the value of lr(numerator) into r0 ldr r1,=ip @ Load the value of ip(denominator) into r1 swi 6 @ Call BIOS SWI 6 (DIV) str r0,[lr] @ Store value of r0 (numerator DIV denominator) into &div str r1,[r6] @ Store value of r1 (numerator MOD denominator) into &mod str r2,[ip] @ Store value of r2 (abs of numerator DIV denominator) into &abs ldmfd sp!, {r4, r5, r6, lr} bx lr |
Why is this in C++ inline ASM:
Code: |
@ SUBSTITUTION LIST @ 0: %0 @ 1: %1 @ 2: %2 @ 3: %3 @ 4: %4 |
Turning into this in generated ASM:
Code: |
@ SUBSTITUTION LIST @ 0: lr @ 1: r6 @ 2: ip @ 3: lr @ 4: ip |
Does anyone have any idea why the substitions aren't working? I'm totally new at inlining ASM so any help would be appreciated.
Thanks!