I am writing a boot loader and require the code to relocate itself after the BIOS loads it. When I tried it the processor hung. After several trial and error procedures I isolated the fault to the JMP instruction. This is what I tried:
mov bx, 0600h
jmp word ptr
it didn't work. This does work though:
byte 0eah, 00h, 06h, 00h, 00h
the difference is the opcode. The instruction that does not work uses an FF opcode (indirect through bx register), the instruction that does work uses an EA opcode (direct jump).
I have tried to do this but I get an assembler error:
jmp 0000:0600
So far I have not been able to find a way to do an absolute jump using MASM32 .. can you help on this one?
Thanks,
Craig
New Zealand
Hi ! You've got many solutions ,
the most structured ( and verbose one ) being along the lines :
Abs_0 Segment AT 0
;......................
Org 600h
There label far
.....
Abs_0 EndS
; ................
.code
; .............;;
Jump There
Thanks Nimbus, I found a solution yesterday. For some reason I thought I had read that
jmp WORD PTR
used the contents of bx for the jump. But then I read yesterday that this is an indirect jump and takes the contents of what bx points at and jump to that location. So the correct way to do an absolute jump is:
mov bx, 0600h
jmp bx
That worked.
Thanks for replying.
Craig
You're welcome !
Now note that jmp bx does an INTRASEGMENT jump - only ip
affected ; I thought you wanted a direct INTERSEGMENT - aka long - jump ( loads CS:IP ) . Your solution does of course
work PROVIDED you were already in the 0000: segment . Well
since I think I remember you're writing a boot loader , it
should be the case...
Another thing , do not confuse : jmp bx / jmp ! This is a frequent error among beginners, really.
/\/.