🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.asm.x86
3 messages
3 total messages Started by assassin17 Sun, 08 Aug 1999 00:00
Relative jump out of range (ignore the last post)
#82
Author: assassin17
Date: Sun, 08 Aug 1999 00:00
30 lines
1757 bytes

i'm trying to figure out how TASM determines whether a JMP is out
of range..  take this program:

.386
CODE SEGMENT USE32 'CODE'
    ASSUME  CS:CODE
    lab:
    jmp SMALL NEAR PTR krad
    db 0FFFFh dup (0)
    db 0
    krad:
    jmp SMALL NEAR PTR lab
CODE ENDS
END lab

the first JMP returns a "Relative jump out of range by 8002h bytes"
error, while the second one has no problem.  i'm not complaining about
TASM here as i shouldn't be specifying SMALL jumps in the first place.
but does anybody know how the assembler could be calculating relative
jumps that would cause one to yield an error but not the other?

thanks

assassin17@rocketmail.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Re: Relative jump out of range (ignore the last post)
#83
Author: John S. Fine
Date: Mon, 09 Aug 1999 00:00
44 lines
2417 bytes
assassin17@rocketmail.com wrote:

> i'm trying to figure out how TASM determines whether a JMP is out
> of range..

  I never tested, but I think I understand the 386 manual and I
expect that it is correct:  A SMALL NEAR JMP does not sign
extend to 32 bits.  It adds the 16-bit offset to IP and
clears the high half of EIP.

  That means you can SMALL NEAR JMP from anywhere to any address
within the first 64Kb of the segment and you cannot ever SMALL
NEAR JMP to any address outside the first 64Kb.

> .386
> CODE SEGMENT USE32 'CODE'
>     ASSUME  CS:CODE
>     lab:
>     jmp SMALL NEAR PTR krad
>     db 0FFFFh dup (0)
>     db 0
>     krad:
>     jmp SMALL NEAR PTR lab
> CODE ENDS
> END lab
> 
> the first JMP returns a "Relative jump out of range by 8002h bytes"
> error, while the second one has no problem.  i'm not complaining about
> TASM here as i shouldn't be specifying SMALL jumps in the first place.
> but does anybody know how the assembler could be calculating relative
> jumps that would cause one to yield an error but not the other?

  I think part of the meaning of "SMALL" is that the assembler
should accept a 16-bit offset in situations in which you can't
know until link time whether a 16-bit offset can work.

  In your second JMP, you can't know til link time whether the target
will be in the first 64Kb of CODE.

  In your first JMP, you know at assembly time that it can't be
correct.
-- 
http://www.erols.com/johnfine/
http://www.geocities.com/SiliconValley/Peaks/8600/
Re: Relative jump out of range (ignore the last post)
#81
Author: assassin17
Date: Sun, 15 Aug 1999 00:00
55 lines
2815 bytes
  johnfine@EROLS.COM wrote:
> assassin17@rocketmail.com wrote:
>
> > i'm trying to figure out how TASM determines whether a JMP is out
> > of range..
>
>   I never tested, but I think I understand the 386 manual and I
> expect that it is correct:  A SMALL NEAR JMP does not sign
> extend to 32 bits.  It adds the 16-bit offset to IP and
> clears the high half of EIP.
>
>   That means you can SMALL NEAR JMP from anywhere to any address
> within the first 64Kb of the segment and you cannot ever SMALL
> NEAR JMP to any address outside the first 64Kb.

thanks for the reply.  that definitely makes more sense of things, and
testing largely confirms the above rule.  but this code has left me
boggled:

.386
CODE SEGMENT USE32 'CODE'
    ASSUME  CS:CODE
    lab:
    db 65536 dup (0)
    krad:
    db 200 dup (55h)  ;padding to prevent a SHORT jmp
    jmp SMALL NEAR PTR krad
CODE ENDS
END lab

if i understood you right, you're saying "you cannot ever SMALL NEAR JMP
to any address outside the first 64Kb" -- _from anywhere_?  yet the
code assembles fine.  however, if 65536 is upped to 65539, a
"Relative jump out of range by 8001h bytes" error results.  what's the
significance of 65539 (or 3)?

and SHORT JMPs don't get error messages from TASM in the same
cases as the SMALL NEAR ones, but that's not really bugging me. :P

assassin17@rocketmail.com

[snip - my garbage]

>   I think part of the meaning of "SMALL" is that the assembler
> should accept a 16-bit offset in situations in which you can't
> know until link time whether a 16-bit offset can work.
>
>   In your second JMP, you can't know til link time whether the target
> will be in the first 64Kb of CODE.
>
>   In your first JMP, you know at assembly time that it can't be
> correct.

--
=-=  assassin17@rocketmail.com  =-=
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads