News:

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

VS .NET 2K3 bug?

Started by x86asm, March 26, 2006, 06:25:33 AM

Previous topic - Next topic

x86asm

Hi guys, I was working on my emulator. I am now working on Sega Genesis support.

Also, it's been quite a while since I have visited this site! Been playing with FPGA's and VHDL and ya long story.

Anyway, I loaded a game and was running the game only to find out that it CRASHED (M68K stopped processing and was thrown into an infinite loop, the developers have all error vectors pointing to the same location). Now before you slam me and say it is an error in my 68K emulator, I would like to inform you that the game DOES NOT crash when NOT being debugged by MSVC.

So using some of the features I built into the 68K emulator, I isolated the bug to a small function within the game code:

               move.l  (a3),(a4)
               move.l  $70(a3),(a4)
               move.l  $E0(a3),(a4)
               move.l  $150(a3),(a4)


My 68K emulator executes these opcodes correctly, but the first one (with $70 in it) corrupts the 68K's PC. So I went and observed the assembly code that performs these instructions and have it as listed:

00741524 8D 6E 20           lea         ebp,[esi+20h]
00741527 8B 5C 95 00      mov         ebx,dword ptr [ebp+edx*4]
0074152B 03 D8               add         ebx,eax
0074152D 89 4E 48          mov         dword ptr [esi+48h],ecx


I think I should take the time to note now, that my 68K emulator was assembled my MASM 6.14 I believe as a LIB and was linked into my VC++ project.

I stepped through and noticed that the ADD EBX,EAX does something weird. IT DESTROYS ECX!!! I am using that register to keep track of the 68K's current PC.

Register State Before ADD EBX,EAX:

EAX = 00000070 EBX = 00FF81C0 ECX = 0003367E EDX = 00000003
ESI = 00928CA8 EDI = 09F60040 EIP = 0074152B ESP = 0012FC10
EBP = 00928CC8 EFL = 00200206



Register State AFTER ADD EBX,EAX:

EAX = 00000070 EBX = 00FF81C0 ECX = 0016328E EDX = 00000003
ESI = 00928CA8 EDI = 09F60040 EIP = 0074152D ESP = 0012FC10
EBP = 00928CC8 EFL = 00200206


As you can see, EBX remains unmodified (incorrect) and ECX has been replaced with garbage.  :dazzled:

Now, I am posting here to see if there is something I may be overlooking?! No I am not running multithreaded code (but DirectSound does seem to create threads on initialization).

Sorry if this is in the wrong place mods and hutch, I havent been here for approx a yr and didnt know where to post!!

My basic system specs:

AThlonXP 2500+ @ 2.2Ghz
768MB RAM
Win2K SP4.


I will try and see if it responds in a similar manner on my Thinkpad.
My Thinkpad T23 is running WinXP SP2.

x86asm

Through further analysis, it seems to ADD ESP to EBX instead of EAX to EBX, why?!  :dazzled:
Could it be because I destroyed EBP? I do save it on the stack and restore it when it is needed and dont reference any vars using it.