i am trying to code a TSR (DOS 16BIT), in which every tick of the INT8 moves an asterisk forward around the perimeter of the screen. I have 4 subroutines with different increments of the ‘*’ position corresponding to the respective screen borders. However, the code hangs and i cannot run it all at once in the debugger either, as it depends upon the interrupt. please suggest a solution
pos: dw 158,3998,3838,0
routine: dw subrt1,subrt2,subrt3,subrt4
subrt1:
add di,2
cmp di,[pos]
jnz exit
add bx,2
exit: ret
subrt2: add di,160
cmp di,[pos+2]
jnz exit
add bx,2
ret
subrt3: sub di,2
cmp di,[pos+4]
jnz exit
add bx,2
ret
subrt4: sub di,160
cmp di,[pos+6]
jnz exit
mov bx,0
ret
timer: push ax
mov ax,0xb800
mov es,ax
mov word[es:di],0x720
call [routine+bx]
mov word[es:di],0x742
mov al,0x20
out 0x20,al
pop ax
iret
start: xor ax,ax
xor bx,bx
mov es,ax
cli
mov word[es:8*4],timer
mov word[es:8*4+2],cs
sti
mov dx,start
add dx,15
mov cl,4
shr dx,cl
mov ax,0x3100
int 0x21
This is how you fix your problems, which are mostly about correct preservation of the register state. See the comments.