判断某一年是否为闰年

; 判断某一年是否为闰年,是则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)