Thread View: alt.msdos.programmer
3 messages
3 total messages
Started by The ChaoTix
Tue, 30 Jan 2001 17:48
Get program out of memory (C++ Dos)
Author: The ChaoTix
Date: Tue, 30 Jan 2001 17:48
Date: Tue, 30 Jan 2001 17:48
80 lines
3838 bytes
3838 bytes
Hi all,
like i asked before, i need to know how to get a program out of the memory.
I
have a little explample of that kind of program. This program will "bind"
his own
function to the timer interrupt (18 times per second). My question to you
all, is
who can make this program so, that you can enable it like "Start.exe -E" or
disable it
"Start.exe -D". Here's the program that is just from C++ help. This programs
runs btw under
full dos mode, and has nothing to do with windows. Be sure that you run this
program in
dos, and not in C++, because c++ locks his interrupts.
Example:
============================================================
#include <dos.h> /* The clock tick interrupt */
#define INTR 0x1C /* Screen attribute (blue on grey) */
#define ATTR 0x7900
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
extern unsigned _heaplen = 1024;
extern unsigned _stklen = 512;
void interrupt ( *oldhandler)(__CPPARGS);
typedef unsigned int (far *s_arrayptr);
void interrupt handler(__CPPARGS)
{ s_arrayptr screen[80];
static int count;
screen[0] = (s_arrayptr) 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;
/* call the old interrupt handler */
oldhandler();
}
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;
}
=========================================================
Everybody thats has tried, thanks a lot. Anyone who has the
answer, pleaaaassseeeeee please please please please send me, and
of cource, Thanks a MORE lot!! =)
ChaoTix
Re: Get program out of memory (C++ Dos)
Author: Jeffrey Turner
Date: Mon, 12 Feb 2001 01:46
Date: Mon, 12 Feb 2001 01:46
92 lines
4377 bytes
4377 bytes
The ChaoTix wrote:
> Hi all,
>
> like i asked before, i need to know how to get a program out of the memory.
> I
> have a little explample of that kind of program. This program will "bind"
> his own
> function to the timer interrupt (18 times per second). My question to you
> all, is
> who can make this program so, that you can enable it like "Start.exe -E" or
> disable it
> "Start.exe -D". Here's the program that is just from C++ help. This programs
> runs btw under
> full dos mode, and has nothing to do with windows. Be sure that you run this
> program in
> dos, and not in C++, because c++ locks his interrupts.
>
> Example:
> ============================================================
>
> #include <dos.h> /* The clock tick interrupt */
> #define INTR 0x1C /* Screen attribute (blue on grey) */
> #define ATTR 0x7900
>
> #ifdef __cplusplus
> #define __CPPARGS ...
> #else
> #define __CPPARGS
> #endif
>
> extern unsigned _heaplen = 1024;
> extern unsigned _stklen = 512;
>
> void interrupt ( *oldhandler)(__CPPARGS);
> typedef unsigned int (far *s_arrayptr);
>
> void interrupt handler(__CPPARGS)
> { s_arrayptr screen[80];
> static int count;
> screen[0] = (s_arrayptr) 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;
>
> /* call the old interrupt handler */
> oldhandler();
> }
>
> 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;
> }
>
> =========================================================
>
> Everybody thats has tried, thanks a lot. Anyone who has the
> answer, pleaaaassseeeeee please please please please send me, and
> of cource, Thanks a MORE lot!! =)
>
> ChaoTix
What compiler are you using? I suspect it's some version of MSVC? What exactly
do you mean by getting the program out of memory? A TSR being removed? This
MAY be impossible if it is not the last TSR loaded. I'd need a lot more info
before being able to help you. Have you tried using D.J. Delorie's port of GNU
tools - including the by far superior gcc - to DOS? That may make the project
earlier, read the FAQ to learn how to deal with x86 segmented addresses and
pointers using djgpp (ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp). Use
version 2.
--Jeff Turner
Re: Get program out of memory (C++ Dos)
Author: The ChaoTix
Date: Mon, 12 Feb 2001 20:29
Date: Mon, 12 Feb 2001 20:29
118 lines
5220 bytes
5220 bytes
Oh please. The last I will use is DJGPP.
Never mind, folks. I got my answer. I even got myself a multitask
program done using TSR's. Check http://go.to/WinTix for more information and
download.
ChaoTix
Jeffrey Turner <cdesign@thecia.net> schreef in berichtnieuws
3A874089.4803781C@thecia.net...
> The ChaoTix wrote:
>
> > Hi all,
> >
> > like i asked before, i need to know how to get a program out of the
memory.
> > I
> > have a little explample of that kind of program. This program will
"bind"
> > his own
> > function to the timer interrupt (18 times per second). My question to
you
> > all, is
> > who can make this program so, that you can enable it like "Start.exe -E"
or
> > disable it
> > "Start.exe -D". Here's the program that is just from C++ help. This
programs
> > runs btw under
> > full dos mode, and has nothing to do with windows. Be sure that you run
this
> > program in
> > dos, and not in C++, because c++ locks his interrupts.
> >
> > Example:
> > ============================================================
> >
> > #include <dos.h> /* The clock tick interrupt */
> > #define INTR 0x1C /* Screen attribute (blue on grey) */
> > #define ATTR 0x7900
> >
> > #ifdef __cplusplus
> > #define __CPPARGS ...
> > #else
> > #define __CPPARGS
> > #endif
> >
> > extern unsigned _heaplen = 1024;
> > extern unsigned _stklen = 512;
> >
> > void interrupt ( *oldhandler)(__CPPARGS);
> > typedef unsigned int (far *s_arrayptr);
> >
> > void interrupt handler(__CPPARGS)
> > { s_arrayptr screen[80];
> > static int count;
> > screen[0] = (s_arrayptr) 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;
> >
> > /* call the old interrupt handler */
> > oldhandler();
> > }
> >
> > 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;
> > }
> >
> > =========================================================
> >
> > Everybody thats has tried, thanks a lot. Anyone who has the
> > answer, pleaaaassseeeeee please please please please send me, and
> > of cource, Thanks a MORE lot!! =)
> >
> > ChaoTix
>
> What compiler are you using? I suspect it's some version of MSVC? What
exactly
> do you mean by getting the program out of memory? A TSR being removed?
This
> MAY be impossible if it is not the last TSR loaded. I'd need a lot more
info
> before being able to help you. Have you tried using D.J. Delorie's port
of GNU
> tools - including the by far superior gcc - to DOS? That may make the
project
> earlier, read the FAQ to learn how to deal with x86 segmented addresses
and
> pointers using djgpp (ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp). Use
> version 2.
>
> --Jeff Turner
>
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads