Subject: Re: NetBSD assembly
To: None <netbsd-help@netbsd.org>
From: Chris Huang <chris@integer.ca>
List: netbsd-help
Date: 03/26/2003 16:16:36
Thanks to those who help....
I was following the wrong convention on the previous post.
Now I am following the C calling convention,
and I got a new question... =)
This is what I have now ,
----------------------------------------------------------------------------
-
.data
msg: .string "Hello\n"
len = . - msg - 1
.text
.extern exit
.global main
do_sys:
int $0x80
ret
main:
pushl $len
pushl $msg
pushl $1
movl $0x4, %eax
call do_sys
addl $12, %esp
pushl $0
call exit
----------------------------------------------------------------------------
-
My newbie question is that "why" the call/ret combination (call do_sys) can
be eliminated by pushing an extra dword ?
----------------------------------------------------------------------------
-
.data
msg: .string "Hello\n"
len = . - msg - 1
.text
.extern write
.extern exit
.global main
main:
pushl $len
pushl $msg
pushl $1
movl $0x4, %eax
pushl %eax # Or any other word
int $0x80
addl $16, %esp
pushl $0
call exit
Thanks all for the patient and suggestions