• R/O
  • SSH
  • HTTPS

amb: Commit


Commit MetaInfo

Revision204 (tree)
Time2020-12-26 17:50:37
Authormateuszviste

Log Message

added low-level notes about DOS memory management

Change Summary

Incremental Difference

--- amb/trunk/amb.c (revision 203)
+++ amb/trunk/amb.c (revision 204)
@@ -893,6 +893,17 @@
893893 int errflag;
894894 #ifdef REALDOS
895895 static char staticbuff[50 * 1024u]; /* can't have full 64K in a COM file, sorry */
896+ /* DOS note: When DOS loads a COM file, it tries to find a 64K block of available
897+ * memory, copies there the 256-bytes PSP followed by the COM file, sets CS=DS=SS to
898+ * the segment where PSP starts, sets SP to 64K-2 and sets IP to 0x100.
899+ * This means that 64K of memory is wasted anyway - so better filling it up
900+ * with something useful (like the above buffer). The memory map produced by TCC
901+ * might suggest something different, but examining the values held by _DS, _SS and
902+ * _SP registers at runtime leaves no doubt.
903+ * One could think that using an EXE instead would be more efficient, but my tests
904+ * show that Turbo C 2.01 does not behave much differently when creating an EXE
905+ * binary (checked under small memory model): only difference is that CS gets its
906+ * own segment, but DS=SS still and SP is set at the end of the segment (65xxx). */
896907 char far *ama = staticbuff;
897908 #else
898909 static char ama[65536u];
Show on old repository browser