我有一个关于汇编 x86 架构的问题。
INCLUDE Irvine32.inc
.data
day BYTE 0
month BYTE 0
year BYTE 0
a BYTE 0
y BYTE 0
m BYTE 0
count BYTE 0
prompt1 BYTE "enter month: ",0
prompt2 BYTE "enter day: ",0
prompt3 BYTE "enter an year: ",0
prompt4 BYTE " the day of the week is ",0
.code
main PROC
mov edx, OFFSET prompt1
call writeString
mov eax, OFFSET month
mov ecx, 19
call readInt
call crlf
mov edx, OFFSET prompt2
call writeString
mov eax, OFFSET day
mov ecx, 19
call readInt
call crlf
mov edx, OFFSET prompt3
call writeString
mov eax, OFFSET year
mov ecx, 19
call readInt
call crlf
mov al, 14
sub al, month
mov bl, 12
div bl
mov a, al
mov al, 0
mov ah, year
sub ah, a
mov y, ah
mov ah, 0
mov bh, 12
mul a
add bh, a
mov ch, 2
sub bh, ch
mov m, bh
mov bh, 0
mov ch, 0
mov al, 31
mul m
mov ah, 12
div ah
mov bl, y
mov bh, day
add bh, y
mov cl, y
mov ch, 4
div ch
add bh, cl
mov dl, y
mov dh, 4
div dh
add bh, cl
add bh, al
mov al, 0
mov al, 7 // mod 7
div al
exit
main ENDP
END main
所以我应该做这些算术方程:
a = (14 - month) / 12
y = year - a
m = month + (12 * a) - 2
d = (day + y + y/4 - y/100 + y/400 + (31 * m / 12)) % 7
对于 的最后一个等式mod 7
,我得到一个错误,“整数溢出”,这是由于bl
我认为使用。
如果我做这样的事情
mov ax, "thing in parenthesis"
mov cl, 7
div cl
那么我会得到al
商,ah
是余数。
但是我怎么能mod
不用ax
注册呢?