Windows Assembly programming
I am experimenting a little with assembly programming
for Windows using the GoAsm Assembler with varying
results, here are two small programs I wrote that are
giving me trouble:
This program should display a message box but
instead it just freezes and I have to force it to shut down:
Code:
CODE SECTION
Start:
PUSH 0 ; hWnd
PUSH 6,'Hello.' ; lpText
PUSH 15,'This is a test.' ; lpCaption
PUSH 0 ; uType
CALL MessageBoxA
POP eax ; Buttons
MOV eax,0
RET
Passing strings to Windows API functions seems to
be giving me the most trouble. Based on examples I could
find, "PUSH 15,"This is a test.'" seems to be how you pass
a string by value. The number 15 should be the length of the
string. The question is: how do I make this program show a message box?
This program does what should do, beep, wait a while
and then beep once more and then quit. The only
problem is that after it is done it quits with an "illegal operation"
error. The question here is: how do I make this program
quit properly?
Code:
CODE SECTION
START:
PUSH 1000 ; Duration.
PUSH 1000 ; Frequency.
CALL Beep
POP eax ; Non zero if error occurred.
PUSH 1500 ; Duration.
CALL Sleep
PUSH 1000 ; Duration.
PUSH 1000 ; Frequency.
CALL Beep
POP eax ; Non zero if error occurred.
MOV eax,0
RET