News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Program Assembles and Links yet crashes

Started by MoonBeam777, May 26, 2006, 08:50:10 PM

Previous topic - Next topic

MoonBeam777

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

Ossa

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
Website (very old): ossa.the-wot.co.uk

MoonBeam777

Over the top seems common in Programming books!

Ossa

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
Website (very old): ossa.the-wot.co.uk

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
Website (very old): ossa.the-wot.co.uk

MoonBeam777

You are right, I typed that line in wrong.

I am checking to see if I made any other mistakes like that.

GregL

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.


Ossa

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
Website (very old): ossa.the-wot.co.uk

MoonBeam777

Thanks for the help, the whole thing was me typeing those lines in incorrectly.

Ossa

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
Website (very old): ossa.the-wot.co.uk