aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Serpell <daniel.serpell@gmail.com>2020-05-23 13:08:44 -0400
committerDaniel Serpell <daniel.serpell@gmail.com>2020-05-23 13:08:44 -0400
commit81acc54ca0b9776b86fc689a40dc9a358ec73730 (patch)
tree3b5420351654e6651a639647b6dd6ae0c441f06e
parenta230bbfad28e854cf35f9df54aeb183ce8187173 (diff)
downloademu2-81acc54ca0b9776b86fc689a40dc9a358ec73730.tar.gz
Adds environment variable to limit available DOS memory.
-rw-r--r--README.md6
-rw-r--r--src/dbg.c5
-rw-r--r--src/dos.c7
-rw-r--r--src/env.h1
4 files changed, 16 insertions, 3 deletions
diff --git a/README.md b/README.md
index 47fdd2e..ba878af 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,12 @@ The available environment variables are:
output, but does not change the DOS NLS information.
The default code-page is CP437.
+- `EMU2_LOWMEM` Limits main memory to 512KB, this fixes some old DOS
+ programs with a bug that checks available memory using
+ "signed" comparison insructions (JLE instead of JBE).
+ This is needed at least for MASM versions 1.0 and 1.10.
+
+
Simple Example
--------------
diff --git a/src/dbg.c b/src/dbg.c
index 11a6dd1..f1c05b3 100644
--- a/src/dbg.c
+++ b/src/dbg.c
@@ -29,9 +29,10 @@ void print_usage(void)
" %-18s DOS current working directory, use 'C:\\' if not given.\n"
" %-18s Set unix path as root of drive 'n', by default all drives\n"
"\t\t point to the unix working directory.\n"
- ". %-18s Set DOS code-page. Set to '?' to show lost of code-pages.\n",
+ ". %-18s Set DOS code-page. Set to '?' to show lost of code-pages.\n"
+ ". %-18s Limit DOS memory to 512KB, fixes some old buggy programs.\n",
prog_name, ENV_DBG_NAME, ENV_DBG_OPT, ENV_PROGNAME, ENV_DEF_DRIVE, ENV_CWD,
- ENV_DRIVE "n", ENV_CODEPAGE);
+ ENV_DRIVE "n", ENV_CODEPAGE, ENV_LOWMEM);
exit(EXIT_SUCCESS);
}
diff --git a/src/dos.c b/src/dos.c
index 84a6816..3d916e5 100644
--- a/src/dos.c
+++ b/src/dos.c
@@ -2052,7 +2052,12 @@ void init_dos(int argc, char **argv)
// Init memory handling - available start address at 0x800,
// ending address at 0xA0000.
- mcb_init(0x80, 0xA000);
+ // We limit here memory to less than 512K to fix some old programs
+ // that check memori using "JLE" instead of "JBE".
+ if(getenv(ENV_LOWMEM))
+ mcb_init(0x80, 0x7FFF);
+ else
+ mcb_init(0x80, 0xA000);
// Init SYSVARS
dos_sysvars = get_static_memory(128, 0);
diff --git a/src/env.h b/src/env.h
index 528a2dc..d4a227b 100644
--- a/src/env.h
+++ b/src/env.h
@@ -8,3 +8,4 @@
#define ENV_CWD "EMU2_CWD"
#define ENV_DRIVE "EMU2_DRIVE_"
#define ENV_CODEPAGE "EMU2_CODEPAGE"
+#define ENV_LOWMEM "EMU2_LOWMEM"
Un proyecto texto-plano.xyz