Open insolor opened 9 years ago
You can find a description of the library on the site http://dman95.github.io/SASM/english.html In brief, macros determine a type of the arguments and call an according code, in which C library functions are used.
I've already seen the docs from the link you given. I need something else: at least I need info on how to make basic IO functions work. Eg. I've written the following code:
format ELF
extrn _printf
section '.text' executable
public _main
_main:
push message
call _printf
xor eax, eax
ret
message db 'Hello!', 0
It is compiled successfully with fasm from sasm, but when I try to run it, it prints nothing.
I've finally found helloworld for fasm in the directory of sasm, it works fine, so I will try to use it as a reference.
printf, puts are working, but I failed to make work scanf - it just passes through it without waiting of input. P.S. It actually works, but it doesn't wait for input (as I expected), and just reads from the input window. Here's an example of working code:
format ELF
section '.data' writeable
num dd 0
format_str db "%d", 0
section '.text' executable
public _main
extrn _printf
extrn _scanf
_main:
mov ebp, esp; for correct debugging
push num
push format_str
call _scanf
add esp, 8
push [num]
push format_str
call _printf
add esp, 8
xor eax, eax
ret
It is not a bug, it is a feature. To perform input in a program you should enter a text before running a program.
There are many libraries that have already been made for other assemblers. Look up FreshLib for a fasm macro library.
@ThomasThelen, the request was not about libraries for fasm in general. It was limited to rewriting existing io.inc file, which works with nasm, to the syntax of fasm. Personally I don't need such include file for using in my projects, but I think it would be useful for some people for educational purposes.
I think I can implement io.inc for fasm if you describe in brief how io.inc for nasm works (I don't understand nasm's macros syntax).