First post, by llm
now it runs and does not crash!!!
FIXES:
1. changed wlink.exe format dos ... to wlink.exe format dos com ...2. removed mov ax,@data and mov ds,ax because ds=cs in tiny model3. fixed the uinstall code to use the real tsr data4. fixes missing use of es in uninstall tsr_info acccess
can anyone see were i made a error or anyone got an idea whats wrong with my code - i try to overwrite the int 21h/ah=9 functions to replace some chars on print
its not finished (no code in the ISR except calling the old handler) but already helps my dosbox DOS behaves strange after install - can't even run the Dosbox debugger after install
build with OpenWatcom V2 wasm+wlink (or JWasm, Uasm, Masm)
set WATCOM=f:\projects\fun\dos_games_rev\tools\open-watcom-2_0-c-win-x64set WATCOM_BIN=%WATCOM%\binnt64set INCLUDE=%WATCOM%\hset PATH=%WATCOM_BIN%;%PATH%wasm.exe tsr.asmwlink.exe format dos com file tsr.obj name tsr.com
the TSR code
far_ptr_t strucoffs dw 0segm dw 0far_ptr_t endstsr_info_t strucsignature dw 0CAFEhold_interrupt_21h far_ptr_t<0,0>load_segment dw 0tsr_info_t ends.model tiny.codeorg 100h ; this is a COM programstart:jmp setup ; jump to TSR installationint21h_handler proc farcmp ah,9 ; is it printjne run_original; copy string with $; search for 'l' and replace with 'X'; ds=cs,dx=offset buffer; ...run_original:jmp far ptr cs:[tsr_info.old_interrupt_21h] ; jump to original int 21h; local bufferbuffer db 16 dup(0)int21h_handler endp; tsr datatsr_info TSR_info_t<>resident_end: ; also contains PSP at start due to "org 100h"TSR_INFO_OFFSET = offset tsr_info - offset int21h_handler;current_load_seg dw 0setup:mov bx,dsmov current_load_seg,bx; ds == csmov ax,3521h ; get int 21hint 21hmov di,bxadd di,TSR_INFO_OFFSETmov ax,es:[di+TSR_info_t.signature]cmp ax,0CAFEhje uinstall
; install; save current int 21h handlermov [tsr_info.old_interrupt_21h.offs],bxmov [tsr_info.old_interrupt_21h.segm],es; save load-segment for uninstallmov ax,current_load_segmov [tsr_info.load_segment],axmov ax,2521h ; set interrupt vectormov dx,offset int21h_handlerint 21hmov ax,3100hmov dx,offset resident_endmov cl,4shr dx,clinc dxint 21huinstall:push dsmov ax,es:[di+TSR_info_t.old_interrupt_21h.segm]mov ds,axmov dx,es:[di+TSR_info_t.old_interrupt_21h.offs]mov ax,2521hint 21hpop dsmov ax,es:[di+TSR_info_t.load_segment]mov es,axmov ah,49hint 21hmov ax,4c00hint 21hEND start
last time if was something simple like an overwritten ah,ah register - im doing way too much C++ and my brain isn't very good in pattern machting of stupid mistakes in 16bit assembler 🙁