Re: newbie: I/O with nasm
- From: "James Daughtry" <mordock32@xxxxxxxxxxx>
- Date: 7 Mar 2006 07:50:39 -0800
how can I do simple I/O with nasm? For example: I want to read a string
from the commandline. Please keep it simple;-).
Okay, keeping it simple, the easiest way in my opinion is to get
something like the C library to do the work for you. How you do it
depends on your compiler, but with GCC, you can do something like this:
[section .data]
prompt: db 'Name: ',0
result: db 'Hello, %s!',0
[section .bss]
name: resb 1024
[section .text]
global _main
extern _printf, _gets
_main:
push prompt
call _printf
add esp,4
push name
call _gets
add esp,4
push name
push result
call _printf
add esp,8
mov eax,0
ret
Then you tell NASM to give you a suitable object file and have gcc link
with it:
C:\>nasmw -f win32 myprog.asm -o myprog.obj
C:\>gcc myprog.obj -o myprog.exe
.
- Follow-Ups:
- Re: newbie: I/O with nasm
- From: Frank Kotler
- Re: newbie: I/O with nasm
- From: santosh
- Re: newbie: I/O with nasm
- References:
- newbie: I/O with nasm
- From: TK
- newbie: I/O with nasm
- Prev by Date: application that retrieve the number of cpu cycles, junk 'cycle' after expression
- Next by Date: Re: application that retrieve the number of cpu cycles, junk 'cycle' after expression
- Previous by thread: newbie: I/O with nasm
- Next by thread: Re: newbie: I/O with nasm
- Index(es):