Hello,
Here is a quick example reading from the stdin stream with the C libray function fgets :
include fgetsPipe.inc
FILE TYPEDEF _iobuf
BUFF_SIZE equ 1024
.data?
stdout dd ?
stdin dd ?
stderr dd ?
buffer db BUFF_SIZE dup(?)
.data
string db 'Read line : %s',0
.code
start:
call __p__iob
mov stdin,eax ; #define stdin (&__iob_func()[0])
mov ecx,SIZEOF(FILE)
add eax,ecx
mov stdout,eax ; #define stdout (&__iob_func()[1])
add eax,ecx
mov stderr,eax ; #define stderr (&__iob_func()[2])
@@:
invoke fgets,ADDR buffer,BUFF_SIZE,stdin
test eax,eax
jz finish
invoke printf,ADDR string,ADDR buffer
jmp @b
finish:
invoke ExitProcess,0
END start
To pipe a simple file to the project executable :
type Build.bat | fgetsPipe.exe
Read line : \PellesC\bin\polib /OUT:msvcrt.lib /MACHINE:x86 /DEF:msvcrt.def
Read line :
Read line : \PellesC\bin\poasm /AIA32 fgetsPipe.asm
Read line : \PellesC\bin\polink /SUBSYSTEM:CONSOLE /LIBPATH:\PellesC\lib\Win fgetsPipe.obj kernel32.lib msvcrt.lib