And another quick follow-up to prove the compiler is generating incorrect code with comments ';;'.
1145: DictObjectRead(DICT_PARAM * pDict) {
1146: PBYTE rptr;
1147: DICT_PARAM * pDictTemp = pDict; // Add this as a place to save the pointer passed in D.
0004 6c87 STD 7,SP
1148: // If the object is valid, control code must be something other than 0
1149: if (pDict->obj->ctl) { // Process any functionally defined objects
0006 b745 TFR D,X
0008 ed00 LDY 0,X
000a e64c LDAB 12,Y
000c c100 CMPB #0
000e 2776 BEQ *+120 ;abs = 0086
1150: void (* OD_func)(PLONG p) = pDict->obj->p.pFunc;
0010 ed00 LDY 0,X
0012 e64f LDAB 15,Y ;; Loads 0x00 rather than page register
0014 eee810 LDX 16,Y ;; Loads offset to function
0017 6e85 STX 5,SP ;; Stores offset to wrong location
0019 6b84 STAB 4,SP ;; because it thinks page has to be in front of offset.
1151: asm ;; Above code doesn't work so we do it in assembler instead.
1152: LDX 7,SP ; restore * pDict
001b ee87 LDX 7,SP ;; Previous code trashed X so we get the copy back
1153: LDY 0,X ; point into pDict
001d ed00 LDY 0,X
1154: LDAB 18,Y ; Get the page register
001f e6e812 LDAB 18,Y
1155: LDX 16,Y ; Get the offset into that page
0022 eee810 LDX 16,Y
1156: STX 4,SP ; Store the offset
0025 6e84 STX 4,SP
1157: STAB 6,SP ; followed by the page register
0027 6b86 STAB 6,SP
1158: } Working assembler code completed
Now let's look at how it's used. This code as generated by the compiler works now.
1163: OD_func((PLONG)pDict->obj->pReqBuf); // pass result register.
0041 ee80 LDX 0,SP ;; Get our parameter to pass.
0043 ed00 LDY 0,X
0045 ec43 LDD 3,Y ;; Pass the parameter in the D register
0047 4bf30004 CALL [4,SP] ;; The opcode is correct and the call is to the function offset which is followed by the page value