Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ERROR: ILLEGAL IMMEDIATE IN JMP INSTRUCTION

dany171dany171 Member Posts: 1
Hi to every body,

i have searched around all internet and i can't find a response to solve this error. It is good to say that i'm new, and learning by my self from a book.

well, the problem:

i'm working with: tasm 4.1 , turbo link version 7.1.30.1 and turbo debugger 5.0

this is my file "ej3.asm":
--------ej3.asm-----------
.model tiny
.code
org 100h
main:

mov al , 19h
mov ah , 20h

jmp 100h
int 20h
end main
-------end of file------

also i have writen a .bat file in order to automatizate my proceses.it is called "compile.bat" and it looks like this:

-------compile.bat---------
tasm ej3.asm ;to build the .obj file
pause
tlink /t ej3.obj ;to create the .com file
pause
td ej3 ;to review and check/learn what really happens
pause
------end of file-----------

ok, as you can see the code is really simple!:S.

BUT, when i run the compile.bat file or i type "tasm ej3.asm" in the shell, this error appears:

Asembling file: ej3.asm
**Error** ej3.asm(8) Illegal immediate
Error messages: 1
Warning messages: None
Passes: 1
Remaining memory: 447k

the instruction JMP is in the line 8, i have tried changing to "jmp 100", "jmp 0100", "jmp 0100h","jmp 0101","jmp 0101h" and it do not works.
In theory this instructions are valid, because they JMP make a should jump to (change the IP register) the specified instrucion, in this case the instruction placed in 0100 position.

Also i have tried changing to "jmp cs:0100h" it works ( ther is no ERROR and the program jumps), BUT , it is readed as "jmp cs:[0100h]" (i can see it in the debugger) so the program jump to another place, a really really far a way place. also i have tried with "cs:[100]","ds:[100]","ds:[100h]","ds:[101]", an so on. in the debugger i can see that cs and ds are pointing to the same place.

also, i have tried with "jmp main" and IT WORKS!! but, as far as know the error must not appear. and it is so complicated to make code writing a label "main, p0 , and so on" to every codeline.

so.....

what is wrong in all this?
how can i solve the problem?
why the error??
thanks for the help.




Comments

  • anthrax11anthrax11 Member Posts: 511
    : In theory this instructions are valid, because they JMP make a
    : should jump to (change the IP register) the specified instrucion, in
    : this case the instruction placed in 0100 position.

    [color=Blue]That's true. This is why Tasm is considered obsolete by now (it was made
    in 1992 or something?). A modern assembler like Fasm can understand
    "jmp 100h" without problems.[/color]

    : Also i have tried changing to "jmp cs:0100h" it works ( ther is no
    : ERROR and the program jumps), BUT , it is readed as "jmp
    : cs:[0100h]" (i can see it in the debugger) so the program jump to
    : another place, a really really far a way place. also i have tried
    : with "cs:[100]","ds:[100]","ds:[100h]","ds:[101]", an so on. in the
    : debugger i can see that cs and ds are pointing to the same place.

    [color=Blue]Tasm indeed resolves both "cs:100h" and "cs:[100h]" to "cs:[100h]".
    This is wrong. Btw, the instruction means to fetch an address from [100h]
    (whatever it may be) and jump to that address instead of 100h.[/color]

    : also, i have tried with "jmp main" and IT WORKS!! but, as far as
    : know the error must not appear. and it is so complicated to make
    : code writing a label "main, p0 , and so on" to every codeline.
    [color=Blue]
    I don't know what you mean by "main, p0 , and so on", but there is
    nothing too hard about making a label and using that as a target
    for a jump:[/color]
    [code]jmp overthere

    ; code to skip

    overthere:[/code]
    [color=Blue]Good luck in learning asm! :-)[/color]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : Hi to every body,
    :
    : i have searched around all internet and i can't find a response to
    : solve this error. It is good to say that i'm new, and learning by my
    : self from a book.
    :
    : well, the problem:
    :
    : i'm working with: tasm 4.1 , turbo link version 7.1.30.1 and turbo
    : debugger 5.0
    :
    : this is my file "ej3.asm":
    : --------ej3.asm-----------
    : .model tiny
    : .code
    : org 100h
    : main:
    :
    : mov al , 19h
    : mov ah , 20h
    :
    : jmp 100h
    : int 20h
    : end main
    : -------end of file------
    :
    : also i have writen a .bat file in order to automatizate my
    : proceses.it is called "compile.bat" and it looks like this:
    :
    : -------compile.bat---------
    : tasm ej3.asm ;to build the .obj file
    : pause
    : tlink /t ej3.obj ;to create the .com file
    : pause
    : td ej3 ;to review and check/learn what really happens
    : pause
    : ------end of file-----------
    :
    : ok, as you can see the code is really simple!:S.
    :
    : BUT, when i run the compile.bat file or i type "tasm ej3.asm" in the
    : shell, this error appears:
    :
    : Asembling file: ej3.asm
    : **Error** ej3.asm(8) Illegal immediate
    : Error messages: 1
    : Warning messages: None
    : Passes: 1
    : Remaining memory: 447k
    :
    : the instruction JMP is in the line 8, i have tried changing to "jmp
    : 100", "jmp 0100", "jmp 0100h","jmp 0101","jmp 0101h" and it do not
    : works.
    : In theory this instructions are valid, because they JMP make a
    : should jump to (change the IP register) the specified instrucion, in
    : this case the instruction placed in 0100 position.
    :
    : Also i have tried changing to "jmp cs:0100h" it works ( ther is no
    : ERROR and the program jumps), BUT , it is readed as "jmp
    : cs:[0100h]" (i can see it in the debugger) so the program jump to
    : another place, a really really far a way place. also i have tried
    : with "cs:[100]","ds:[100]","ds:[100h]","ds:[101]", an so on. in the
    : debugger i can see that cs and ds are pointing to the same place.
    :
    : also, i have tried with "jmp main" and IT WORKS!! but, as far as
    : know the error must not appear. and it is so complicated to make
    : code writing a label "main, p0 , and so on" to every codeline.
    :
    : so.....
    :
    : what is wrong in all this?
    : how can i solve the problem?
    : why the error??
    : thanks for the help.
    :
    :
    :
    :
    :
    [color=Blue]
    For all Intel instructions get Volume 2A and 2B from here:

    [link=http://www.intel.com/products/processor/manuals/]http://www.intel.com/products/processor/manuals/[/link]

    Now, about that particular case of yours:

    1. JMP instruction in your case expects the value to be an offset to the location you jumping - not the address. That offset must be in range of -128 .. +127 (you can check it in the manual). Your offset is 100h, which is 256 decimal and is out of range, which is why TASM sees it as an error.

    2. Why do you need to jump to the location, specified by the exact address? When code changes, the address you jumping to can change and you jump will end up not where you want it to be.

    3. There is also a form of the JMP (see manual) which uses a register for jumping farther than 128 bytes. This time is not a relative offset, but absolute address. Simply move the address into a register and then jump:
    [/color]
    [code]
    mov bx, 100h

    jmp bx
    jmp [bx]

    ; One of these JMP ^^^ instruction should work, I do not
    ; remember which one - I droped using TASM long ago.
    ; I recommend FASM actually - awesome Assembler!
    ; Try both of these instruction and see what is happening in debugger.
    [/code]
Sign In or Register to comment.