Gnu assembler question for ARM
Ciaccia
ciacciax@yahoo.com
Thu May 3 13:47:00 GMT 2007
Dear all,
I'm writing you not because I'm lazy, but because I really could not find an answer to my issue online, so I'm asking you advice about that.
I'm writing an 100% assembler function for a Cirrus ep9312 core (ARM), and I am using gnu gcc+gnu as. The Cirrus ep9312 has a floating-point co-processor, and I am trying to write an highly optimized DSP code for it. Everything is fine, but I'm having problems with floating-point "constants".
Consider the following C code:
void test(float *buffer)
{
buffer[0] += 1.0f;
}
I am trying to port this to assembler. Here is my function (1st version):
--------------------------------------------------------------------------------
.text
.globl asm_test;
.align 4,0x90
myvar1: .float 1.0
asm_test:
cfldrs c0, [r0, #0] @ load buffer[0] in c0
adr r1, myvar1
cfldrs c1, [r1, #0] @ load 1.0 in c1
cfadds c0, c0, c1
cfstrs c0, [r0, #0]
mov pc, lr
--------------------------------------------------------------------------------
Then I improved it as following:
--------------------------------------------------------------------------------
.text
.globl asm_test;
.align 4,0x90
myvar1: .float 1.0
asm_test:
cfldrs c0, [r0, #0] @ load buffer[0] in c0
cfldrs c1, [pc, #-16] @ load 1.0 in c1
cfadds c0, c0, c1
cfstrs c0, [r0, #0]
mov pc, lr
--------------------------------------------------------------------------------
This version is "better" (and faster, but less readable) since I got rid of one instruction (adr r1, myvar1) and I did not change the content of r1.
Is there a nice way of doing this without having to manually compute the distance in bytes between the current PC and the memory area where the local variable is stored? I wonder if something like this exists:
asm_test:
ldr r0, [pc, #(myvar1_adr - current_op_address - 8)]
mov pc, lr
?!? I have seen that the dot '.' operator returns the value of the current instruction, but I was not able to use it...
Any help is greatly appreciated
Thanks in advance
Best regards
Andrea
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Binutils
mailing list