assume cs:code
code segment
; 要格式化的字符串
s1: db 32h,30h,0,0,'/',0,0,'/',0,0,' ',0,0,':',0,0,':',0,0,'$'
; CMOS日期部分的参数
s2: db 9,8,7,4,2,0
; 要格式化的字符串中变量的偏移地址
s3: db 2,5,8,11,14,17
start:
; 秒:0 2:分 4:时 7:日 8:月 年:9
; 以"年/月/日 时:分:秒"的格式
; bx,di,si,cx
mov ax,cs
mov ds, ax
mov di, offset s2
mov si, offset s3
mov cx,6
s:
push cx
; 设置从70H端口读取日期,[di]指定要读取的时间部分
mov al,[di]
out 70h,al ; 把读取日期部分的参数送入70H端口
in al,71h ; 从70H端口中读出日期部分的值到AL中
mov ah,al
mov ch,0
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h ; 把BCD码转换为ACII码表示的10进制
add al,30h
mov cl,[si] ; s1字符串中要格式化的变量的偏移地址
mov ch,0
mov bx, offset s1 ; 把要显示的字符串的首地址放在bx中
add bx,cx ; 要显示的字符串的首地址+要修改的偏移位置
mov byte ptr [bx],ah ; 把日期部分参数写入格式化字符串的指定位置
mov byte ptr [bx+1],al
inc si
inc di
pop cx
loop s
mov dx, offset s1
mov ah,09H
int 21H
mov ax,4c00h
int 21h
code ends
end start
- [assumechen] 呵呵,我把程序搞复杂了。谢谢! 07/12 23:58
- [fpamc] MOV BX,AX MOV AX,DX MOV DX,0 07/11 23:26
- [assumechen] 这个公式原来一直想不明白,总是觉得会溢出,直到看到这个贴子才转过来。 http://www.asm 07/11 21:19
- [assumechen] 谢谢! 07/11 21:16
- [fpamc] 对的。 07/09 23:04
- [assumechen] 谢谢 06/30 22:34
- [assumechen] 谢谢 06/30 22:33
- [fpamc] 对的。 06/30 10:26
- [fpamc] 恩对的, 06/30 10:24
- [assumechen] 是程序错了,把这一句: mov word ptr es:[0dH],ax ; 雇员的平 06/29 14:45