can you please consider this piece of code (dsPIC30F6014) :
Code: Select all
dir = (DIRENT *)sect ;
UART1_print("PTR:") ;
printFix(bufOut, dir, 1000000) ;
UART1_printVar(bufOut) ;
UART1_print("\r") ;
memcpy(dir->nameExt, ". ", 11) ;
dir->attrib = 0x10 ;
dir->first[0] = cl & 0xff ;
dir->first[1] = cl >> 8 ;
// dir = (DIRENT *)(sect + DIRENT_SIZE) ;
dir += DIRENT_SIZE ;
UART1_print("DIRENT_SIZE:") ;
printFix(bufOut, DIRENT_SIZE, 1000000) ;
UART1_printVar(bufOut) ;
UART1_print("\r") ;
UART1_print("PTR:") ;
printFix(bufOut, dir, 1000000) ;
UART1_printVar(bufOut) ;
UART1_print("\r") ;
dir is defined as pointer to a DIRENT struct
at run time I get :
but 6162 + 32 != 7186 should be 6194PTR:006162
DIRENT_SIZE:000032
PTR:007186
watching asm :
Code: Select all
;commands.c,404 :: dir += DIRENT_SIZE ;
$1988 $204004 MOV #1024, W4
$198A $90104E MOV [W14+40], W0
$198C $420810 ADD W4, [W0], [W0]
if I use tagged pointer affectation instead of pointer calculation all is going well.
where does 1024 come from
Thank you !