calculating arithmetic expressions in assembly x86 -


i have assembly x86 question

include irvine32.inc .data day word 0 month word 0 year word 0  count byte 0  prompt1 byte "enter month: ",0 prompt2 byte "enter day: ",0 prompt3 byte "enter year: ",0 prompt4 byte " day of week ",0 .code main proc  mov edx, offset prompt1 call writestring mov edx, 0 mov eax, offset month mov ecx, 19 call readint call crlf mov eax, 0 mov ecx, 0  mov edx, offset prompt2 call writestring mov edx, 0 mov eax, offset day mov ecx, 19 call readint call crlf mov eax, 0 mov ecx, 0  mov edx, offset prompt3 call writestring mov edx, 0 mov eax, offset year mov ecx, 19 call readint call crlf mov eax, 0 mov ecx, 0  mov ebx, 0 mov ax, 14 sub ax, month mov bx, 12 div bx mov ebx, 0 sub year, ax mov ecx, 0 mov cx, year       exit main endp  end main 

so have 2 arithmetic equation code

a = (14 - month) / 12 y = year - 

this input

enter month: 4  enter day: 15  enter year: 2013 

i'm expecting value of y after last instruction 7dd(2013)

but got value of register ecx 0000ffff, why isn't value of y 7dd, ffff

can help? thank in advance

the answer after, 10decimal appear in edx , eax 0

mov ebx, 0

mov ax, 14

sub ax, month

mov bx, 12

div bx

10/12 = 0 in eax , 10 remainder in edx


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -