TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRISTOPHER BUTLER
from: BENJAMIN L MCGEE
date: 1997-05-24 14:20:00
subject: TSRS

 On 05-11-97 Christopher Butler wrote to All... 
 
 CB> Does anyone know how I'd code a TSR that would do something when an 
 CB> interrupt is called? 
 
#begin makefile 
# NOTE: I added the '-Xlinker -noinhibit-exec' below 
# it wouldn't link othewise on my system 
 
all: djgpptsr.exe 
 
djgpptsr.exe: djgpptsr.c 
          gcc -O2 -s djgpptsr.c -o djgpptsr.exe -Xlinker\ 
          -noinhibit-exec -Xlinker -M > djgpptsr.map 
          stubedit djgpptsr.exe minstack=4K bufsize=2K 
#end makefile 
 
/*begin djgpptsr.c*/ 
 
/* DJGPPTSR, Nov 1995 Charles Sandmann (sandmann@clio.rice.edu) 
 
   ABSOLULTELY NO WARRANTY.  May be redistributed or copied without 
restriction. 
 
 
   An example of a DJGPP TSR.  This routine changes the video attribute of 
the 
   character in the upper right of the screen once per tick (from protected 
   mode).  The DPMI provider will be forced to stay resident after this image 
   exits.  This code also shows an undocumented way to suppress the exception 
   code loading to decrease the image footprint size.  Not optimal - you can 
   do the same thing with a single GAS file with a much smaller image.  Left 
   as an exercise for the user.  Have fun!  */ 
 
#include  
#include  
#include  
#include  
#include  
#include  
#include  
 
int _stklen = 8192; 
int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; 
 
void __crt0_load_environment_file(char *_app_name) { return; } 
void __crt0_setup_arguments(void) { return; } 
char **__crt0_glob_function(char *_arg) { return 0; } 
 
/* Start undocumented way to make exception handling disappear */ 
void _npxsetup(void) { return; } 
int __emu387_load_hook; 
short __djgpp_ds_alias; 
void __djgpp_exception_setup(void) { return; } 
int __djgpp_set_ctrl_c(int enable) { return 0; } 
/* End undocumented way to make exception handling disappear */ 
 
void int8(void) 
{ 
  unsigned offset = ScreenPrimary+(2*79)+1; 
  _farsetsel(_dos_ds); 
  _farnspokeb(offset,1+_farnspeekb(offset)); 
} 
 
void main(void) 
 { 
   __dpmi_regs regs; 
   _go32_dpmi_seginfo pmint; 
 
   pmint.pm_selector = _my_cs(); 
   pmint.pm_offset = (unsigned)&int8; 
   _go32_dpmi_chain_protected_mode_interrupt_vector(8, &pmint); 
   _write(2,"Installing DJGPP TSR\r\n",22); 
/*   __djgpp_exception_toggle(); */	/* Only needed if exceptions linked */ 
   regs.x.ax = 0x3100; 
   regs.x.dx = (256) / 16;		/* paragraphs */ 
   __dpmi_int(0x21, ®s); 
 } 
 
/*end djgpptsr.c*/ 
 
...Hope that helps.  I have DJGPP 2.01 and MSDos 6.22 and the above 
DOES work.  It leaves a !HUGE! footprint in memory tho.  Under Windows 
3.1, however it leaves only 1K.  Who would have thought Windows would 
actually help a Dos program take up LESS memory. :) 
 
 
Raw MSDos 6.22 
 
Modules using memory below 1 MB: 
 
  Name           Total       =   Conventional   +   Upper Memory 
  --------  ----------------   ----------------   ---------------- 
  ... 
  DJGPPTSR    30,640   (30K)     30,528   (30K)        112    (0K) 
  CWSDPMI     49,200   (48K)     49,200   (48K)          0    (0K) 
  ... 
 
MSDos 6.22 box under Win 3.1 
 
Modules using memory below 1 MB: 
 
  Name           Total       =   Conventional   +   Upper Memory 
  --------  ----------------   ----------------   ---------------- 
  ... 
  DJGPPTSR     1,264    (1K)      1,264    (1K)          0    (0K) 
  ... 
 
  
 
*I had my head examined.  They didn't find anything. 
  
blm
--- FLAME v1.1
---------------
* Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.