// TSR_3 Example //Scout equals _KeyboardFlags = 0417h (expr Terminate (?) ax=4C^1; 21h=.int expr) (expr JumpFAR ?) -> bytes =0EAh, ^1(4) (expr FreeEnvironment es=WORD PTR ds:[2Ch] ah=49h; 21h=.int expr) (expr TSR (?) dx=OFFSET ^1; 27h=.int expr) (expr FreeMemory ah=49h; 21h=.int expr) equals Request = 0ABBAh, Reply = 0BABAh, HotKey = 1C0Dh, ShiftStatus = 00000001b equals BufferSize = 0 MODEL Tiny, Pascal .ORG 100h PROGRAM TSR_3 .LOCALS _@ goto Initialize bytes Flags = 00000000b, SaveAH (proc FAR Int_16h()[] (if cs:Flags.test.00000001b= (if ah.test.11101110b<> if ax<>Request goto Pass_16h ax=Reply; push cs; pop es; .iret if) (if ah.test.00000001b= (while cs:SaveAH=ah .sti; .pushf; .cli; call DWORD PTR cs:Old_Int_16h() if ax<>HotKey then .iret call ChkShiftStatus() if <> then .iret call Main() ah=cs:SaveAH while) if) cs:SaveAH=ah; cs:SaveAH=-1 .sti; .pushf; .cli; call DWORD PTR cs:Old_Int_16h() (if <> and ax=HotKey call ChkShiftStatus() if <> then 2=.retf ah=cs:SaveAH .pushf; .cli; call DWORD PTR cs:Old_Int_16h() call Main() if) 2=.retf if) Pass_16h: JumpFAR Old_Int_16h proc) (proc ChkShiftStatus()[ax,es] es=ax=0 al=BYTE PTR es:[_KeyboardFlags]; al=.and.00001111b al=.cmp.ShiftStatus return proc) (proc Main()[ax] cs:Flags=.or.00000001b // [ Куча всего ] // Например: ax=0E07h; 10h=.int // cs:Flags=.and.11111110b return proc) Initialize: // Проверить наличие себя в памяти ax=Request; 16h=.int (if ax<>Reply ax=3516h; 21h=.int WORD PTR [Old_Int_16h]=bx WORD PTR [Old_Int_16h+2]=es dx=OFFSET Int_16h ah=25h; 21h=.int FreeEnvironment TSR (Initialize+BufferSize) if) // UnInstall dx=es ax=3516h; 21h=.int bx=-OFFSET Int_16h ax=es-dx.or.bx if <> goto Finish dx=.lds.DWORD PTR es:Old_Int_16h ax=2516h; 21h=.int FreeMemory Finish: Terminate (00h)