Hi,
First of all, thanks for reading this stuff.
I am writing a msdos program that needs to assign memory dinamically. I know that previously I must reduce the memory assigned to my program. Then, i have written this macro that is just at the startup of the program:
;--------------------------------
;AJUSTA LA MEMORIA USADA POR EL
;PROGRAMA AL MINIMO NECESARIO.
;ES NECESARIO PARA PODER USAR
;MEMORIA DINAMICA YA QUE AL
;PRINCIPIO NO HAY MEMORIA LIBRE
;PORQUE EL SISTEMA LA ASIGNA TODA
;AL PROGRAMA.
__AJUSMEM MACRO
MOV BX, SS
MOV AX, ES
SUB BX, AX
MOV AX, SP
SHR AX, 4
ADD AX, 2 <------
ADD BX, AX
MOV AH, 4AH
INT 21H
ENDM __AJUSMEM
;--------------------------------
My doubt is that (in the line with the arrow) I have seen in all the internet examples simply an INC AX, but if I use only inc the program seems to work but when finishes msdos hangs.
My question is if this method is correct or I shall need in some future add 3, 4 or another number to AX. Or I am wrong.
Thanks in advance.