* gas "ljmp" instruction
@ 2002-12-16 0:22 ram
2002-12-16 7:24 ` Frederic Marmond
2002-12-17 4:09 ` Doug Smith
0 siblings, 2 replies; 3+ messages in thread
From: ram @ 2002-12-16 0:22 UTC (permalink / raw)
To: linux-assembly
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gas "ljmp" instruction
2002-12-16 0:22 gas "ljmp" instruction ram
@ 2002-12-16 7:24 ` Frederic Marmond
2002-12-17 4:09 ` Doug Smith
1 sibling, 0 replies; 3+ messages in thread
From: Frederic Marmond @ 2002-12-16 7:24 UTC (permalink / raw)
To: ram; +Cc: linux-assembly
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
ram wrote:
> 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
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gas "ljmp" instruction
2002-12-16 0:22 gas "ljmp" instruction ram
2002-12-16 7:24 ` Frederic Marmond
@ 2002-12-17 4:09 ` Doug Smith
1 sibling, 0 replies; 3+ messages in thread
From: Doug Smith @ 2002-12-17 4:09 UTC (permalink / raw)
To: ram; +Cc: linux-assembly
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.
--
Doug Smith: C.S.F.C.
Computer Scientist For CHRIST!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-17 4:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-16 0:22 gas "ljmp" instruction ram
2002-12-16 7:24 ` Frederic Marmond
2002-12-17 4:09 ` Doug Smith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).