News:

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

HEXDUMP.ASM

Started by herge, December 07, 2005, 03:45:19 PM

Previous topic - Next topic

herge

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?


// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

PBrennick

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

The GeneSys Project is available from:
The Repository or My crappy website

roticv

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.

herge

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.
// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy

GregL

#4
herge,


  • \masm32\vkdebug\dbproc\hexdump.asm is not intended to be assembled to an executable, it is intended to be assembled to an obj file and included in debug.lib. You are trying to LINK it into an exe. If somehow you successfully create an exe, it's not going to run correctly.



[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]

zooba

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

hutch--

#6
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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website