Page 1 of 1

Assembler directive help

PostPosted: Aug 28, 2004 @ 5:42pm
by GlenC
Hi Gurus :D

I have written some asm that will be relocatable but am stuck on a problem accessing a table as follows

ASM_table DCB 1,2,3,4,5

and am referencing it using

ldr r5,=ASM_table
ldrb r1,[r5,r0]

This produces a pc relative lookup, but uses a fixed address at the end of the code to get the table, ie

ldr r5,[pc,#0x222]

this is not really acceptable to relocatable code, as it uses a fixed addess within a lookup table. What I would ideally like (and I'm not sure of the way of doing this is)

add r5,pc,-60

which will give me the address of the table, but without having to do a lookup and is fully relocateable, providing the table stays the same distance away from the code.

I don't see why this isn't possible, but I dont know the syntax on how to get the assembler to produce this code, rather than the first code which it currently produces.

I hope I've explained that clearly enough :)

Thanks

Glen.

Re: Assembler directive help

PostPosted: Aug 28, 2004 @ 6:25pm
by Kak

PostPosted: Aug 28, 2004 @ 7:02pm
by GlenC

PostPosted: Aug 28, 2004 @ 7:42pm
by GlenC

PostPosted: Aug 29, 2004 @ 11:59pm
by Tala

PostPosted: Aug 30, 2004 @ 6:44pm
by GlenC
Hi Tala,

The reason the first version is not suitable for relocation is the code generated by the assember will hard code the table refernce to a specific address

ie

Table address is say at 0x12345678

the code

ldr r5,=ASM_table

will actually produce

ldr r5,[pc,#0x222]

then at location

pc+0x222 DCW 0x12345678

The DCW produced by the assembler is hard coded to the table address, therefore it is not relocatable.

The data stays in the assembler code section, as it's dynamically loaded.

Glen.

PostPosted: Sep 1, 2004 @ 10:41am
by Tala

PostPosted: Sep 1, 2004 @ 11:29am
by GlenC

PostPosted: Sep 1, 2004 @ 4:30pm
by Tala