Assembly Language 80x86 Debug Help?

nothingasis

In Runtime
Messages
198
Location
CA
Hey, can't figure out what's wrong with this file.
The div instruction displays the wrong result.
I'm using Visual Studios to compile this, the template file can be provided if needed.

Objective is to display the the result of a div instruction where the dividend is stored in register EAX. The problem I'm having is that the displayed result stored in EAX comes out wrong.



I have my .asm file in the link below I'd appreciate it if anyone could help me out.

Also we were supposed to display it onto a single window on two lines.



Code:
pastebin.com/1Lsu6brs



Comments:(Already in the pastebin file but I'll post here as well)
Code:
Objective:      Prompt and allocate DWORD(32 bits) size labels for Grade1-Grade4 and Weight1-Weight4.
                        Solve for WeightedSum = G1*W1 + G2*W2 + G3*W3 + G4*W4
                        Solve for SumOfWeights = W1 + W2 + W3 + W4
                        Solve for WeightedAverage = (WeightedSum/SumOfWeights)
                        Display WeightedAverage & WeightedSum

Code:
Grades:         Weights:
88              1
77              2
94              1
85              3
SumOfWeight = 7
WeightedSum = 591
WeightedAvg = 81        ;Displays 1792


And as always please and thank you!
 
If everything except your WeightedAvg is being calculated correctly (I'm assuming this is the case, since you only said the weightedAvg isn't displaying correctly), then I'd look into if you're storing your values correctly in WeightedSum and SumOfWeights. Then make sure you're doing the division operation correctly.

It's been about 3.5 years since I've done anything with Assembly... wish I could be of more help.
 
I appreciate your advice nonetheless. Ive been running break points at the key points right before my final calculations and display and the div takes the value in EAX as the dividend of the operation but for some reason it just comes out wrong.

I'll keep running breakpoints and check out the div instruction and do as you suggested.
Thanks!
 
Have you tried maybe clearing out the div registers before using them?

You're positive you're using the correct registers for operations / getting the values?
 
Did that exactly, before every mov instruction I cleared out the register with 0h. After it was occupied I walked through to check the values are correct and all checks out. I'll have to go to my professor tomorrow and have him walk me through my mistakes. Thank you though!
 
Hmm, yeah I'm not quite sure what to say then. Other than making sure your atod and dtoa functions you're calling are working correctly.

Like I said, been a long time since I've done anything in assembly, so I just can't remember all the registers and such lol. Wish I was of more help, sorry!
 
How considerate, much much appreciated carnageX. :)
And yeah Assembly language is a B*TCH to troubleshoot.. especially when the CORRECT information is vital from the first line of the main. >.<

Anyhow, thanks again for the tips!
 
Lol yup... exactly. I never liked using the debugger for assembly. Was always a pain to add watches and such. Of course, I did it in a DOS environment under a WinME VM lol.
 
Back
Top Bottom