|
主题 : : 实验14_访问CMOS RAM完成!请大家指教。 [待解决] |
回复[ 3次 ]
点击[ 461次 ] | |
|
|
|
|
[帖 主]
[ 发表时间:2009-10-08 12:47 ]
[引用]
[回复]
[ top ] | |
荣誉值:0
信誉值:0
注册日期:2009-10-05 23:09 |
先划出一块内存,向端口读取数据并传送至内存,最后使用中断显示信息。
assume cs:code
code segment
data: db 9,0,'/',8,0,'/',7,0,' ',4,0,':',2,0,':',0,0,'$'
go: mov ax,cs
mov ds,ax
mov si,0
mov cx,6
main: push cx
mov al,[si]
out 70h,al
in al,71h ;读取CMOS RAM的时间信息
mov ah,al
mov cl,4
shr ah,cl
and al,0fh ;析取BCD码,高4位码放在ah中,低4位码放在al中
add ah,30h
add al,30h ;转为十进制数的ASCII码值。
mov [si],ah
mov [si+1],al ;送至data处。
add si,3
pop cx
loop main
display: mov ah,2
mov dh,5
mov dl,12
mov bh,0
int 10h ;设置光标位置为0页5行12列。
mov ah,9
mov dx,0
int 21h ;在光标位置显示data段中的字符串。
mov ax,4c00h
int 21h
code ends
end go | | |
|
|
|
|
[第1楼]
[ 回复时间:2009-10-24 13:09 ]
[引用]
[回复]
[ top ] | |
荣誉值:4
信誉值:0
注册日期:2009-06-14 17:55 |
兄弟我用你的程序怎么不行啊,我编译了,但是没有结果显示 | | |
|
|
|
|
[第2楼]
[ 回复时间:2011-01-07 12:18 ]
[引用]
[回复]
[ top ] | |
荣誉值:0
信誉值:0
注册日期:2011-01-06 09:29 |
assume cs:code,ds:data
;*************************************************************************************************
data segment
db 'yy/mm/dd hh:mm:ss'
db 9,8,7,4,2,0 ;CMOS中时间信息的单元号
data ends
;*************************************************************************************************
stack segment
dw 8 dup(0)
stack ends
;*************************************************************************************************
code segment
start:
mov bx,data
mov ds,bx
mov bx,stack
mov ss,bx
mov sp,16d
mov si,0 ;si指向'yy/mm/dd hh:mm:ss'的首地址
mov di,17d ;di指向9,8,7,4,2,0的首地址
mov cx,6 ;循环次数
s: push cx
mov al,ds:[di] ;从CMOS中读出年份的BCD码
out 70h,al
in al,71h
mov ah,al ;al中位读出的数据
mov cl,4
shr ah,cl ;ah中为年份的十位数
and al,00001111b ;al中为年份的个位数
add ah,30h ;把数值转换为对应的ASCII码
add al,30h ;同上
mov byte ptr ds:[si],ah ;把读出的时间写入ds段
mov byte ptr ds:[si+1],al
add si,3
inc di
pop cx
loop s
;把读出的内容按yy/mm/dd hh:mm:ss的格式写显存
mov bx,0b800h
mov es,bx
mov ch,ds:[0]
mov byte ptr es:[160*16+26*2],ch
mov cl,ds:[1]
mov byte ptr es:[160*16+26*2+2],cl
mov cl,ds:[2]
mov byte ptr es:[160*16+26*2+4],cl
mov ch,ds:[3]
mov byte ptr es:[160*16+26*2+6],ch
mov cl,ds:[4]
mov byte ptr es:[160*16+26*2+8],cl
mov cl,ds:[5]
mov byte ptr es:[160*16+26*2+10],cl
mov ch,ds:[6]
mov byte ptr es:[160*16+26*2+12],ch
mov cl,ds:[7]
mov byte ptr es:[160*16+26*2+14],cl
mov cl,ds:[8]
mov byte ptr es:[160*16+26*2+16],cl
mov ch,ds:[9]
mov byte ptr es:[160*16+26*2+18],ch
mov cl,ds:[10]
mov byte ptr es:[160*16+26*2+20],cl
mov cl,ds:[11]
mov byte ptr es:[160*16+26*2+22],cl
mov ch,ds:[12]
mov byte ptr es:[160*16+26*2+24],ch
mov cl,ds:[13]
mov byte ptr es:[160*16+26*2+26],cl
mov cl,ds:[14]
mov byte ptr es:[160*16+26*2+28],cl
mov ch,ds:[15]
mov byte ptr es:[160*16+26*2+30],ch
mov cl,ds:[16]
mov byte ptr es:[160*16+26*2+32],cl
;调用int 16h的1号功能,从键盘缓冲区读字符
mov ah,1
int 16h
cmp al,'q' ;若按q键则退出程序
je exit
jmp start ;使程序反复读CMOS,从而实现动态显示时间
exit: mov ax,4c00h
int 21h
code ends
;*************************************************************************************************
end start | | |
|
|
|
|
[第3楼]
[ 回复时间:2011-01-07 22:32 ]
[引用]
[回复]
[ top ] | |
荣誉值:268
信誉值:12
注册日期:2010-06-18 22:19 |
|
|