Re: Why doesn't this NASM program work? It loops endlessly

From: Frank Kotler (spamtrap_at_crayne.org)
Date: 03/27/05

  • Next message: Nathan Moore : "Re: Why doesn't this NASM program work? It loops endlessly"
    Date: Sun, 27 Mar 2005 21:53:49 +0000 (UTC)
    
    

    Francesca wrote:

    [Re: http://www.drpaulcarter.com/pcasm/ ]
    > I would have preferred that you had put a
    > section describing interaction between Linux OS and NASM,

    That would have been great, but... the whole "point" of Dr.
    Carter's tut is to be "portable" - you can learn assembly
    language using Windows, or Linux, or 32-bit dos/djgpp. The
    interface with the OS - any of 'em - is "hidden" behind C
    library calls. Strictly speaking, this interface isn't
    "assembly language". Obviously, you're interested in it (and
    I agree), but you'll have to learn that part elsewhere.

    > a section
    > describing in great details segments and other assembly conventions,

    You might be worrying too much about segments... Nasm uses
    "segment" and "section" interchangeably. In a 16-bit dos
    ..exe (which is maybe what you were doing with Masm), it
    makes sense to call 'em "segment"s - the different "chunks"
    of your program are expected to have different segment
    registers pointed to them. For Linux (or Windows), you can
    pretty much forget that segment registers exist (they do,
    and they're still a part of every address - but they work
    differently than in real mode, and the OS takes care of
    'em). The different "chunks" of your code have less to do
    with segment registers, and it makes more sense to call 'em
    "section"s.

    More details about segment *registers* here:

    http://my.execpc.com/~geezer/johnfine/segments.htm

    ....but I don't think that's really what you're interested
    in...

    Information about elf-specific Nasm usage of the
    "section"/"segment" directive here:

    <http://nasm.sourceforge.net/doc/html/nasmdoc6.html#section-6.5.1>

    ....but I guess you've read that(?). Just put your code in
    "section .text", your data in "section .data", and
    uninitialized data in "section .bss". Strictly speaking,
    "constant" data should go in "section .rodata" so it can't
    be written to, but ".data" will work fine.

    > may
    > be more simple examples, for people like to, absolute beginners.

    There are some examples in the "files" section of the
    linux-nasm-users Yahoo group. You'll have to subscribe to
    the group... http://groups.yahoo.com/group/linux-nasm-users/
    Not much traffic, but it's another place to discuss this
    stuff - and the "files" and "links" might interest you.

    > You know,
    > it is difficult to find a lot of materials about Asm programming, and what
    > is found assumes that you already know the basis.

    You might enjoy Jonathan Bartlett's "programming from the
    Ground Up". It's for Linux, but it uses Gas syntax rather
    than Nasm - not too much of a stretch to "mentally
    translate" the information for use with Nasm. (I've got the
    examples from the book translated to Nasm syntax - holler if
    you want 'em - I'll get 'em posted somewhere... someday...)

    http://www.cafepress.com/bartlettpublish.8640017

    Or get a free peek ("free" as in "freeloader") here:

    http://savannah.nongnu.org/projects/pgubook/

    In spite of the fact that it's not for Nasm, it covers a lot
    of Linux-specific information you'll want to know.

    There's a tutorial on Linux programming with Nasm here:

    http://docs.cs.up.ac.za/programming/asm/derick_tut/

    .... it kind of assumes you're familiar with dos programming
    and are just new to Linux, but it might be some help.

    The "homepage" for Linux programming information is:

    http://linuxassembly.org

    ....have I mentioned that one. My bad, if not... You can
    treat "asmutils" and "libASM" as more examples - although
    not for "pale green virgin newbies" perhaps... Good links to
    examples, tuts and papers on how to do various things...

    The "BSD Developer's Manual" has a chapter on assembly
    language programming. Linux and BSD differ, when we get down
    to the sys_call interface, so you can't take it all
    literally, but the "general principles" apply.

    That ought to keep you busy for a while :)

    Best,
    Frank


  • Next message: Nathan Moore : "Re: Why doesn't this NASM program work? It loops endlessly"

    Relevant Pages

    • Re: Question for RosAsm users
      ... FASM or NASM, if i recall well... ... main reason in relationship with Linux Programming? ... Other than that yes, since I use both XP and Linux, NASM works for me. ...
      (alt.lang.asm)
    • Re: Help with Enter and Leave Instructions
      ... If you're more familiar with doing it with equates, ... but it's one of the parts that's a PITA to "translate" to Nasm ... so you can "port" it to Linux. ... But perhaps we can minimize the "schlepping" - if RosAsm foesn't ...
      (alt.lang.asm)
    • Re: New to Debian Linux - I have NASM experience under DOS 6.22
      ... > simple NASM program under Linux. ... > whether there is a more official or reliable way to make a NASM ... Windows automatically including the "current directory" in the ... directory" is NOT part of that PATH as it is with DOS... ...
      (alt.lang.asm)
    • Re: Why do so many people love Teas Instruments?
      ... that almost every modern programming language ... What you described is some "improvements" to the algebra, ... different calculators will produce different results depending on how ... She lived with Linux for a few weeks, ...
      (comp.sys.hp48)
    • Re: Upgrade all Linux Certification exams to test knowledge of PROGRAMMING!!
      ... pdf file for the previous Linux+ networking ... networking interface for Linux certified people ... Three computer programming classes plus ... programming requirement to get a LINUX+ certification a new ...
      (comp.os.linux.networking)