🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1409

Re: Get program out of memory (C++ Dos)

#1409
From: Jeffrey Turner
Date: Mon, 12 Feb 2001 01:46
92 lines
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
Technical Details
Message-ID: <3A874089.4803781C@thecia.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
References: <y7Dd6.277393$8r2.5304182@nlnews00.chello.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f6aa,88e59f72df81b779
X-Google-Attributes: gid10f6aa,public
X-Google-Thread: 102bfa,88e59f72df81b779
X-Google-Attributes: gid102bfa,public
X-Google-Thread: fe885,88e59f72df81b779
X-Google-Attributes: gidfe885,public
X-Google-Thread: fcea4,88e59f72df81b779
X-Google-Attributes: gidfcea4,public
X-Google-Thread: 1145b7,88e59f72df81b779
X-Google-Attributes: gid1145b7,public
X-Google-Thread: fa7a6,88e59f72df81b779
X-Google-Attributes: gidfa7a6,public
X-Google-ArrivalTime: 2001-02-11 17:47:58 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail
From: Jeffrey Turner <cdesign@thecia.net>
Newsgroups: alt.msdos.programmer,be.comp.programming,comp.games.development.programming.misc,comp.os.msdos.programmer,comp.programming.contests,no.it.programmering.c++
Subject: Re: Get program out of memory (C++ Dos)
Date: Sun, 11 Feb 2001 20:46:50 -0500
Organization: Posted via Supernews, http://www.supernews.com
Message-ID: <3A874089.4803781C@thecia.net>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
References: <y7Dd6.277393$8r2.5304182@nlnews00.chello.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Complaints-To: newsabuse@supernews.com
Lines: 95