The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: herge on December 07, 2005, 03:45:19 PM

Title: HEXDUMP.ASM
Post by: herge on December 07, 2005, 03:45:19 PM
HI All:

I Have installed MASM32 Beta V9.
It compiled HEXDUMP.ASM okay.
But it crashs on execution!

Microsoft Visual C++
Unhandled exception in HEXDUMP.exe: 0xC0000005: Access Violation

0040122C   mov         al,byte ptr [esi]

Any suggestions?


Title: Re: HEXDUMP.ASM
Post by: PBrennick on December 07, 2005, 04:51:41 PM
herge,
There are three (3) entirely different versions of hexdump.asm in the package.  Could you be more specific?  Doing some exploring, myself, I suspect you should change:

mov         al,byte ptr [esi]


to


mov         al, [esi]


Because one of my versions has a line like that, but I am just guessing... usually a bad thing to do.  Please do not flame me.
Paul

Title: Re: HEXDUMP.ASM
Post by: roticv on December 07, 2005, 05:19:22 PM
I dont think that's the offending line. I suppose the problem was that esi was pointing to an address out the data allocated for the program. This is probably a bug in the code.

Therefore congrats for finding a bug.
Title: Re: HEXDUMP.ASM
Post by: herge on December 07, 2005, 05:52:36 PM
hi:
I didn't realize they were three
versions of HEXDUMP.ASM.

G:\masm32\vkdebug\dbproc\hexdump.asm

hexdump.obj : error LNK2001: unresolved external symbol _DebugPrint@4
LINK : error LNK2001: unresolved external symbol  _mainCRTStartup
hexdump.exe : fatal error LNK2001: 2 unresolved externals
_
Link Error
Press any key to continue . . .

g:\masm32\examples\exampl08\hexdump\hexdump.asm
This one actual runs!

g:\masm32\m32lib\hexdump.asm
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
hexdump.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
Press any key to continue . . .

I've seen the _mainCRTStartup error message before.
Title: Re: HEXDUMP.ASM
Post by: GregL on December 07, 2005, 06:53:18 PM
herge,




[li]\masm32\examples\exampl08\hexdump\hexdump.asm is intended to be assembled to an executable. Therefore it works.[/li]



[li]\masm32\m32lib\hexdump.asm is not intended to be assembled to an executable, it is intended to be assembled to an obj file and included in masm32.lib. Again, you are trying to LINK it into an exe. It's not going to work.[/li]



[/list]
Title: Re: HEXDUMP.ASM
Post by: zooba on December 07, 2005, 08:23:10 PM
Quote from: roticv on December 07, 2005, 05:19:22 PM
the problem was that esi was pointing to an address out the data allocated for the program

That's it precisely. Without seeing more of the code I can't give you an exact fix, but I'd suggest some parameter checking may be in order. Find out what value of ESI crashes it and test for it  :thumbu

BTW, 'mov al, [esi]' and 'mov al, BYTE PTR [esi]' are identical. The assembler knows that 'al' is only a byte and it automatically fills in the 'BYTE PTR' part. :U
Title: Re: HEXDUMP.ASM
Post by: hutch-- on December 08, 2005, 01:11:43 AM
The example code version in exampl08  is a working EXE file and it builds correctly and workes correctly. Greg is right that the algo in the m32lib directory is a library module, not an application. Same with the algo in the VKDEBUG directory.

To complicate things a little more, there are a matching pair of reasonably fast algos in the masm32 library, "bin2hex" and "hex2bin" that handle hex conversions in both directions. When I did them about a year or so ago they were running at about 400 meg/sec on my current PIV.

Just one favour, if you find any problems in the version 9.00 BETA, would you report them in the topic in the MASM32 sub directory as it makes it easier for me to keep track of them.

Just as a postscript comment, the report did not specify which files was being built and with comments of the type,

Quote
the problem was that esi was pointing to an address out the data allocated for the program

That's it precisely. Without seeing more of the code I can't give you an exact fix,

The posted BETA has all of its code present and guesswork on the basis of unseen code is about as useful as a hip pocket in a singlet.

When you get an error report with this content,

LINK : error LNK2001: unresolved external symbol _mainCRTStartup
hexdump.exe : fatal error LNK1120: 1 unresolved externals

It is about as obvious as titz on a bull that there is no startup code present and that the file is a module, not an application. This is fine for a member who is learning assembler and that is why we are here to help but I can reasonably expect more sense from people who should know better.
Title: Re: HEXDUMP.ASM
Post by: PBrennick on December 08, 2005, 02:39:48 AM
Hi Hutch,
I guess I can color you frustrated.  I don't blame you for getting disjointed and I must say, I have always liked the 'hip pocket in a singlet' comment.  When you think about it, it is probably a good thing it was not posted in the topic in the MASM32 sub directory.

Paul