section .data
msg db 'Enter a year ' , 10
msglen equ $-msg
leapYear db ' is a leap year.', 10
leapYearLenght equ $-leapYear
noLeapYear db ' is not a leap year.', 10
noLeapYearLenght equ $-noLeapYear
section .bss
year resd 1
section .text
global main
main:
mov eax,4
mov ebx, 0
mov ecx, msg
mov edx, msglen
int 0x80
mov eax, 3
mov ebx, 0
mov ecx, year
mov edx, 4
int 0x80
mov eax, 4
mov ebx, 1
int 0x80
mov edx, 0
mov eax, ecx
mov ebx, 4h
div ebx ; step 3
mov eax, edx
cmp eax, 0
jne NoLeapYear
je L1
L1:
mov edx, 0
mov eax, ecx
mov ebx, 64h
div ebx ; step 2
mov eax, edx
cmp eax, 0
je L2
jne LeapYear
L2:
mov edx, 0
mov eax, ecx
mov ebx, 190h
div ebx ;step 1
mov eax, edx
cmp eax, 0
je LeapYear
jne NoLeapYear
LeapYear: ; step4
mov eax, 4
mov ebx, 1
mov ecx, leapYear
mov edx, leapYearLenght
int 0x80
jmp Exit
NoLeapYear: ; step 5
mov eax, 4
mov ebx, 1
mov ecx, noLeapYear
mov edx, noLeapYearLenght
int 0x80
jmp Exit
Exit:
mov eax, 1
mov ebx, 0
int 0x80
我上面附上了我的代码。因为,我给出的每一个输入都说1993年的输出是闰年。
由于