I'm working on a big project for my college class.
I put a string/array in the .data section like this:
stringread BYTE DUP(STRSIZE)
And in main I have:
push OFFSET stringread
push esi
call ReadFileLine
pop esi
pop OFFSET stringread
But I get this error:
undefined symbol: stringread
I think my problem is that I didn’t declare the string correctly.
At first I thought maybe I wasn’t allowed to push strings directly onto the stack like that, but I looked at my professor's example code and he had something similar:
array DWORD 1,2,3,4,5
push OFFSET array
EDIT: I replaced the declaration with this, which seems to have fixed it:
stringread BYTE STRSIZE DUP(?)
For MASM this line is syntactically wrong. As a consequence what would normally be considered a label, didn't get recognized that way and so the symbol stringread was reported 'undefined' once you used it on the line
push OFFSET stringreadin main.The
DUPoperator needs to be told how many duplications you need. Looking atDUP(STRSIZE)it would seem that you erroneously have placed the repeat count between the parenthesis. One solution could be:OFFSET stringreadis a so-called 'immediate' aka just a number. While you canpushan immediate, you can notpopan immediate!You can remove the pushed value either through
add esp, 4pop edx