flat assembler
Message board for the users of flat assembler.

Index > Main > [$2 vs $ + 2] How to declare jump to relative address

Author
Thread Post new topic Reply to topic
Art Vandelay



Joined: 23 Jan 2015
Posts: 2
Location: Canada
Art Vandelay
How can I jump ahead by a certain number of bytes? Doing something like jmp 2 attempts to jump to the address 0x00000002 in memory, instead of EB 02.

Aside from entering it in bytes, I can't figure out how to do it. Is there something I can enter that specifies the address is relative? I'm trying to play around with jump tables and things like that, and writing in hex is a pain to read.
Post 23 Jan 2015, 20:53
View user's profile Send private message Reply with quote
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt
1.2.4 Numerical expressions:
Quote:

There are also some special symbols that can be used inside the numerical expression. First is $, which is always equal to the value of current offset, while $$ is equal to base address of current addressing space.

Code:
jmp $ + 2 ;EB 02
    
Post 23 Jan 2015, 20:56
View user's profile Send private message Visit poster's website Reply with quote
Art Vandelay



Joined: 23 Jan 2015
Posts: 2
Location: Canada
Art Vandelay
thanks

I tried doing jmp $2 when I read that section of the documentation *facepalm*
Post 23 Jan 2015, 21:02
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Welcome to the FASM forum. The dollar symbol can also prefix HEX numbers:

Code:
MOV CL, $2 ; Same as "MOV CL, 2"
MOV EAX, $FFFF'FFFF
INC EAX ; Will be ZERO now Wink
    
Post 30 Jan 2015, 10:27
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.