I'm trying to call the function fgets to read from standard input. How do I get the FILE* stdin in assembly?
I'm using nasm on cygwin.
Thanks in advance.
So, I have been doing some digging, and figured out how to use the system calls _write and _read, that use file descriptors instead of a FILE*.
I found some references to a function called fileptr that returns a FILE* corresponding to a file descriptor, but that doesn't seem to be part of the C standard library.
Anyway, here is my test code. It builds and runs correctly under Cygwin.
; test_io.asm ; Test _read and _write system calls ; ; nasm -o test_io.o -fwin32 test_io.asm ; gcc -o test_io test_io.o section .data prompt db 'Enter a string: ',0 prompt_len equ $ - prompt BUFSZ equ 1024 STDIN equ 0 STDOUT equ 1 section .bss buffer resb BUFSZ section .text global _main extern _read, _write _main: push prompt_len push prompt push STDOUT call _write add esp, 12 push BUFSZ - 1 ; leave space for terminating 0 push buffer push STDIN call _read add esp, 12 push eax ; _read returns string length in eax push buffer push STDOUT call _write add esp, 12 mov eax, 0 ret
That would seem to be the way to go.
FILE*'s are constructed by the C runtime library, which may necessitate you dragging in a whole lot of stuff you didn't want. If you did want it, there would seem to be little point in writing this bit in ASM.
i am trying to create a library management system which is supposed to be used to store/keep infp for the library and the library members( book title, author, name and picture for borrower and other stuffs). The app has 6 buttons, delete, save, add,previsous,next, and upload( for upload ...
Im trying to bind my custom vertical scrollbar to datagridview is this possible.. Please help Thnak you..
I have two tables, I will call them first-half and second-half (of the year)
Table: first id jan feb mar apr ----------------------- 2 80 90 70 60 3 50 40 60 30 Table: second id jan feb mar apr ----------------------- 2 50 70 60 90 3 80 60 50 ...