您的位置:首页 > 其它

判断某一年是否为闰年

2014-04-26 17:49 190 查看
; 判断某一年是否为闰年,是则eax=1,否eax=0
;
; author:  wangguolaing
; date:  revised 4/14

.386
.MODEL FLAT

INCLUDE io.h
includelib Kernel32.lib
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

cr          EQU    0dh
Lf          EQU    0ah

.STACK      4096

.DATA
prompt      BYTE   cr,Lf,'Plase enter a year :',cr,Lf,Lf,0
number      BYTE  16 DUP(?)
year        DWORD  ?
Leapyear    BYTE 'The year is a leap year',cr,Lf,Lf,0
Commonyear  BYTE 'The year is a common year',cr,Lf,Lf,0

.CODE
_start:
output prompt
input  number,16
atod number
mov year,eax

cdq
mov ecx,4
idiv ecx
cmp edx,0
jg  common
mov eax,year
cdq
mov ecx,100
idiv ecx
cmp edx,0
je common

leap  :
output Leapyear
jmp quit

common :
output Commonyear

quit:       INVOKE ExitProcess, 0   ; exit with return code 0

PUBLIC _start                       ; make entry point public
END                     ; end of source code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  80x86 汇编语言