delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/09/20:05:11

Date: Thu, 9 Oct 1997 17:02:44 -0700 (PDT)
Message-Id: <199710100002.RAA14815@adit.ap.net>
Mime-Version: 1.0
To: "Gurunandan R. Bhat" <grbhat AT unigoa DOT ernet DOT in>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Asm question

At 07:53  10/7/1997 +0000, Gurunandan R. Bhat wrote:
>
>Greetings,
>
>	I need help in understanding the nature of the operand for the 
>	"jmp" instruction. For example in 
>
>	jmp operand
>
>	what are the possible operands. If I want to give a segment overide, 
>	can I set "operand" to a 6 byte area which holds sel:off? 
>	When does one attach a prefix (ljmp) and when a suffix (jmpl) or are 
>	both equivalent? 
If you are using `as', the instructions are called `jmp' for a near jump,
and `ljmp' for a far jump. All jumps in `as' are 32-bit jumps.
For the near jump, possible operands are:
* Near jump to displacement, which assembler figures out. Displacement is
immediate value.
jmp foo
# ...
foo:
# ...

You can also do it explicitly:
jmp 100 # jump 100 bytes ahead

jmp *100 #jump to address 100

* Indirect near jump, with address in register or memory.
movl eax,$foo
jmp *%eax # jump to foo

In memory:
address_of_label: .long 0

movl address_of_label,$foo
jmp *address_of_label

For a far jump:
* Immediate 6-byte seg:ofs address:
ljmp $1234:$56789000 # jump to address 56789000 in selector 1234

* Indirect, address of 6-byte pointer supplied:
pointer: .long OFFSET_OF_LABEL
         .short SELECTOR_OF_LABEL

ljmp pointer #jump to far address stored at `pointer'

Note that any place you supply a memory operand, you can also use indirect
addresses from registers (`(%ebx)'), displacements, scaling, etc.

I hope this has helped.



Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019