| delorie.com/archives/browse.cgi | search |
| From: | "Andrew Betts" <andy AT jasp DOT com> |
| Newsgroups: | alt.msdos.programmer,comp.lang.c++,comp.arch.embedded,comp.os.msdos.djgpp |
| Subject: | Specifing the location of a function |
| Date: | Sun, 13 Feb 2000 12:07:17 -0000 |
| Organization: | NTL Internet News Service |
| Lines: | 95 |
| Message-ID: | <8866lt$t10$1@nclient3-gui.server.dtn.ntl.com> |
| NNTP-Posting-Host: | p174-harc2-guildford2.tch.dtn.ntl.com |
| X-Trace: | nclient3-gui.server.dtn.ntl.com 950443517 29728 194.168.242.144 (13 Feb 2000 12:05:17 GMT) |
| X-Complaints-To: | abuse AT net DOT ntl DOT com |
| NNTP-Posting-Date: | 13 Feb 2000 12:05:17 GMT |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2919.6600 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2919.6600 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Specifing the location of a function / dynamic loading for .COM
This is my problem: I have 64K of program storage space (tiny memory model)
and vast quantities of disk space. To increase program functionality I want
to be able to load/unload program code at runtime.
As tiny contains only fixed addresses/non relocatable....
The way I thought I could acheive this was by telling the compiler I have a
function at address XYZ and then loading from disk into this address the
code I want. I'm assuming I can generate the code that is loaded by:
1) compiling a separate, complete program for each module I want to build
eg
If we represent each block of program as a letter
prog 1 - XXXXXXXXX....AAAAAA....
prog 2 - XXXXXXXXX....BBB.......
prog 3 - XXXXXXXXX....CCCC......
where X is the common code, '.' is free space and A, B, and C are
different functions.
so now any reference A, B, and C make to global data/functions will be the
same for all three programs. (I hope)
2) Extracting and storing each section on disk
ie
file 1 - AAAAAA
file 2 - BBB
file 3 - CCCC
3) Load and run any one of the progs (doesn't matter which -say prog 1. And
somewhere in the code do
typedef void(*MYFUNCTION)();
MYFUNCTION x=placeHolder; // this is where I have fixed the function to be
...
copyFromFileToRam(x,"file3");
// XXXXXXXXX....AAAAAA.... becomes
// XXXXXXXXX....CCCCAA....
x(); // call function C
...
copyFromFileToRam(x,"file2");
// XXXXXXXXX....CCCCAA.... becomes
// XXXXXXXXX....BBBCAA....
x(); // call function B
...etc
---------
It this technique possible?
Specifically:
a) Can I tell the linker to put a function at a certain location
b) Is it safe to assume in the above 3 programs that the common code with
be in the same place in each. (of course this relies on the fixed location
code (ABC) not getting in the way)
Alternatively, does anyone know a way to acheive the same thing?
Many thanks for your input.
Andrew Betts
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |