Re: Why doesn't this NASM program work? It loops endlessly
From: Frank Kotler (spamtrap_at_crayne.org)
Date: 03/27/05
- Previous message: cfk: "BIOS Assembly"
- In reply to: Francesca : "Re: Why doesn't this NASM program work? It loops endlessly"
- Next in thread: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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:
....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
- Previous message: cfk: "BIOS Assembly"
- In reply to: Francesca : "Re: Why doesn't this NASM program work? It loops endlessly"
- Next in thread: Benjamin David Lunt: "Re: Why doesn't this NASM program work? It loops endlessly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|