Summary
- The rounding doesn't appear correct; It's not always to the next multiple of 8;
- None of the docs mention that the block header is included in the space allocated?
- Is the block header pointer to next free space relative?
- The block header doesn't appear correct either;
- Owning job Id seems always to be zero.
- Request 1 byte, gets 32 bytes returned in D1, expected 24.
- Request 10 bytes, also gets 32 bytes returned in D1, expected 32.
- Request $3f2 bytes, gets $410 bytes returned in D1, expected $408.
- Request $400 bytes, also gets $410 bytes returned in D1, expected $410.
Detail
I know that there's a 16 byte overhead included before the start of the common heap space allocated, detailing:
- Size of the block;
- (Relative?) pointer to the next free space in the common heap (or the address of the device driver code to free this block);
- Owning Job Id;
- Address of a byte to be set when this block is freed.
None of the docs I've seen specifically mention that the overhead is included in the value returned in D1 from SMS.ACHP/MT_ALLOC. Is this definitely the case? It appears to be as requesting 10 bytes also gives me $20 according to D1. (10 rounded to 16 plus 16.)
On top of the weird rounding up, the 4 long words ahead of the base of the area allocated are looking strange. I get:
-$10 Size of block = $20
-$0C Pointer to next free/dealloc code = $00
-$08 Owner job ID = $00
-$04 Address to set when block freed = $00
EDIT: Of course S*BASIC owns it, you CALLed the code, it's not in a job! Duh!
I can understand the address to set being zero, but there doesn't seem to be a (relative?) pointer to the next free block. Unless the pointer is from the end of the allocated block? (Which I doubt!)
What am I not understanding?
QPC on Linux Mint 20.3 Under wine. 64 bits.
Cheers,
Norm.