c - Compiler ignoring if statements -


this simple problem so, hope can point me in right direction.

i writing simple io program in c. in middle of program, have if statement never executed. realized when tried put break point within if statement have automatically removed , pushed down past if statement block. diving problem further, c compiler doesn't create assembly code if statement. following code snippet , assembly output.

code:

void senddata(unsigned int val1 ){     p1out |= 1;     if ((val1 & 0x8000 ) == 0x8000)         wait(t1h);     else         wait(t1l);     p1out &= ~(1); } 

*note: yes, have function called wait delays number of cycles.

assembly:

 13     p1out |= 1;       senddata():  c0ae:   d3d2 0021           bis.b   #1,&port_1_2_p1out  18     p1out &= ~(1);  c0b2:   c3d2 0021           bic.b   #1,&port_1_2_p1out 

thank help.

wait busy loop getting optimized out. believe there example of wait function survive optimization in sample code.

see example http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/18638.aspx


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -