pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pgubook-readers] exit.s on amd64? 0x3c.


From: Guillaume Yziquel
Subject: [Pgubook-readers] exit.s on amd64? 0x3c.
Date: Fri, 01 Jan 2010 16:48:20 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707)

Hello.

I've been reading the beginning of the book, and have been wondering how to adapt the exit.s to the amd64 architecture, Linux.

Googling around, I found:

        http://www.vikaskumar.org/amd64/sample.htm

and more generally, stuff on this website seems quite up the point. But unfortunately, in nasm / yasm. So I'm feeling quite a lot of pain trying to use these two different sources together: the PGU book in gas, and this amd64 documention in nasm / yasm.

I've been trying the following, as an adaptation of the exit.s program (the first sample of code in the PGU book.) It works.

#PURPOSE:   Simple program that exits and returns a
#           status code back to the Linux kernel
#

#INPUT:     none
#

#OUTPUT:    returns a status code.  This can be viewed
# by typing #
#           echo $?
#
#           after running the program

#VARIABLES:
#           %rax holds the system call number
#           %rdi holds the return status
#
.section .data

.section .text
.globl _start
_start:
movq $0x3c, %rax    # This is the linux kernel command
                    # number (system call) for exiting
                    # a program

movq $2, %rdi       # This is the status number we will
                    # return to the operating system.
                    # Change this around and it will
                    # return different things to
                    # echo $?

syscall             # This wakes up the kernel to run
                    # the exit command

The thing that I'd like to know is the following:

-1- The syscall numbers are different. Where do you get the list of syscall numbers?

-2- Would you believe useful to include a few info in PGU for amd64? (How to make syscalls, where to find the syscalls numbers, etc...)

Thank you very much for the PGU book. It is quite excellent.

All the best,

--
     Guillaume Yziquel
http://yziquel.homelinux.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]