Passive TSR Hello World

NotNull -1 Tallied Votes 400 Views Share

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

bits 16
org 100h

jmp init.tsr
 chk  db '$$$ABz'
   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]
 tsrseg    dw 0
 msg       db 'h3LL0 wOrLDD',0xd,0xa,0x24
 callerstk dd 0
 times 0x100 db 0
 stk equ $+1

   mov ax, 0x3565
   int 0x21
   mov si, chk
   mov di, chk
   mov cx, 0x6
   rep cmpsb    ; Check if installed
   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$'
   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:
XXXX:0100 int 65
XXXX:0102 int 3
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, learning, and sharing knowledge.