Altera_Forum
Honored Contributor
19 years agoCurious compiler error, "j=j++"
Hey, I made an error coding yesterday while developing an application for the NIOS II processor. I accidentally typed "j=j++;" instead of just "j++;". What I found curious was the resulting assembly:
<div class='quotetop'>QUOTE </div> --- Quote Start --- gcc version 3.4.1 (Altera Nios II 6.1 b197) j=j++; 0x00102bb0 <process_packet+940>: addi r3,fp,60 0x00102bb4 <process_packet+944>: ldw r2,0(r3) 0x00102bb8 <process_packet+948>: mov r4,r2 0x00102bbc <process_packet+952>: addi r2,r2,1 0x00102bc0 <process_packet+956>: stw r2,0(r3) 0x00102bc4 <process_packet+960>: stw r4,60(fp)[/b] --- Quote End --- I don't mind so much that j doesn't get incremented, j=j++ is a quirky case, but why two memory writes? I compiled the code using the default options associated with the "hello world stand alone" template. --Jordan