We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm trying to use the _init_boxh() function but the function always fails. When I look into the assembler code I noticed that the _init_boxh() routine is not support. 64Ksegment length huge pointers, but using the 16Ksegment far memory model instead when it is testing the memory space: // example, calling function: // use 0x1000 block at 0x11F000 _init_boxh(0x11F000,0x1000,0x100) MOV R11,#0x0100 MOV R10,#0x1000 MOV R8,#0xF000 MOV R9,#0x0011 CALLS _init_boxh(0x2B7E8) (0x2B7E8): _init_boxh() routine: MOV R4,#0x00 ADD R11,#1 AND R11,#0xFFFE JMPR CC_Z,0x02B828 ADD R10,R8 => NOT VALID in 64Kspace => cc lost!! MOV R6,R8 MOV R5,R8 ADD R6,#6 SUB R10,R11 JMPR CC_C,0x02B828 => exits here because R10 < R11
Hi Mike, thanks for the quick response. But I don't quite understand why I'm hitting the huge boundaries: I've allocate a huge memory space (from 0x11F000 to 0x11FFFF = 0x1000 bytes) => not crossing the 64K segment I'm requesting to use this 0x1000 bytes size block in the _init_blockh() function. => not more then 16K bytes In the assembly code I see that: R11 = 0x100 (size for one block) R10 = 0x1000 (size of the pool) R9 = 0x11 (segment of mem. space) R8 = 0xF000 (offset of mem. space) Then: R10 (pool size) is added with R8 (offset mem. space): R10 = 0x1000 + 0xF000 = 0x0000 next, R10 is substracted from R11 (size for one block): R10 = 0x0000 - 0x100 => causing cc and error exit of function My idea is that this routine is checking if the size for one block is not higher then the size of the pool, but it is forgetting the carier when adding offset with pool size.
You are saying you don't understand where you are hitting a 64K boundary, but the rest of your post explains exactly where you do. "Crossing a 64K boundary" means having a carry in 16-bit arithmetics, and that's exactly what's happening in your case (0x11F000+0x1000=0x120000: here is your carry.) - mike
The asm code printed is the code from the _init_boxh() routine, NOT mine! The internal code of the function is hitting the 64k boundary by adding the pool size with the segment offset. I, as a user of the _init_boxh() function, doesn't hit any 64K boundary. I allocated a static huge 0x1000 byte block and gave the returned pointer to the _init_boxh() function: #define BLOCK_POOL_SIZE 0x1000 char huge *block_pool[BLOCK_POOL_SIZE]; main { ... _init_boxh(block_pool,BLOCK_POOL_SIZE,0x100); ... } And block_pool pointer showed 0x11F000 value when I was debugging. How should I call this function then? I've made a work around by using _init_boxf() instead (far-version), and casting my pointers to (void far *). main { ... _init_boxf((void far *)block_pool,BLOCK_POOL_SIZE,0x100); ... }
One thing is confusing me. You wrote:
char huge *block_pool[BLOCK_POOL_SIZE];
char huge block_pool[BLOCK_POOL_SIZE];
char huge block_pool[BLOCK_POOL_SIZE+1];
A correction to my last post: although it's not guaranteed to work After thinking about it a minute, it is guaranteed to work. But I could still be missing something, of course. Regards, - mike