gas "ljmp" instruction
Hi,
I was looking at bootsect.S in the Linux sources to understand how the boot process works and noticed the "ljmp" instruction but I can find no documentation on it either in the Intel docs or the gas docs. Does anyone know what it does, and more generally, is there some documentation on the full set of x86 opcode mnemonics supported by gas ? I'm a novice at the x86 instruction set ...
Thanks.
Ram
Hi,
ljmp is 'long jump'
A 'short' jump (standard jump) will move your ip pointer to a near area (in real mode, in the +/-32768 bytes around => jmp 0x1234, which is the offset). If you need more displasment, you have to specify the segment (jmp 0x1234:0x5678). This is a far jump (long jump). I don't remember opcodes.
In the bootsect.S, we only copy the code at a different place, and then, run into our copy:
# First things first. Move ourself from 0x7C00 -> 0x90000 and jump there.
movw $BOOTSEG, %ax movw %ax, %ds # %ds = BOOTSEG movw $INITSEG, %ax movw %ax, %es # %ax = %es = INITSEG movw $256, %cx subw %si, %si subw %di, %di
cld
rep
movsw
ljmp $INITSEG, $go
We copy the code from BOOTSEG:0 to INITSEG:0, and jump to INITSEG:0.
Do you understant that?
cld: clear direction => auto increment
rep : will repeat next instruction while cx>0
movsw: move word from ds:si to es:di and
decrement cx
increment si (by 2, as we are moving words)
increment di (by 2 as well)
if the direction bit in the flags was 1, we would have decrement by2 si and di (so, the cld).
Is it clearer?
Fred
Quoted 18 lines · ram
Hi,
I was looking at
bootsect.Sin the Linux sources to understand how the boot process works and noticed the "ljmp" instruction but I can find no documentation on it either in the Intel docs or the gas docs. Does anyone know what it does, and more generally, is there some documentation on the full set of x86 opcode mnemonics supported by gas ? I'm a novice at the x86 instruction set ...Thanks.
Ram
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Join the club. I hope to have a few things straightened out at the first of the year and I can more easily help you. It appears that this ljmp means, if it's like the instruction sets I worked with in the past, long jump. In those days, it meant that the processor was to jump over either a page or bank boundary. If I remember correctly, it meant over a page boundary. I will have to study a little more on this and I will be happy to tell you more.
Hope this helps.
Signature · 2 lines
Doug Smith: C.S.F.C. Computer Scientist For CHRIST!