flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [BUG] EIP/RIP symbols improperly handled

Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
use64
eip: ; Accepted
rip: ; Accepted

;jmp eip ; Error "invalid address"
;jmp rip ; Error "invalid address"

lea rax, [rip] ; Works but rax is set with the run-time rip_value memory address
rip_value:    


The problem is in TABLES.INC (EIP/RIP is added as an addressing register but not in the reserved symbols table).

BTW, why the tables are hand-made instead of defined more safely with the interpreter layer and maybe with the preprocessor as well?
Post 06 Aug 2008, 01:05
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
You're right, the addressing registers table is not scanned when checking for reserved words - perhaps the simplest fix is to include EIP/RIP in main symbols table, too

The EAX points exactly where it should.

And as for the hand-made tables - that's mainly because I try to keep fasm's sources assemblable even with very basic version of compatible assembler - without any macros or advanced features.
It is for two reasons: one is, that is it a relict of the early times, when fasm was written and assembled with my very simple previous assembler (and it just stayed this way); the second reason is that I considered to write a very simple "startup assembler" in C, that would be used to make fasm from sources on linux systems starting with only C compiler. I never did this, but I still think that would be a good idea - maybe someone else would like to do it? Wink
Post 06 Aug 2008, 09:41
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

The EAX points exactly where it should.

haha, well RAX actually and yes I did know that, what I tried to point out was that "[rip]" used the RIP register instead of the rip label (that shouldn't be allowed to be defined like eax label).

Interesting idea that "startup assembler", candidate to be included in Project and Ideas forum. Could you create a thread and post the minimal feature set required for assembling fasm sources?
Post 06 Aug 2008, 17:18
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-2020, Tomasz Grysztar.

Powered by rwasa.