VOGONS


First post, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

Hi all,

I'm currently developing my own emulator and while testing Turbo BASIC's Readme.com, I ran into an issue: the program gets stuck in a loop, repeatedly trying (and failing) to allocate memory.

By reviewing the log of simulated interrupt calls, I found that Readme.com tries to allocate 0xFFFF paragraphs via DOS function 0x48. I’ve designed my emulator to prevent such large allocations since I assume a portion of that memory would already be reserved for BIOS and video memory.

Here's the relevant snippet extracted using the Netwide Disassembler (skipping the initial 732 bytes):

00000995  BBFFFF            mov bx,0xffff
00000998 B448 mov ah,0x48
0000099A CD21 int 0x21

I'm curious—how does DOSBox (or even genuine MS-DOS) respond when a program tries to allocate such a large block of memory? Does it reject the request outright, return a specific error code, or perhaps fake a successful allocation?

Any insights would be appreciated!

My GitHub:
https://github.com/peterswinkels

Reply 1 of 3, by jakethompson1

User metadata
Rank Oldbie
Rank
Oldbie

Is this just a hack way to figure out how much memory is free?

Reply 2 of 3, by crazyc

User metadata
Rank Member
Rank
Member

From https://www.ctyme.com/intr/rb-2934.htm

DOS 2+ - ALLOCATE MEMORY

AH = 48h
BX = number of paragraphs to allocate

Return:
CF clear if successful
AX = segment of allocated block
CF set on error
AX = error code (07h,08h) (see #01680 at AH=59h/BX=0000h)
BX = size of largest available block

Is this just a hack way to figure out how much memory is free?

Not a hack, that's intentionally designed that way.

Reply 3 of 3, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

Turns out I missed that the function was trying to assess available memory. After digging deeper, I discovered it was hanging while trying to allocate the free memory reported by my emulator. I traced the problem to a bug, which I’ve just resolved. Appreciate you taking the time to reply!

My GitHub:
https://github.com/peterswinkels