Date: Thu, 12 Nov 2009 10:38:07 -0500 From: David Jackson <djackson452@gmail.com> To: Charlie Kester <corky1951@comcast.net>, freebsd-questions@freebsd.org Subject: Re: Problems with FreeBSD assembly Message-ID: <4AFC2BDF.7060405@gmail.com> In-Reply-To: <20091112014515.GB21567@comcast.net> References: <4AFB13D9.9050507@gmail.com> <20091112013240.GA21567@comcast.net> <20091112014515.GB21567@comcast.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Charlie Kester wrote: > On Wed 11 Nov 2009 at 17:32:41 PST Charlie Kester wrote: > > One more thing: > >> Notice that the system call number (or any other dword) should also be >> pushed onto the stack before the int 80h. > > The reason for this is given at the top of the page: > > although the kernel is accessed using int 80h, it is assumed the > program will call a function that issues int 80h, rather than issuing > int 80h directly. > > So the extra dword pushed onto the stack takes the place of the return > address from the function the kernel expects to have been called. > And since you're not actually using as a return address, it doesn't > matter what value it actually has. The kernel doesn't use it for > anything; it just expects it to be there in a properly arranged stack > frame. > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" The push eax is what made it work. So that was the problem. Stdin and stdout do not need to opened before they are used, as in C. Thank you everyone for your help on this, that solved it. Here is the code that works: section .data hello db 'Hello, World!', 0xa hbytes equ $ - hello section .text global _start _start: push dword hbytes push dword hello push dword 1 mov eax,0x4 push eax int 0x80 add esp,16 push dword 0 mov eax,0x1 push eax int 0x80
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AFC2BDF.7060405>