【虎彡】时钟显示程序遭遇无效指令
时间:2011-02-02
来源:互联网
;==================================================
;中断处理程序常量定义
count_val =18 ;间隔”滴答“数
dpage =0 ;显示页
row =0 ;显示时钟行号
column =80-buff_len ;显示时钟开始列号
color =07h ;属性
;代码
code segment
assume cs:code,ds:code
;1ch号中断处理程序使用的变量
count dw count_val ;滴答计数
hhhh db ?,?,':' ;时
mmmm db ?,?,':' ;分
ssss db ?,? ;秒
buff_len = $-offset hhhh ;BUFF_LEN显示信息长度
cursor dw ? ;原光标为止
;---------------------------------------------------
;1ch号中断处理程序代码
new1ch:
cmp cs:count,0 ;是否到显示的时候?
jz next ;是,转
dec cs:count ;滴答计数-1
iret ;中断返回
next:
mov cs:count,count_val;重置间隔初值
sti ;开中断
push ds
push es
push ax
push bx
push cx
push dx
push si
push bp
push cx
pop ds
push ds
pop es
call get_t ;取时间
mov bh,dpage
mov ah,3
int 10h
mov cursor,dx ;保存光标位置
mov bp,offset hhhh
mov bh,dpage
mov dh,row
mov dl,column
mov bl,color
mov cx,buff_len
mov al,0
mov ah,13H
int 10h ;显示时钟
mov bh,dpage
mov dx,cursor
mov ah,2
int 10h ;恢复原光标
pop bp
pop si
pop dx
pop cx
pop bx
pop ax
pop es
pop ds
iret ;中断返回
get_t proc near
mov ah,2
int 1ah ;取时间
mov al,ch
call ttasc ;把BCD码转换成ASCII码
xchg ah,al
mov word ptr hhhh,ax ;保存
mov al,cl
call ttasc
xchg ah,al
mov word ptr mmmm,ax ;保存
mov al,dh
call TTASC
xchg ah,al
mov word ptr ssss,ax ;保存
ret
get_t endp
;---------------------------------------------------
;把两位压缩BCD码转换成相对应的ASCII码
;入口:al=压缩BCD码
;出口:ah=高位BCD码对应的ASCII码
; al=低位BCD码对应的ASCII码
TTASC proc near
mov ah,al
and al,0fh
shr ah,1
shr ah,1
shr ah,1
shr ah,1
add ax,3030h
ret
TTASC endp
;===================================================
;初始化部分代码和变量
OLD1CH dd ? ;原中断向量保存单元
start:
push cx
pop dx
mov ax,351ch
int 21h ;取1CH号中断向量
mov word ptr OLD1CH,bx
mov word ptr OLD1CH+2,es;保存原1CH中断向量
mov dx,offset new1ch
mov ax,251ch
int 21h ;设置新1CH号中断
;........
;........ ;其他工作
mov ah,0
int 16h
lds dx,old1ch
mov ax,251ch
int 21h ;恢复原1CH中断
mov ax,4c00h
int 21h
code ends
end start
;====================================================
谁帮我在虚拟机下试试? 我这没有,是哪里错误导致无效指令了呢?
另庆祝小花一朵~第一次哦~
;中断处理程序常量定义
count_val =18 ;间隔”滴答“数
dpage =0 ;显示页
row =0 ;显示时钟行号
column =80-buff_len ;显示时钟开始列号
color =07h ;属性
;代码
code segment
assume cs:code,ds:code
;1ch号中断处理程序使用的变量
count dw count_val ;滴答计数
hhhh db ?,?,':' ;时
mmmm db ?,?,':' ;分
ssss db ?,? ;秒
buff_len = $-offset hhhh ;BUFF_LEN显示信息长度
cursor dw ? ;原光标为止
;---------------------------------------------------
;1ch号中断处理程序代码
new1ch:
cmp cs:count,0 ;是否到显示的时候?
jz next ;是,转
dec cs:count ;滴答计数-1
iret ;中断返回
next:
mov cs:count,count_val;重置间隔初值
sti ;开中断
push ds
push es
push ax
push bx
push cx
push dx
push si
push bp
push cx
pop ds
push ds
pop es
call get_t ;取时间
mov bh,dpage
mov ah,3
int 10h
mov cursor,dx ;保存光标位置
mov bp,offset hhhh
mov bh,dpage
mov dh,row
mov dl,column
mov bl,color
mov cx,buff_len
mov al,0
mov ah,13H
int 10h ;显示时钟
mov bh,dpage
mov dx,cursor
mov ah,2
int 10h ;恢复原光标
pop bp
pop si
pop dx
pop cx
pop bx
pop ax
pop es
pop ds
iret ;中断返回
get_t proc near
mov ah,2
int 1ah ;取时间
mov al,ch
call ttasc ;把BCD码转换成ASCII码
xchg ah,al
mov word ptr hhhh,ax ;保存
mov al,cl
call ttasc
xchg ah,al
mov word ptr mmmm,ax ;保存
mov al,dh
call TTASC
xchg ah,al
mov word ptr ssss,ax ;保存
ret
get_t endp
;---------------------------------------------------
;把两位压缩BCD码转换成相对应的ASCII码
;入口:al=压缩BCD码
;出口:ah=高位BCD码对应的ASCII码
; al=低位BCD码对应的ASCII码
TTASC proc near
mov ah,al
and al,0fh
shr ah,1
shr ah,1
shr ah,1
shr ah,1
add ax,3030h
ret
TTASC endp
;===================================================
;初始化部分代码和变量
OLD1CH dd ? ;原中断向量保存单元
start:
push cx
pop dx
mov ax,351ch
int 21h ;取1CH号中断向量
mov word ptr OLD1CH,bx
mov word ptr OLD1CH+2,es;保存原1CH中断向量
mov dx,offset new1ch
mov ax,251ch
int 21h ;设置新1CH号中断
;........
;........ ;其他工作
mov ah,0
int 16h
lds dx,old1ch
mov ax,251ch
int 21h ;恢复原1CH中断
mov ax,4c00h
int 21h
code ends
end start
;====================================================
谁帮我在虚拟机下试试? 我这没有,是哪里错误导致无效指令了呢?
另庆祝小花一朵~第一次哦~
作者: znxllyuan 发布时间: 2011-02-02
不能运行,
作者: leetow2003 发布时间: 2011-02-02
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28