I tried using my own simple malloc by calling this bios function. Again in MS-DOS real mode.
This bios function returns a 16 bit number and I don't really know if my code is correct to convert it to the actual address:
I call this function once (allocating 4096 paragraphs=64K), it returns 0x1C18 (using dosbox for example). That is the number of 16 byte paragraphs, so the real address is 0x1C180.
I assumed the first digit should be the memory segment, and the rest are the offset, so 0x1C18 = 0x1000:C180.
Assuming it is, I tested allocating 64KB arrays:
There was no problem, I even could use default "free" functions with that pointer, and everything seems ok.
Calling the function a second time, returns 0x2C19 = 2000:C190.
Is this correct?
This bios function returns a 16 bit number and I don't really know if my code is correct to convert it to the actual address:
Code:
word _malloc(word para){
word addr = 0;
asm mov ah,48h
asm mov bx,para
asm int 21h
asm jc _error
asm mov addr,ax
return addr;
_error:
return 0;
}
I call this function once (allocating 4096 paragraphs=64K), it returns 0x1C18 (using dosbox for example). That is the number of 16 byte paragraphs, so the real address is 0x1C180.
I assumed the first digit should be the memory segment, and the rest are the offset, so 0x1C18 = 0x1000:C180.
Assuming it is, I tested allocating 64KB arrays:
Code:
byte *tempdata = (byte*)0x1000C180;
There was no problem, I even could use default "free" functions with that pointer, and everything seems ok.
Calling the function a second time, returns 0x2C19 = 2000:C190.
Is this correct?