This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Assembler directive help


Assembler directive help

Postby GlenC » Aug 28, 2004 @ 5:42pm

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.
GlenC
pm Member
 
Posts: 11
Joined: Feb 9, 2004 @ 3:03pm


Re: Assembler directive help

Postby Kak » Aug 28, 2004 @ 6:25pm

User avatar
Kak
pm Member
 
Posts: 291
Joined: Jul 26, 2003 @ 12:24pm
Location: Zannarkand, Spira


Postby GlenC » Aug 28, 2004 @ 7:02pm

GlenC
pm Member
 
Posts: 11
Joined: Feb 9, 2004 @ 3:03pm


Postby GlenC » Aug 28, 2004 @ 7:42pm

GlenC
pm Member
 
Posts: 11
Joined: Feb 9, 2004 @ 3:03pm


Postby Tala » Aug 29, 2004 @ 11:59pm

Tala
pm Member
 
Posts: 125
Joined: Feb 6, 2004 @ 4:32pm


Postby GlenC » Aug 30, 2004 @ 6:44pm

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.
GlenC
pm Member
 
Posts: 11
Joined: Feb 9, 2004 @ 3:03pm


Postby Tala » Sep 1, 2004 @ 10:41am

Tala
pm Member
 
Posts: 125
Joined: Feb 6, 2004 @ 4:32pm


Postby GlenC » Sep 1, 2004 @ 11:29am

GlenC
pm Member
 
Posts: 11
Joined: Feb 9, 2004 @ 3:03pm


Postby Tala » Sep 1, 2004 @ 4:30pm

Tala
pm Member
 
Posts: 125
Joined: Feb 6, 2004 @ 4:32pm


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum