Is this allowed?
procedure1 PROC
.
.
.
procedure1 ENDP
main PROC
.
.
.
INVOKE ExitProcess, 0
main ENDP
END main
That is, having procedures before 'main'? Thanks.
Yes. And a side benefit is you don't have to have a worthless proto to call the earlier procedures.
And it doesn't even need to be a proc if there's no specific reason for it.
.code
... whatever code you want here
main:
...whatever other code you want here
INVOKE ExitProcess, 0
end main
Thanks. I had the procedure named 'Test'. I changed the name and it worked.
Quote from: Jimg on December 03, 2008, 02:06:08 AM
Yes. And a side benefit is you don't have to have a worthless proto to call the earlier procedures.
And it doesn't even have to be
code if there's no specific reason for it :wink
.code
AppName db "Masm32:", 0
...
However, with the no proto technique the order matters for everything: Any procedure can only be called if it is above the calling code.
include \masm32\include\masm32rt.inc
MyTest3 PROTO: DWORD, :DWORD
.code
AppName db "Masm32:", 0
MyTest2 proc argA, argB
invoke MessageBox, 0, argA, argB, MB_YESNO
ret
MyTest2 endp
MyTest1 proc argA, argB
invoke MyTest2, argA, argB ; defined above, no PROTO needed
invoke MyTest3, argA, argB ; PROTO needed
ret
MyTest1 endp
MyTest3 proc argA, argB
invoke MessageBox, 0, argA, argB, MB_YESNO or MB_DEFBUTTON2
ret
MyTest3 endp
start: invoke MyTest1, chr$("Hello World"), addr AppName
exit
end start
QuoteHowever, with the no proto technique the order matters for everything: Any procedure can only be called if it is above the calling code.
More precisely, you can CALL a procedure that is defined below the CALL statement, but without a preceding PROTO you cannot INVOKE a procedure that is defined below the INVOKE statement.