Re: Getting NASM from C

From: Frank Kotler (fbkotler_at_comcast.net)
Date: 05/27/04

  • Next message: The Wannabee: "Re: RosAsm - right click"
    Date: Thu, 27 May 2004 06:37:37 GMT
    
    

    assemblyperson wrote:
    >
    > I have been trying to find the complete list of int 80h system calls
    > together with information about how the registers need to be set up
    > prior to the call in NASM under Debian Linux. I also wish not to
    > learn the C programming language.

    You're dealing with an OS that's written and documented in C.

    > I have found that good information is obtained by disassembling short
    > programs that are documented in C:

    Mmmm... if ya wanna learn how C does it...

    > ndisasm -a -u <filename>

    That'll work (well, the "-a" switch doesn't actually work very well,
    that I've noticed). You may well want to include some other switches to
    get the correct "origin", and to skip over the header.
     
    > The registers are lined up and filling with the right numbers to make
    > the call, but what the numbers mean is learned from the comments in
    > the short C program.

    ... if you've got the appropriate, intelligently-commented C program...
    fortunately, they're pretty common...
     
    > Man 2 write, for instance is unreadable unless you can program in C,

    Balderdash! All you need to be able to do is filter out the C cruft.

    ssize_t write(int fd, const void *buf, size_t count);

    dword write(dword fd, dword buf, dword count);

    They're all dwords, for practical purposes. C enthusiasts will assure
    you that having a bazillion names for the same thing is highly
    desireable, but they're going in 32-bit registers - they're dwords.

    There is no such thing as "errno"! That's a variable that C defines
    somewhere. The syscalls return -ERRNO in eax. Don't believe what man 2
    says about "errno"...

    > and it never tells you what the registers are loaded with in terms of
    > NASM.

    Same with Nasm as with any other assembler that runs on Linux - syscall
    number in eax, first parameter in ebx, second parameter in ecx, third
    parameter in edx, then esi, edi... or is it edi, esi? You don't often
    run into that many parameters. There are exceptions... the socketcalls
    take a "subfunction number" in ebx. In case of too many parameters to
    fit in registers, there's a pointer to a structure in ebx (or ecx, for
    socketcalls). In general, the stuff in the parentheses in the C
    prototype goes in ebx, ecx, edx...

    > I have investigated the matter very thoroughly. All of the Internet
    > pages that used to contain what I need are gone.

    This unfortunately seems to be true, although IIRC the
    no-longer-available pages had a lot of "blank spots", too.

    > The system calls are
    > not documented by the operating system itself (at least not on my
    > machine).

    Well, you have, or can get, source code for the entire OS, and that's
    the "ultimate documentation". It surely isn't in a convenient form for
    Nasm users!

    > Perhaps there is a better way of accomplishing what I want.

    Maybe finding some of the "missing" pages would be easier. Maybe
    spamming all the Linux related groups you can find would turn up
    something? *Somebody* must have those files!

    > If not, I
    > am looking for a C programmer who is interested in helping me solve
    > this problem.

    I'm not a C programmer, by any means, but I can "filter" enough C to get
    something working based on what I read in man 2... in *some* cases, at
    least...

    > I promise you that if I get the complete documentation I will cause it
    > to be placed back on the Internet.

    I suspect if you collected what you *can* find, and made it into a
    "fill-in-the-blanks" document of some kind, making it easy for people to
    contribute, you'd get some help. With minor modifications, it would make
    a great pop-up help file for LuxAsm!

    I'll cc this to the !Yahoo! linux-nasm-users group to get the ball
    rolling... they need some traffic! (hi, list! :)

    Best,
    Frank


  • Next message: The Wannabee: "Re: RosAsm - right click"

    Relevant Pages