I am reading "The Assembly Programming Master Book", and example 2.2 Assembles, links, and crashes. :(
This is the asm file --> http://www.geocities.com/little5washu777/Masm32/Example_2.2.Asm
Well... just had a little look at that - I'll attempt to debug it, but, do yourself a favor and take a look at Iczelions tutorials - the format that your code is written in is a bit erm... over the top... you can make use of many of the features of MASM32 that are not being used in your code (e.g. _TEXT SEGMENT etc is prdefined as .code and all of the windows structres are predefined in the windows.inc file that comes with MASM32)
Iczelions tutorials come with MASM32, but you can get them on the web here: http://win32assembly.online.fr/tutorials.html
Ossa
Over the top seems common in Programming books!
OK,
first mistake (this does not fix it, but is a very major bug - stops the crash, but now crashes somewhere else): line 96, you have
MOV [WC.CLSCEXTRA], OFFSET WNDPROC
it should be
MOV [WC.CLWNDPROC], OFFSET WNDPROC
This means that windows has junk for the pointer to WNDPROC... so it jumps to a random address.
Ossa
OK, got it going now... second mistake is on line 185, you have
JMP WMDESTROY
it should be
JMP DEFWNDPROC
You always destroy the window otherwise... even before it is created.
Hope that helps... and you might want to treat yourself to some whitespace every now and then... solid lines of code are hard to read.
Ossa
You are right, I typed that line in wrong.
I am checking to see if I made any other mistakes like that.
MoonBeam777,
I have that book too. Ossa is right, the author's style is a bit odd. His goal is writing code that will assemble with both MASM and TASM. In my opinion it really limits what you can do. I say pick an assembler and use all the available features it provides. The book was worth reading though.
Thought I'd just show the difference between the code you posted and something using the full MASM32 bag of tricks...
http://web.mit.edu/rcassels/www/example.asm
I added some comments to describe some of the differences (and really pointless things done in the example - like the .386P thing, why not use .386 ?).
Ossa
Thanks for the help, the whole thing was me typeing those lines in incorrectly.
Quote from: MoonBeam777 on May 26, 2006, 10:40:25 PM
Thanks for the help, the whole thing was me typeing those lines in incorrectly.
No problem
Ossa