assume cs:code
code segment
;待显示的日期字符串
year: db 'yy-'
month: db 'mm-'
day: db 'dd '
hour: db 'hh-'
min: db 'mm-'
sec: db 'ss',0
;每个字段的偏移地址
s: dw offset year,offset month,offset day,offset hour,offset min,offset sec
port: db 9,8,7,4,2,0 ;端口号
start:
mov ax,cs
mov ds,ax
mov di,offset port
mov si,offset s
mov cx,6
ok:
push cx ;因以下程序使用cl寄存器,先将cx寄存器压栈
mov al,ds:[di]
out 70h,al
in al,71h ;读出相应端口号内的内容
mov ah,al ;转换al中读出的内容,例:(al)=18,转换后(ah)=01,(al)=08
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h ;将数字转换为ascii码
add al,30h
mov bx,ds:[si] ;将偏移地址作为地址,写入字符串,类似指针的指针
mov ds:[bx],ah
mov ds:[bx+1],al
inc di
add si,2
pop cx
loop ok
;显示字符串
mov si,0
mov dh,10
mov dl,10
mov cl,07h
call show_str
mov ax,4c00h
int 21h
;子程序描述
;名称:show_str
;功能:在指定的位置,用指定的颜色,
王爽《汇编语言》实验14 访问CMOSRAM
最新推荐文章于 2024-04-17 10:05:39 发布