Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
insolor opened this issue Sep 17, 2015 · 7 comments
Open

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

insolor opened this issue Sep 17, 2015 · 7 comments

Comments

@insolor
Copy link

insolor commented Sep 17, 2015

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
Copy link
Owner

Dman95 commented Sep 18, 2015

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
Copy link
Author

insolor commented Sep 18, 2015

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
Copy link
Author

insolor commented Sep 18, 2015

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
Copy link
Author

insolor commented Sep 18, 2015

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
Copy link
Owner

Dman95 commented Sep 20, 2015

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
Copy link
Contributor

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

@insolor
Copy link
Author

insolor commented Mar 17, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants