I've been wrapped around the axle all day trying to figure out why INSTR isn't finding a carriage return in my text file. How do I get the INSTR macro to read the text and find the line breaks?
.data
CRLF db 13,10,0
.data?
hFile DWORD ?
bytesRead DWORD ?
tmpstr BYTE 1825 DUP (?)
.code
println_arr MACRO arr
lea EAX, arr
print EAX
ENDM
start:
mov hFile, fopen("books.txt")
mov bytesRead, fsize(hFile)
mov bytesRead, fread(hFile, addr tmpstr, 1825)
strpos TEXTEQU @InStr( , tmpstr, CRLF)
print "Position of first instance of '"
println_arr CRLF
print "': "
print str$(strpos), 13, 10
fclose hFile
exit
end start
It looks like the TEXTEQU
directive evalutes its argument at assembly time rather than at runtime. You may have to find a different method to search for a string at runtime.
Also, I'd just like to say that code looks nothing like what I'd expect assembly code to look like. Maybe I'm just old.