I've been trying to write TSR (Terminate-Stay-Resident) programs (in general) in Assembly (16-bit) for MS-DOS. I've read through a Wikipedia page on TSR and also a page on using it specifically in DOS (but it seems to be teaching it in C and not Assembly directly). I've looked at a site with tons of DOS interrupt documentation and find this one, this one, and another most relevant to TSR programs. I can't post all of the links because as a new user I can have up to 2 hyperlinks on a post.
So, I've tried writing a (seemingly) very simple TSR program in real mode flat model (.COM file format) in NASM. Here's the code:
creating digital clock
.model small
.stack 64h
code segment
assume cs:code
begin :
jmp tsr
address dd ?
str db ':','$'
hrs db ?
min db ?
sec db ?
num db 10
h db 2 dup(0)
m db 2 dup(0)
s db 2 dup(0)
clrscrn proc near
mov ax,0600h
mov bh,34h
mov cx,0000h
mov dx,2060h
int 10h
ret
clrscrn endp
set proc near
mov ah,02h
mov bh,00h
mov dh,0ah
mov dl,0ah
int 10h
ret
set endp
getv proc near
mov ah,2ch
int 21h
mov al,ch
mov ah,00
div num
mov bl,ah
mov dl,al
add dl,30h
mov ah,02h
int 21h
mov dl,bl
add dl,30h
mov ah,02h
int 21h
mov ah,09h
lea dx,str
int 21h
mov ah,2ch
int 21h
mov al,cl
mov ah,00h
div num
mov bl,ah
mov dl,al
add dl,30h
mov ah,02h
int 21h
mov dl,bl
add dl,30h
mov ah,02h
int 21h
mov ah,09h
lea dx,str
int 21h
mov ah,2ch
int 21h
mov al,dh
mov ah,00h
div num
mov bl,ah
mov dl,al
add dl,30h
mov ah,02h
int 21h
mov dl,bl
add dl,30h
mov ah,02h
int 21h
ret
getv endp
clock proc near
mov cl,100
b11:
call clrscrn
call set
call getv
call clrscrn
loop b11
ret
clock endp
l1:
mov ax,cs
mov ds,ax
mov es,ax
mov ah,00h
mov al,03h
int 10h
in al,60h
cmp al,01
jne e1
call clock
e1:
jmp dword ptr cs:address
tsr:
mov ax,cs
mov ds,ax
mov es,ax
mov ah,35h
mov al,09h
int 21h
mov word ptr address,bx
mov word ptr address+2,es
mov ah,25h
mov al,09h
mov dx,offset l1
int 21h
mov ah,31h
mov dx,offset tsr
int 21h
code ends
end begin
No comments:
Post a Comment