osdir.com
mailing list archive

Subject: RE: Very newbie question... - msg#00015

List: linux.assembly

Date: Prev Next Index Thread: Prev Next Index
> i have some problems with my first linux/nasm asm program.
> This is a simple "hello world" program but i can't see the "hello
> world" on my screen and i don't find my error.

As noted, you are confusing the function call method with the system
call method, and doing a little of both. You need to decide on one or
the other.

If you want to make direct kernel system calls, then follow the code
that was posted earlier. Alternately, if you wanted to use the POSIX
functions, your code would look something like this:

EXTERN write, _exit

; ...

push len
push hello
push 1
call write
add esp, 12
push 0
call _exit

b
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html



Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Very newbie question...

Hi, in amd64, registers are different (64bits...) ;) So, I think you'd better use the 64 bits name version push rbp mov rbp,rsp ... What do you have as result in your case? can you try it with gdb and step your prog? Fred Le Samedi 12 Novembre 2005 00:05, Lorenzo a écrit : > Hi, > > i have some problems with my first linux/nasm asm program. > This is a simple "hello world" program but i can't see the "hello world" > on my screen and i don't find my error. > I work on 64bit amd system. > Someone can illuminate me? :) > > > Thx > > ----------------------------------- > > section .text > global _start > > msg db 'hello, world!',0xa > len equ $ - msg > > _start: > push ebp > mov ebp,esp > > push len > push msg > push 1 > mov ebx,esp > mov eax,4 > int 0x80 > > add esp,12 > > mov ebx,0 > mov eax,1 > int 0x80 > - > To unsubscribe from this list: send the line "unsubscribe linux-assembly" > in the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Frederic Marmond - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html

Next Message by Date: click to view message preview

Re: About a-linux (asmutils mini-distribution)

Hi,all! Is there a book that introdnuces Linux assembly using AT&T grammar? Thanks! - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html

Previous Message by Thread: click to view message preview

RE: Very newbie question...

I am still newbie myself, but one thing that I noticed is that you pass some parameters via registers and others via the stack pointer. The write sys call takes 3 param (as you prob already know), the file descriptor (1 = stdout), the pointer to the buffer, and its size. The write sys call itself is syscall 4. According to http://asm.sourceforge.net/articles/linasm.html "For all syscalls, the syscall number goes in %eax. For syscalls that have less than six args, the args go in %ebx,%ecx,%edx,%esi,%edi in order. The return value of the syscall is stored in %eax." Here is my own example that I wrote about a year ago. section .data hello db 'Hello, World!', 0Ah len equ $-hello section .text global _start _start: mov edx, len mov ecx, hello mov ebx, 1 mov eax, 4 int 80h mov ebx, 0 mov eax, 1 int 80h -----Original Message----- From: linux-assembly-owner@xxxxxxxxxxxxxxx [mailto:linux-assembly-owner@xxxxxxxxxxxxxxx] On Behalf Of Lorenzo Sent: Friday, November 11, 2005 6:05 PM To: linux-assembly@xxxxxxxxxxxxxxx Subject: Very newbie question... Hi, i have some problems with my first linux/nasm asm program. This is a simple "hello world" program but i can't see the "hello world" on my screen and i don't find my error. I work on 64bit amd system. Someone can illuminate me? :) Thx ----------------------------------- section .text global _start msg db 'hello, world!',0xa len equ $ - msg _start: push ebp mov ebp,esp push len push msg push 1 mov ebx,esp mov eax,4 int 0x80 add esp,12 mov ebx,0 mov eax,1 int 0x80 - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html

Next Message by Thread: click to view message preview

Re: Very newbie question...

Ah ok... now i understand some more things :) Thx :) Brian Raiter wrote: As noted, you are confusing the function call method with the system call method, and doing a little of both. You need to decide on one or the other. If you want to make direct kernel system calls, then follow the code that was posted earlier. Alternately, if you wanted to use the POSIX functions, your code would look something like this: EXTERN write, _exit ; ... push len push hello push 1 call write add esp, 12 push 0 call _exit b - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by