驻留IP内容显示,可以执行,但执行后不能再输入,(DOS下).高手帮个忙

romyks 2003-05-12 07:33:11
cseg segment para public 'CODE'
assume cs:cseg,ds:cseg
org 100h
start:
jmp initialize
;----------------------------------------------------------------------------
;Data define
;----------------------------------------------------------------------------
old_timer dd ?
location dw 0041h
hextab db '0123456789ABCDEF',0
;----------------------------------------------------------------------------
;Timer initialize
;----------------------------------------------------------------------------
timer_init proc far
sti
pushf
assume ds:nothing
call old_timer
push bp
mov bp,sp
call timer
pop bp
iret
timer_init endp
;----------------------------------------------------------------------------
;Timer
;----------------------------------------------------------------------------
timer proc near
assume cs:cseg,ds:cseg
push ax
push bx
push cx
push dx
push si
push di
push es
push ds
;
mov bx,cs
mov ds,bx
call getpos
push bx
mov bx,location
call setpos
;The stack looks like this:
;New stack since BP saved
;[BP] word Old value of BP
;[BP+2] word offset of calling address
;[BP+4] word segment of calling address
;[BP+6] word flags at interrupt
mov dx,word ptr ss:[bp+2] ;Offset of addr
mov es,word ptr ss:[bp+4] ;Seg of addr
call ddword
pop bx
call setpos
;
pop ds
pop es
pop di
pop si
pop bx
pop dx
pop bx
pop ax
ret
timer endp
;----------------------------------------------------------------------------
;Get the current cursor position and rerturn it in BX
;----------------------------------------------------------------------------
getpos proc near
push ax
push cx
push dx
;
mov ah,03h
mov bh,0 ;Page zero
int 10h
mov bx,dx ;Return the position in BX
;
pop dx
pop cx
pop ax
ret
getpos endp
;----------------------------------------------------------------------------
;Set the current cursor position to the value in BX
;----------------------------------------------------------------------------
Setpos proc near
push ax
push bx
push dx
;
mov ah,02h
mov dx,bx
mov bh,0
int 10h
;
pop dx
pop bx
pop ax
ret
Setpos endp
;----------------------------------------------------------------------------
;ES:DX contains double word to be displayed
;----------------------------------------------------------------------------
ddword proc near
push dx ;Save offset temporarily
mov dx,es ;Move segment to DX
call dsword ;Display segment
call dcolon ;Print a ";"
; call dcrlf
pop dx ;Restore offset to DX
call dsword ;Display offset
ret
ddword endp
;----------------------------------------------------------------------------
;DX containes single word to be displayed
;----------------------------------------------------------------------------
dsword proc near
push dx ;Save low byte temporarily
mov dl,dh ;Move high byte to low byte
call dbyte ;Display high byte
pop dx ;Restore low byte to DL
call dbyte ;Display low byte
ret
dsword endp
;----------------------------------------------------------------------------
;DL contains byte to be displayed
;----------------------------------------------------------------------------
dbyte proc near
push ax ;Save any registers used
push dx
push si
push dx ;Save low nybble temporarily
push cx ;Save CX
mov cl,4 ;Set shift count to 4
shr dx,cl ;Shift high nybble into low nybble
and dx,0fh ;Mask out all but low nybble
mov si,dx ;Use low nybble as index into
mov al,hextab[si] ;hexadecimal character table
call dchar ;Display character
pop cx ;Restore CX
pop dx ;Restore low nybble
and dx,0fh ;Mask out all but low nybble
mov si,dx ;Use low nybble as an index into
mov al,hextab[si] ;hexadecimal character table
call dchar ;Display character
pop si ;Restore registers
pop dx
pop ax
ret
dbyte endp
;----------------------------------------------------------------------------
;Display a ":"
;----------------------------------------------------------------------------
dcolon proc near
mov al,':'
call dchar
ret
dcolon endp
;----------------------------------------------------------------------------
;Display the character contained in AL
;----------------------------------------------------------------------------
dchar proc near
push ax
push bx
mov bh,1
mov ah,0eh
int 10h
pop bx
pop ax
ret
dchar endp
;----------------------------------------------------------------------------
;Initialize section
;----------------------------------------------------------------------------
initialize:
mov bx,cs
mov ds,bx
mov al,08h
mov ah,35h
int 21h
mov word ptr old_timer,bx
mov word ptr old_timer[2],es
mov dx,offset timer_init
mov al,08h
mov ah,25h
int 21h
mov dx,offset initialize
int 27h
cseg ends
end start
...全文
65 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Areslee 2003-05-13
  • 打赏
  • 举报
回复
将对OLDTIMER的调用移到TIMER_INIT函数的最后试试

21,497

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧