Tuesday, 15 June 2010

assembly - Why does this program crashes everytime? -



assembly - Why does this program crashes everytime? -

title: question 5

include irvine32.inc .data x dword ? y dword ? z dword ? .code main proc phone call readint mov eax, x add together eax, y add together eax, z mov ebx, 3 div ebx phone call dumpregs phone call crlf exit main endp end main

with info you've provided it's hard say.

one cause of crashes you're not clearing edx prior division. if read description div in intel's manual you'll see div r/m32 uses 64-bit register pair edx:eax dividend. if edx happens contain arbitrary value, run chance of getting quotient won't fit in 32 bits, cause exception.

hence, you'll typically want clear edx prior each div. can done mov edx,0 or xor edx,edx.

assembly x86 mean masm irvine32

No comments:

Post a Comment