For my first question, let's assume we have the following line of code under .data:
"theSINTArray BYTE 256 dup(?)".
I know that this code creates an array in which each element must be a BYTE, but what are the 256 and dup(?) there for?
I know that the code below pushes the type, length and offset/address of theSINTArray onto the stack, but what I would like to know is if it is possible to retrieve them from the stack and utilize them within a subroutine.
main PROC
push TYPE theSINTArray
push LENGTHOF theSINTArray
push OFFSET theSINTArray
call testParameters
exit
main ENDP
This is a bit of a tedious question, so I apologize in advance, but I simply don't understand why a large portion of the lines in the code sample below are necessary. Assuming I have the line "prompt BYTE "Please enter a value: ",0" in the .data section, what is the purpose of each line of the code below? Note: WriteString and ReadString are subroutines defined in Irvine's library, which I am using.
testOutput PROC
push edx
push ecx
mov edx,offset prompt
call WriteString
pop ecx
pop edx
call ReadString
ret
testOutput ENDP
what are the 256 and dup(?) there for?
Read the assembler's manual. TL;DR: reserves 256 uninitialized bytes
if it is possible to retrieve them from the stack and utilize them within a subroutine
Of course it is possible, argument passing would be silly if the callee couldn't access the arguments ;) You address them relative to esp
(the stack pointer), or, after you have set it up as frame pointer, ebp
. Examples: [esp+4]
or [ebp+8]
.
what is the purpose of each line of the code below
testOutput PROC ; begin testOutput procedure
push edx ; save edx on stack
push ecx ; save ecx on stack
mov edx,offset prompt ; load edx with address of prompt
; presumably argument to WriteString
call WriteString ; invoke WriteString procedure
pop ecx ; restore ecx saved above
; in case WriteString modified it
pop edx ; restore edx saved above (we have modified it)
call ReadString ; invoke ReadString procedure
ret ; return from subroutine
testOutput ENDP ; end of procedure