All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Marmond <fmarmond@eprocess.fr>
To: ram <ram@curvesoft.com>
Cc: linux-assembly@vger.kernel.org
Subject: Re: gas "ljmp" instruction
Date: Mon, 16 Dec 2002 08:24:18 +0100	[thread overview]
Message-ID: <3DFD7FA2.8050808@eprocess.fr> (raw)
In-Reply-To: 3DFD1CAF.6010106@curvesoft.com

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
>




  reply	other threads:[~2002-12-16  7:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-16  0:22 gas "ljmp" instruction ram
2002-12-16  7:24 ` Frederic Marmond [this message]
2002-12-17  4:09 ` Doug Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3DFD7FA2.8050808@eprocess.fr \
    --to=fmarmond@eprocess.fr \
    --cc=linux-assembly@vger.kernel.org \
    --cc=ram@curvesoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.