From 81acc54ca0b9776b86fc689a40dc9a358ec73730 Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sat, 23 May 2020 13:08:44 -0400 Subject: Adds environment variable to limit available DOS memory. --- README.md | 6 ++++++ src/dbg.c | 5 +++-- src/dos.c | 7 ++++++- src/env.h | 1 + 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" -- cgit v1.2.3