Passive TSR Hello World

NotNull -1 Tallied Votes 414 Views Share

Assembles under NASM 16-bit,
invoke INT 0x65 to display message.

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
wildgoose 420 Practically a Posting Shark

What is it you need?

NotNull 23 Posting Whiz in Training

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.