I've managed 'Hello World' with Gnu as!
So, next thing is print 1 to 10 right? (Maybe in ruby)
At the moment, I'll be happy to print A closely followed by B. Here's what I have.
.section .text
.globl _start
_start:
# Print A
movl $4,%eax
pushl $0x41
movl %esp,%ecx # Would rather movl $0x41,%ecx
movl $1,%ebx
movl $1,%edx
int $0x80
# Closely followed by B
movl $4,%eax
incl (%esp) # Rather incl(%ecx) here
movl %esp,%ecx
movl $1,%ebx
movl $1,%edx
int $0x80
movl $1,%eax
movl $0,%ebx
int $0x80
And it actually works, but my question is, why can't I
movl $0x41,%ecx
To begin with, and then
incl (%ecx)
a little later on?
For a sys_write, %ecx wants to point to where the character or characters reside in memory, not "be" the character to print. "incb" might be more correct than "incl" since you're only incrementing one byte - either "(%esp)" or "(%ecx)" ought to work, since they point to the same place at this point. Note that you're incrementing "contents" of memory, not the pointer to memory.
Best, Frank