Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Nov 1998 23:09:55 +0200 (SAT)
From:      Robert Nordier <rnordier@nordier.com>
To:        crossd@cs.rpi.edu (David E. Cross)
Cc:        rnordier@nordier.com, ru@ucb.crimea.ua, hackers@FreeBSD.ORG
Subject:   Re: FreeBSD on i386 memory model
Message-ID:  <199811132109.XAA13342@ceia.nordier.com>
In-Reply-To: <Pine.SGI.4.05.9811131447590.6396-100000@o2.cs.rpi.edu> from "David E. Cross" at "Nov 13, 98 02:49:42 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
David E. Cross wrote:
> 
> That is great.  Could you sprinkle a comment or 2 as to what it is doing?
> 
> ie, I am not sure what the 'call .+0x5' and 'lcall $0x7,0x0' do.

The "call .+0x5" just calls the location corresponding to the start
of the next instruction (the '.' is the current location and a call
is encoded as 5 bytes).  The "lcall 0x7,0x0" does a system call.

        # Get offset of main in %ebp
        main:   call .+0x5
                popl %ebp
                subl $0x5,%ebp
        # write(STDOUT_FILENO, msg, sizeof(msg));
                pushl $msg.1-msg
                leal msg-main(%ebp),%eax
                pushl %eax
                pushl $0x1
                movl $0x4,%eax  # SYS_write
                call .+0x5
                lcall $0x7,$0x0
        # exit(0);
                pushl $0x0
                movl $0x1,%eax  # SYS_exit
                call .+0x5
                lcall $0x7,$0x0
        msg:    .ascii "hello, world!\n"
        msg.1:

It is really just intended as a curiosity, and is neither very
idiomatic nor very correct. :-)

-- 
Robert Nordier

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811132109.XAA13342>