flat assembler
Message board for the users of flat assembler.

flat assembler > Main > Something like ORG $-2

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 40
In MASM I can write:
Code:
jmp x mov ax,1234h org $-2 x: mov bx,cx
and replace 1234h with mov bx,cx

But how can I do this in fasm?
Post 08 Jul 2018, 11:39
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6873
Location: Kraków, Poland
You can do it with a combination of LOAD and STORE:
Code:
mov ax,1234h virtual at 0 mov bx,cx load tmp word from 0 end virtual store word tmp at $-2
But in this specific case just LOAD would be enough:
Code:
virtual at 0 mov bx,cx load tmp word from 0 end virtual mov ax,tmp
Post 08 Jul 2018, 13:41
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 40
Tomasz, maybe you can add MASM-style org directive (named e.g. .org)? To move forward and backward by code Smile
Post 09 Jul 2018, 16:34
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6873
Location: Kraków, Poland
This would not cooperate well with how the addressing spaces work in fasm's engine.

But you could make some macros that would make the entire process easier. Like:
Code:
macro rewrite address { virtual at address } macro end_rewrite { local ..area,..top,..bottom,..a ..area:: ..top = $ ..bottom = $$ end virtual if $ < ..top rb ..top - $ end if repeat ..top - ..bottom load ..a byte from ..area:..bottom+%-1 store byte ..a at ..bottom+%-1 end repeat } mov ax,1234h rewrite $-2 mov bx,cx end_rewrite
Post 09 Jul 2018, 17:17
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 40
Oh, thanks!
Why are you using double dots .. in names.
Is there some special meaning? Or you just like to do so? Smile
Post 09 Jul 2018, 17:43
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 © 2004-2018, Tomasz Grysztar.

Powered by rwasa.