用自己的打印函数,自定义的比较舒服,可以设置颜色。dos中断理应能够diy颜色,不过目前还不知道怎么设置参数
效果图
assume cs:codesg
; 秒: 0 分:2 时: 4 日 : 7 月:8 年:9
codesg segment
str1: db '20yy/mm/dd hh:mm:ss',0
row: db 9,8,7,4,2,0
start:
mov ax, cs
mov ds, ax
mov di, offset str1 + 2
mov si, offset row
mov cx, 5
s: mov al, [si]
out 70h, al
in al, 71h
call do_addstr
add di, 3
inc si
loop s
; 调用函数
mov dh, 12
mov dl, 4
mov cl, 2
mov si, offset str1
call show_str
mov ax, 4c00h
int 21h
; 参数al, 将al中bcd放到ds:di指定处
do_addstr:
push di
push ax
mov ah, al
mov cl, 4
shr ah, cl
add ah, 30h
and al, 00001111b
add al, 30h
mov [di], ah
mov [di + 1], al
pop ax
pop di
ret
;dh 行号,dl 列号 cl 颜色 ,遇到0返回
show_str:
push ax
push bx
push es
push di
push si
push cx
; 计算偏移量
mov al, 160
mul dh
mov bx, ax
mov al, 2
;mov dl, 2
mul dl
add bx, ax
; 偏移量存储在bx中
mov ax, 0b800h
mov es, ax
mov di, 0
mov ah, cl
mov ch, 0
print:
mov cl, ds:[si]
jcxz backshow_str
mov al, cl
mov es:[bx + di], ax
add di, 2
inc si
jmp short print
backshow_str:
pop cx
pop si
pop di
pop es
pop bx
pop ax
ret
codesg ends
end start
浙公网安备 33010602011771号