⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 luofangl.asm

📁 在电脑上提示用户输入某一天的年月日
💻 ASM
字号:
;This program is for caculating weekday. 
datas segment
    Isay       db 0dh,0ah,'This program is for caculating weekday.',0dh,0ah,' We know 1900-01-01 is Monday.$'
    warnning   db 0dh,0ah,'<only digit allowable ,and use enter as a ending> .$'
    yearinfor      db 0dh,0ah,'please input the year!(four num): $' 
    monthinfor db 0dh,0ah,'please input the month!(tow num): $'
    dateinfor  db 0dh,0ah,'please input the date!(tow num): $'
    ISNOT      db 0dh,0ah,'It is not a leap year!$'
    IS         db 0dh,0ah,'It is a leap year!$'   
    ; weekday
     Mon       db  0dh,0ah,'It is Monday!$' 
     Tue       db  0dh,0ah,'It is Tuesday! $'     
     Wed       db  0dh,0ah,'It is Wednesday!$' 
     Thu       db  0dh,0ah,'It is Thursday!$' 
     Fri       db  0dh,0ah,'It is Friday !$' 
     Sat       db  0dh,0ah,'It is Saturday !$' 
     Sun       db  0dh,0ah,'It is Sunday !$'  
year       dw 0   ;the years from 1900 to the input year
    incr       dw 0   ; the day increased to 1900-01-01
    leapm      dw 0   ; this is design especially for Feb 
    days       db 0   ; the days from 01 to input date  
    ;********* the following macro is used to start a new line
    newline macro
 mov dl,0dh;
     mov ah,02h
     int 21h
     mov dl,0ah
     int 21h   
    endm
datas ends
;-------------------------------------------------------------------------------------------------------------------
prognam segment
    assume cs:prognam,ds:datas
start:
       mov ax,datas           ; move data segment's address to ds
       mov ds,ax
       mov dx,offset Isay;
       mov ah,09
       int 21h
 mov dx,offset warnning;
       mov ah,09
       int 21h
       mov dx,offset yearinfor;
       mov ah,09           
       int 21h
 mov ah,1       ;
       int 21h        ;
       cmp al,0dh    ;
       jz  exit      ;
       mov bx,0       ;
       jmp leap1      ;
leap:
        mov ah,1      ;
        int 21h       ;
        cmp al,0dh   ;
        jz  leap2       ;
 ; the following code is to convert ascii to digit
leap1:
       sub al,30h     ;if character is not a digit then jump to start: 
       jl start           ;
       cmp al,09      ;if character is not a digit then jump to start:
       jg start      ;
       cbw           ; convert byte to word, that is AL to AX   
       xchg ax,bx    ;Exchange AX and BX
       mov cx,10    
       mul cx       
       xchg ax,bx   
       add bx,ax    
       jmp leap 
;******************************************************************
    leap2:      
      mov cx,bx
      mov ax,bx
      mov year,bx
      cwd
      mov dx,0
      mov bx,100
      div bx
      cmp dx,0
      jz  leap3
      mov ax,cx
      cwd
      mov dx,0
leap3:
       mov bx,4
       div bx
       cmp dx,0
       jnz leap4
       lea dx,IS 
       mov ah,09
       int 21h    
       mov bx,1
       add leapm,bx
       jmp next_step
leap4: ;show judge information
       lea dx,ISNOT
       mov ah,09
       int 21h       
       jmp next_step     
       next_step:        
          ;***********************************************************************
             lea dx,monthinfor
             mov ah,09h
             int 21h
mov bx,0h                 
 month:
        mov ah,1      ;
        int 21h          ;
        cmp al,0dh   ;
        jz  month2       ;
month1:
       sub al,30h     ;
       jl start           ;
       cmp al,09      ;
       jg start           ;
       cbw                ;    
       xchg ax,bx    ;
       mov cx,10    
       mul cx       
       xchg ax,bx   
       add bx,ax    
       jmp month
month2:
       mov cx,bx
       dec cx  ; because the current month should not be added; 
       jz calc        ;for example: Feb ,we just need to add 3 for Jan
       add incr,3  ; jan 
       dec cx
       jz calc
       mov bx,leap ; feb
       add incr,bx  
       dec cx
       jz calc   
       add incr,3   ; mar
       dec cx
       jz calc   
       add incr,2  ;apr 
       dec cx
       jz calc     
       add incr,3 ;may  
       dec cx
       jz calc
       add incr,2 ; june  
       dec cx
       jz calc
       add incr,3 ;july  
       dec cx
       jz calc
       add incr,3 ;aug   
       dec cx
       jz calc
       add incr,2 ;sep  
       dec cx
       jz calc
       add incr,3 ;oct   
       dec cx
       jz calc
       add incr,2 ; nov   
       dec cx
       jz calc
       add incr,3;dec   
       dec cx
       jz calc       
calc:
     mov bx,year
     sub bx,1900
     mov ax,bx  
     mov dl,4
     div dl 
     cbw
     add bx,ax   ; al or ah
         add incr,bx 
    ; recieve date here   
         lea dx,dateinfor
         mov ah,09h
         int 21h
         mov bx,0h                 
   date:
        mov ah,1      ;
        int 21h          ;
        cmp al,0dh   ;
        jz  date2       ;
date1:
       sub al,30h     ; 
       jl start           ;  if character is not a digit then jump to start:
       cmp al,09      ;
       jg start           ;if character is not a digit then jump to start:
       cbw                ;    
       xchg ax,bx    ;Exchange BX and AX 
       mov cx,10    
       mul cx       
       xchg ax,bx   
       add bx,ax    
       jmp date
 date2:      
       dec bx ; calculate out how many days has gone since the first day of the input month   
      add incr,bx 
final_calc:
      mov ax,incr       
      mov dl,7
      div dl
jugde:
      cmp ah,0
      jz Monl
      cmp ah,1
      jz Tuel
      cmp ah,2
      jz Wedl
      cmp ah,3
      jz Thul
      cmp ah,4
      jz Fril
      cmp ah,5
      jz Satl
      cmp ah,6
      jz Sunl         
 Monl:
     lea dx,Mon    
     mov ah,09h
     int 21h
     jmp exit
 Tuel:
      lea dx,Tue
     jmp showday
Wedl:
      lea dx,Wed
    jmp showday
 Thul:
     lea dx,Thu
     jmp showday
 Fril:
      lea dx,Fri 
      jmp showday  
 Satl:
       lea dx,Sat
       jmp showday
 Sunl:     
      lea dx,Sun
      jmp showday
showday:  ;display the result
     mov ah,09h
     int 21h      
 newline
     newline  ; newline is define as a macro to start a new line
     newline
       jmp start
   ;***********************************************************************************
 exit:   
        mov ah,4ch
        int 21H
;************************************************************
prognam ends
;------------------------------------------------------------------------------------------
    end start  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -