汇编语言实验课:第十次记录

文章目录


要求

输出系统的时间包括:时-分;星期;年-月-日

一、程序

DATAS SEGMENT
    ;此处输入数据段代码  
    a1 db 'Sun','Mon','Tue','Wed','Thur','Fri','Sat'
DATAS ENDS

STACKS SEGMENT
    ;此处输入堆栈段代码
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX
    ;此处输入代码段代码
    
    ;hour
    mov al,4
    out 70h,al
    in al,71h
    mov ah,0
    call output
    mov al,':'
    call dispc
    
    ;min
    mov al,2
    out 70h,al
    in al,71h
    mov ah,0
    call output
    call control
    
    ;week
    mov al,6
    out 70h,al
    in al,71h
    mov ah,0
    call output1
	call control
    
    ;year
    mov al,9
    out 70h,al
    in al,71h
    mov ah,0
    call output
    mov al,'-'
    call dispc
    
    ;month
    mov al,8
    out 70h,al
    in al,71h
    mov ah,0
    call output
    mov al,'-'
    call dispc
    
    ;day
    mov al,7
    out 70h,al
    in al,71h
    call output
    
  
    MOV AH,4CH
    INT 21H
    
output proc    ;ax为入口参数

    push bx
	push cx
	push ax
	push dx
	
	mov cl,16
	mov bl,0
D1:	
	cmp al,0
	je D2
	div cl
	push ax
	add bl,1
	mov ah,0
	jmp D1
	
D2:
	cmp bl,0
	je dover
	pop cx 
	sub bl,1
	mov dl,ch
	
	add dl,48
	mov ah,2
	int 21h
	jmp D2

	
dover:
	pop dx
	pop ax
	pop cx
	pop bx
     ret
     
output endp   

;回车换行
dispc proc
     
     push ax
     push dx
     
     
     mov dl,al
     mov ah,2
     int 21h
     
     
     pop dx
     pop ax
     
     ret
     
dispc endp  

;输出星期
output1 proc
	push ax
	push dx
	push si
	mov si,offset a1
	mov dl,0
	sub al,1
L0:
	cmp dl,al
	jb L1
	
	mov dl,[si]
	mov ah,2
	int 21h
	
	add si,1
	mov dl,[si]
	mov ah,2
	int 21h
	
	add si,1
	mov dl,[si]
	mov ah,2
	int 21h
	jmp L3
L1:
	add si,3
	add dl,1
	
	jmp L0
L3:
	pop si
	pop dx
	pop ax
	ret 
output1 endp

;输出字符
control proc
     
     push ax
     push dx
     
     mov dl,13
     mov ah,2
     int 21h
     mov dl,10
     mov ah,2
     int 21h
     
     pop dx
     pop ax
     
     ret
     
control endp 


    
CODES ENDS
    END START

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值