bits 16
org 100h

jmp init.tsr
 chk  db '$$$ABz'
 handler:
   sti ; enable interrupts
   mov [cs:callerstk+2], ss
   mov [cs:callerstk], sp
   mov ss, [cs:tsrseg] ; mov segreg disables interrupts
                    ; until end of next instruction
   mov sp, stk
   push ds
   push cs
   pop ds
   push dx
   push ax
   mov dx, msg
   mov ah, 0x9
   int 0x21
   pop ax
   pop dx
   pop ds
   mov ss, [cs:callerstk+2]
   mov sp, [cs:callerstk]
   iret
 tsrseg    dw 0
 msg       db 'h3LL0 wOrLDD',0xd,0xa,0x24
 callerstk dd 0
 times 0x100 db 0
 stk equ $+1

 init.tsr:
   mov ax, 0x3565
   int 0x21
   mov si, chk
   mov di, chk
   mov cx, 0x6
   rep cmpsb    ; Check if installed
   jz init.fail
   mov [tsrseg], cs
   mov dx, handler
   mov ax, 0x2565
   int 0x21
   mov es, [0x2c] ; Free enviroment block if not needed
   mov ah, 0x49
   int 0x21
   mov dx, stk-1
   add dx, 0xf
   shr dx, 0x4
   mov ax, 0x3100
   int 0x21

 fail db 'AlReAdy iNstAleD$'
 init.fail:
   mov dx, fail
   mov ah, 0x9
   int 0x21
   mov ax, 0x4c01
   int 0x21
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by NotNull
0

Assemble using NASM -F BIN -O TSR.COM TSR.ASM
It can be tested in Debug:
>DEBUG
-a
XXXX:0100 int 65
XXXX:0102 int 3
XXXX:0103
-g
h3LL0 wOrLDD

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.