I'm trying to figure out what feof would be in ASM
So I can pick this apart

for(x=0;cl && (!feof(stdin));x++)

The end of the Buffer?

And I guess stdin is the address of the beginning of the buffer

Will
invoke GetStdHandle, STD_INPUT_HANDLE
mov hStdIn, eax

put stdin in , hStdIn ?




Thanks Andy981!
Posted on 2002-01-21 12:52:21 by andy981
Can you post the rest of the snippet? A quick search in the Win32 API:
fEof

Specifies whether the end-of-file (EOF) character has been received. If this member is TRUE, the EOF character has been received.


That was found in the COMSTAT structure.
Posted on 2002-01-21 15:49:27 by eet_1024
The EOF is found by reading the next character, and comparing it with '10 h', which is the EOF code.

As for the StdIn stuff, i dunno, never used that api, look it up on the MSDN Search...

NaN
Posted on 2002-01-21 15:53:03 by NaN
Wrong, NaN. feof() determines if the end of the file is reached by
seeing if the file pointer is, well, at the end of file file :). It *might*
return eof if it has read an EOF char (which is 01Ah or 01Bh, not 10h),
but I don't think so.

andy, the C buffered file I/O (fopen, fread, fwrite, fseek, ftell, fclose,
feof et cetera)
have no direct counterparts in asm. (Might be some m32lib, but I
dunno... check the m32lib help file).

stdin is more than a buffer. You can think of it as a file object. Internally
it is (usually) composed of a file handle, buffer, buffer size, current
position in buffer.

You can generally just use the win32 native File* functions. But even
though windows does caching itself, if you do very small reads (like
a few bytes at a time), implementing a buffered scheme on top
should give a performance increase.
Posted on 2002-01-21 16:16:18 by f0dder
Here is the listing of

It has to do with __iob

for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries.val = fmakeword(stdin,'&',&cl);
plustospace(entries.val);
unescape_url(entries.val);
entries.name = makeword(entries.val,'=');
}



; 77 : for(x=0;cl && (!feof(stdin));x++) {

mov DWORD PTR _x$, 0
jmp SHORT $L1272
$L1273:
mov eax, DWORD PTR _x$
add eax, 1
mov DWORD PTR _x$, eax
$L1272:
cmp DWORD PTR _cl$, 0
je $L1274
mov ecx, DWORD PTR __iob+12
and ecx, 16 ; 00000010H
test ecx, ecx
jne $L1274

; 78 : m=x;

mov edx, DWORD PTR _x$
mov DWORD PTR _m$, edx

; 79 : entries.val = fmakeword(stdin,'&',&cl);

lea eax, DWORD PTR _cl$
push eax
push 38 ; 00000026H
push OFFSET FLAT:__iob
call ?fmakeword@@YAPADPAU_iobuf@@DPAH@Z ; fmakeword
add esp, 12 ; 0000000cH
mov ecx, DWORD PTR _x$
mov DWORD PTR _entries$, eax

; 80 : plustospace(entries.val);

mov edx, DWORD PTR _x$
mov eax, DWORD PTR _entries$
push eax
call ?plustospace@@YAXPAD@Z ; plustospace
add esp, 4

; 81 : unescape_url(entries.val);

mov ecx, DWORD PTR _x$
mov edx, DWORD PTR _entries$
push edx
call ?unescape_url@@YAXPAD@Z ; unescape_url
add esp, 4

; 82 : entries.name = makeword(entries.val,'=');

push 61 ; 0000003dH
mov eax, DWORD PTR _x$
mov ecx, DWORD PTR _entries$
push ecx
call ?makeword@@YAPADPADD@Z ; makeword
add esp, 8
mov edx, DWORD PTR _x$
mov DWORD PTR _entries$, eax

; 83 : }

jmp $L1273
$L1274:
Posted on 2002-01-21 16:58:03 by andy981
When fread() returns 0 as the number of bytes read, or getc()/fgetc() returns int(-1) as the actual byte "read", the input routines have gotten an error or else an eof has been detected.

One status bit in the iob structure is set if it was eof (checked with feof), and another status bit is set if it was an error (checked with ferror).

In text mode, the old DOS eof character (ctrl-Z, 01Ah) may be interpreted as EOF.

C's stdio functions hide a lot of code. The prinf/scanf functions have a lot of conversion code behind them. And the putc/getc functions hide buffering and error detection.

If you're comfortable with C, there exist free compilers with source code to the standard function libraries. Take a look at them to see how much work is handled by the I/O routines.
Posted on 2002-01-21 19:18:59 by tank
Thanx for the correction.... I looked up a source of mine that works (but used with memory mapped files) and i have its EOF code equated to 10h. I should give it a look over. Kinda odd that it never gave me a hard time before...

Anywho, im sure two to one has to mean something :)
Thanx..
:alright:
NaN
Posted on 2002-01-22 02:07:32 by NaN