flat assembler
Message board for the users of flat assembler.

Index > Non-x86 architectures > Handling LDR reg,=constant?

Author
Thread Post new topic Reply to topic
mark4th



Joined: 02 Jun 2012
Posts: 2
mark4th
Just downloaded and gave this a try and have a feature request. not sure if fasm arm is developed by the same author though...

could we please implement a ldr reg, =literal syntax for loading literals?

plzz? Smile

i would like to be able to port my forth compiler (for linux) to android and fasm arm would be perfect for this except i hate having to add extra verbosity to what should be simple operations. im kind of anally retentive about keeping my source files SUPER neat and tidy ya know Smile
Post 02 Jun 2012, 07:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16884
Location: In your JS exploiting you and your system
revolution
Using the "=" format of the LDR opcode is a pseudo instruction. You won't find it in the CPU manual because the CPU does not support it.

With that in mind: To follow the fasm paradigm this type of thing is best suited to using a macro. The "=" form involves two parts. 1) the instruction is converted to an ordinary LDR reg,[PC+offset] and, 2) later the compiler must find a place to insert the literal constant into the output file. It is the second part that must be properly coordinated by the macro. The assembler cannot determine the appropriate place to insert the literal constant value.

Simply inserting a constant randomly into the output can cause problems if it is not properly done with the overall control by the programmer. Often this is controlled by the use of proc/endp to signal that it is safe to insert values between such pairs. But proc/endp are also macros and the assemlber has no such knowledge of their inner workings to be able to do automatic insertions.

Moving to non-x86 section
Post 02 Jun 2012, 07:38
View user's profile Send private message Visit poster's website Reply with quote
mark4th



Joined: 02 Jun 2012
Posts: 2
mark4th
Yes,the =literal syntax is like a forward ref to a local lable. the assembler should be able to remember all these forward references and the USER should define where they get resolved with a .ltorg directove or ltorg (that dot always looked FUNKY to me too).

as with local labels this literal pool needs to be within a certain distance of the code referencing it and if its out of range we could have a "pool out of range" error here.

i dont think this would be too difficult to implement, after all you already have local labels!
Post 02 Jun 2012, 08:11
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.