Преглед изворни кода

* fixed the msdos startup code for the cases when the largest available memory block is smaller that what would be needed for a full 64kb data segment

git-svn-id: trunk@24714 -
nickysn пре 12 година
родитељ
комит
14ded034f6
1 измењених фајлова са 20 додато и 5 уклоњено
  1. 20 5
      rtl/msdos/prt0.asm

+ 20 - 5
rtl/msdos/prt0.asm

@@ -52,15 +52,30 @@ no_bss:
         ; allocate max heap
         ; allocate max heap
         ; TODO: also support user specified heap size
         ; TODO: also support user specified heap size
         ; try to resize our main DOS memory block until the end of the data segment
         ; try to resize our main DOS memory block until the end of the data segment
-        mov bx, word [dos_psp]
-        mov es, bx
-        sub bx, dgroup
-        neg bx  ; bx = (ds - psp) in paragraphs
-        add bx, 1000h  ; 64kb in paragraphs
+        mov dx, word [dos_psp]
+        mov cx, dx
+        sub dx, dgroup
+        neg dx  ; dx = (ds - psp) in paragraphs
+        add dx, 1000h  ; 64kb in paragraphs
+
+         ; get our MCB size in paragraphs
+        dec cx
+        mov es, cx
+        mov bx, word [es:3]
+
+        ; is it smaller than the maximum data segment size?
+        cmp bx, dx
+        jbe skip_mem_realloc
+
+        mov bx, dx
+        inc cx
+        mov es, cx
         mov ah, 4Ah
         mov ah, 4Ah
         int 21h
         int 21h
         jc mem_realloc_err
         jc mem_realloc_err
 
 
+skip_mem_realloc:
+
         ; bx = the new size in paragraphs
         ; bx = the new size in paragraphs
         add bx, word [dos_psp]
         add bx, word [dos_psp]
         sub bx, dgroup
         sub bx, dgroup