Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why says that JMP may not >127bytes?

Status
Not open for further replies.

syskplim

Technical User
Nov 17, 2003
46
0
0
MY
as i read from many reference books, i got this JMP may not more that 127 bytes up and down.

how about if i ve many lines in my programming?

.
.
.
JNE QUIT_HERE
.
.
. more than 127 lines
.
.

QUIT_HERE:
.
.
.
.

?????




---->ASM fresher need help!<----

With kind regards.
syskplim@streamyx.com
 
Jump with condition is only for a short range, so there is nothing you can do about it.

If you have more than that, you should consider to make it as procedure (subroutine) or break it down into smaller routine.

Or you can use JMP (without condition). this instruction has more range (–32,768 to +32,767 bytes)

Regards

-- AirCon --
 
The conditional jumps like JNZ are two byte instructions.

JNZ encodes as 076h 0xxh

where the 0xxh contains the displacement from the current value in the instruction pointer.

Since it is a single byte, you have a limit of +126/-127 bytes.

so if you wanted to do

JNZ here

...

here: ;here is more than 127 bytes away from JNZ

then you could do

JZ skipit
JMP here ;this encodes as 0e9h 0xxh 0xxh

skipit:

......


here: ;here is within +/-32768 bytes of the JMP instruction (for a near JMP).

It ain't pretty, but it works.

There are also FAR jumps, but I don't think I'd use those.

rgds
Zeit.
 
ok. i got it now.

JNE/JZ.. has only -127<>127 but 'JMP XXX' has -/+32768

i thought all of them got only -/+127. Thats why i blur..


thnkx AirCon, thnkx Zeit.



---->ASM fresher need help!<----

With kind regards.
syskplim@streamyx.com
 
Hi guys! u r right concerning jumps but this is applicable to 8086 instructions. as i can recall, for 386+ CPUs long conditional jumps are possible (at least for 32 bit code).
here comes an example taken from some proggy in my windows dir:
0F8D09000000 jge 0004014FB

generally, such opcodes start with 0F prefix

for coding u will need .386 (. 486 ?) directive

regards
 
Oleksii is right. You can do it in 16-bit code too. There can't be many 286-and-earlier processors still in action nowadays.
 
Hi, I've just looked up the conditional jumps, the 16 bit displace (with prefix byte 0fh) seems to have come in with the 386.

Don't suppose there are many 286 systems left now.

I do remember a pick & place machine for surface mount components that relied on the processor being a 12MHz 286 for software timing loops.

Wonder if the manufacturer is still selling those....

rgds
Zeit.
 
Arrghh..

Oleksii is right. You can do it in 16-bit code too. There can't be many 286-and-earlier processors still in action nowadays.

Guess I've been away too looong from Assembly :-D

-- AirCon --
 
i'll try it out. thnkx all. [peace]






---->ASM fresher need help!<----

With kind regards.
syskplim@streamyx.com
 
Nice thing is according to my Maljugin et al. revolutionary guide to assembly it's got the same cycle count. One should be wary of cycle counts, but there's a sporting chance the 16-bit (or 32-bit) displacement won't actually cost anything (except the extra 1-3 bytes). I must admit I'm not sure how many of my conditional jumps are larger than 128 bytes - I tend to let the assembler get on with it and don't notice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top