I think I have found a problem with the debugger.
pstart = DFS_GetPtnStart(0, sector, 0, &pactive, &ptype, &psize);
0x0000563e <main+34>: push #1362 ;#0x0552
0x00005642 <main+38>: push #1352 ;#0x0548
0x00005646 <main+42>: mov #1366, r12 ;#0x0556
0x0000564a <main+46>: clr.b r13 ;
0x0000564c <main+48>: mov #1378, r14 ;#0x0562
0x00005650 <main+52>: clr.b r15 ;
0x00005652 <main+54>: call #7720 ;#0x1e28
This is correct in that the two far left parameters are pushed on the
stack, and then r12-r15 are used for remaining parameters.
When I call the function is called here is the prolog:
{
0x00001e28 <DFS_GetPtnStart>: push r11 ;
0x00001e2a <DFS_GetPtnStart+2>: push r5 ;
0x00001e2c <DFS_GetPtnStart+4>: push r4 ;
0x00001e2e <DFS_GetPtnStart+6>: mov r1, r5 ;
0x00001e30 <DFS_GetPtnStart+8>: add #8, r5 ;subst r2 with
As==11
0x00001e32 <DFS_GetPtnStart+10>: sub #38, SP ;#0x0026
0x00001e36 <DFS_GetPtnStart+14>: mov r1, r4 ;
0x00001e38 <DFS_GetPtnStart+16>: mov r5, 20(r4) ;
0x00001e3c <DFS_GetPtnStart+20>: mov.b r15, 0(r4) ;
0x00001e40 <DFS_GetPtnStart+24>: mov r14, 2(r4) ;
0x00001e44 <DFS_GetPtnStart+28>: mov.b r13, 4(r4) ;
0x00001e48 <DFS_GetPtnStart+32>: mov r12, 6(r4) ;
uint32_t result;
uint8_t t;
PMBR mbr = (PMBR) scratchsector;
0x00001e4c <DFS_GetPtnStart+36>: mov 2(r4), 14(r4) ;
// DOS ptable supports maximum 4 partitions
if (pnum > 3)
0x00001e52 <DFS_GetPtnStart+42>: cmp.b #4, 4(r4) ;subst r2 with
As==10
0x00001e56 <DFS_GetPtnStart+46>: jnc $+12 ;abs dst addr
0x1e62
Here r4=0x9c8 thus the address of scratchsector should be 2+0x9c8 =
0x9cA however the debugger shows the address of scratchsector to be
0x9f8, thus when I try to debug the code scratchsector appears to have
incorrect value. Now mbr has correct value. Also the first parameter to
the function, variable name unit, is also shown as incorrect as being
address 0x9f6, thus it looks like the debug information has the frame
pointer wrong. As the first parameter should be address stored in r4
which is 0x9c8.
Trampas Stern