主题:求助:闰年题,只要能被4整除都输出闰年?
本人纯属新手,无能为力,写出下面的代码,发现,输出的,只要能被4整除都会输出闰年。
查了很久,无奈之下,发帖在网上求助。
data segment
s1 db 'Please input a year :$'
y1 db 0dh,0ah,'This is a leap year !$'
n1 db 0dh,0ah,'This is not a leap year !$'
y2 db 5
db ?
db 5 dup(?)
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
lea dx,s1
mov ah,09h
int 21h
lea dx,y2
mov ah,0ah
int 21h
lea si,y2+2
mov ax,[si]
and al,0fh
mov cx,1000
mul cx
mov bx,ax
inc si
mov ax,[si]
and al,0fh
mov cx,100
mul cx
add bx,ax
inc si
mov ax,[si]
and al,0fh
mov cx,10
mul cx
add bx,ax
inc si
mov ax,[si]
and al,0fh
add bx,ax
mov bx,ax
mov cx,4
div cx
cmp dx,0
jnz no1
mov ax,bx
mov cx,100
div cx
cmp dx,0
jnz yes1
mov ax,bx
mov cx,400
div cx
cmp dx,0
jnz yes1
yes1:lea dx,y1
mov ah,09h
int 21h
jmp back
no1:lea dx,n1
mov ah,09h
int 21h
back:mov ah,4ch
int 21h
code ends
end start
查了很久,无奈之下,发帖在网上求助。
data segment
s1 db 'Please input a year :$'
y1 db 0dh,0ah,'This is a leap year !$'
n1 db 0dh,0ah,'This is not a leap year !$'
y2 db 5
db ?
db 5 dup(?)
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
lea dx,s1
mov ah,09h
int 21h
lea dx,y2
mov ah,0ah
int 21h
lea si,y2+2
mov ax,[si]
and al,0fh
mov cx,1000
mul cx
mov bx,ax
inc si
mov ax,[si]
and al,0fh
mov cx,100
mul cx
add bx,ax
inc si
mov ax,[si]
and al,0fh
mov cx,10
mul cx
add bx,ax
inc si
mov ax,[si]
and al,0fh
add bx,ax
mov bx,ax
mov cx,4
div cx
cmp dx,0
jnz no1
mov ax,bx
mov cx,100
div cx
cmp dx,0
jnz yes1
mov ax,bx
mov cx,400
div cx
cmp dx,0
jnz yes1
yes1:lea dx,y1
mov ah,09h
int 21h
jmp back
no1:lea dx,n1
mov ah,09h
int 21h
back:mov ah,4ch
int 21h
code ends
end start