Dman95 / SASM

SASM - simple crossplatform IDE for NASM, MASM, GAS and FASM assembly languages
http://dman95.github.io/SASM/
Other
5.81k stars 193 forks source link

Add io.inc includes similar to the nasm's one for other compilers #37

Open insolor opened 9 years ago

insolor commented 9 years ago

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).

Dman95 commented 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.

insolor commented 9 years ago

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.

insolor commented 9 years ago

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.

insolor commented 9 years ago

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
Dman95 commented 9 years ago

It is not a bug, it is a feature. To perform input in a program you should enter a text before running a program.

ThomasThelen commented 8 years ago

There are many libraries that have already been made for other assemblers. Look up FreshLib for a fasm macro library.

insolor commented 8 years ago

@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.