Article View: comp.os.msdos.programmer
Article #179Release a Turbo C TSR program
From: Nguyen Peter
Date: Sun, 02 Aug 1992 03:47
Date: Sun, 02 Aug 1992 03:47
83 lines
2818 bytes
2818 bytes
Hello everyone,
I have to write an TSR interupt handler for one of my project in
school. I can keep the program TSR and function somewhat "OK". But I
having problem releasing from memory.....
If any expert programmer out there have any clue or suggestion to
release a C TSR program please post or e-mail me...
Below is a sample program taking from the example to BC++ 2.0
Would you please help me how write the release() procedure or give me a
hint on how this can be accomplished.
Many, Many Thanks,
#include <dos.h>
/* The clock tick interrupt */
#define INTR 0x1C
/* Screen attribute (blue on grey) */
#define ATTR 0x9700
#define PPI_BASE 0x380 /* 8255 base address */
#define PORTA 0x380 /* 8255 port A address */
#define PORTB 0x381 /* 8255 port B address */
#define PORTC 0x382 /* 8255 port C address */
#define CONTROL_8255 0x383 /* 8255 control word address */
#define SETUP_8255 0x082 /* 8255 control word data */
/* reduce heaplength and stacklength
to make a smaller program in memory */
extern unsigned _heaplen = 1024;
extern unsigned _stklen = 512;
void interrupt ( *oldhandler)(void);
void interrupt handler(void)
{
unsigned int (far *screen)[80];
static int count;
int VOLTAGE_u; /* 8 bit voltage reading from the ADC0808 */
/* For a color screen the video memory
is at B800:0000. For a monochrome
system use B000:000 */
screen = MK_FP(0xB800,0);
/* increase the counter and keep it
within 0 to 9 */
count++;
count %= 10;
/* put the number on the screen */
screen[0][79] = count + '0' + ATTR;
/* Read in the conversion data from port A */
VOLTAGE_u = inportb(PORTA);
if (VOLTAGE_u==0)
{ setvect(INTR, oldhandler);
release(); <---------------- this is what i have
prblem with.
}
}
int main(void)
{
/* get the address of the current clock
tick interrupt */
oldhandler = getvect(INTR);
/* install the new interrupt handler */
setvect(INTR, handler);
/* _psp is the starting address of the
program in memory. The top of the stack
is the end of the program. Using _SS and
_SP together we can get the end of the
stack. You may want to allow a bit of
saftey space to insure that enough room
is being allocated ie:
(_SS + ((_SP + safety space)/16) - _psp)
*/
keep(0, (_SS + (_SP/16) - _psp));
return 0;
}
Technical Details
Message-ID:
<64838@hydra.gatech.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!prism!gt7961aShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!prism!gt7961a From: gt7961a@prism.gatech.EDU (Nguyen Peter) Newsgroups: comp.os.msdos.programmer Subject: Release a Turbo C TSR program Keywords: TSR Message-ID: <64838@hydra.gatech.EDU> Date: 2 Aug 92 03:47:34 GMT Organization: Georgia Institute of Technology Lines: 84