I'am totally new to the masm32 and I'am trying to learn assembler.
I was wondering is there any detailed tutorial for assembler, that will explain everything ot the detail?
And I also tried to compile this code as my first, and it compiles successefully but, when this program it crashes.
include \masm32\include\masm32rt.inc
includelib \masm32\include\kernel32.lib
.486
.code
NAME db "Console"
start:
cls
invoke SetConsoleTitle,"NAME"
inkey
ret
end start
Did you build it as a console app ? Without the console being started as the app starts, you are sending the console command to nowhere.
I think I did, I used 'Console Build All' option after assembling this code.
SetConsoleTitle need a parameter.
the parameter treats as a memory address.
invoke SetConsoleTitle,"NAME"
parameter: "NAME"
address: 4E414D45
if the address invalid access.
this Windows API function just a error!
Change
invoke SetConsoleTitle,"NAME"
to
invoke SetConsoleTitle, chr$("NAME")
and it will work fine.
:U
include \masm32\include\masm32rt.inc
.code
NAMEx equ "Console"
start:cls
invoke SetConsoleTitle,chr$(NAMEx)
inkey
ret
end start
JJ is right but there is a cleaner way of doing it, use the "fn" macro instead of "invoke" and you can just use the quoted text without the "chr$()" macro.
Quote from: hutch-- on May 24, 2009, 01:18:13 PM
JJ is right
I am afraid I wasn't right - I misread his example. Here are all the variants:
include \masm32\include\masm32rt.inc
.code
MyName db "Console", 0
start:
cls
invoke SetConsoleTitle, offset MyName
getkey
invoke SetConsoleTitle, chr$("one more for the road")
getkey
fn SetConsoleTitle, "this one is good enough?"
getkey
.if rv(SetConsoleTitle, "and that one gives an error?")==0
MsgBox 0, "You got an error", "Hi", MB_OK
.endif
inkey "we are done, press a key now"
ret
end start
ok, thanks for the help.