printf can't output 8-bit variable

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf can't output 8-bit variable

403 Views
fqh
Contributor II
135           printf("%hhu %d\n", byte, 9999);
0xfe89b8:   90270F LD D2,#9999
0xfe89bb:   0402 PSH D2
0xfe89bd:   A4120A LD D0,4618
0xfe89c0:   9E40 TFR D0,D2
0xfe89c2:   0402 PSH D2
0xfe89c4:   98001201 LD X,#4609
0xfe89c8:   0442 PSH X
0xfe89ca:   BBFEF83D JSR 16709693 printf (0xfef83d)

byte is defined as an 8-bit variable:

unsigned char byte;

when call printf function, the compiler loads it to D0 (8-bit) register and then transfers to D2 (16-bit) register, then pushes the 16 bits value to stack. But in the printf,  it is retrieved as an 8-bit value from stack. Is it a compiler bug?

CodeWarrior for MCU
Version: 10.7
Build Id:160721

0 Kudos
Reply
0 Replies