hi all,
compiling the following program, the load of the variable stdout is moved outside the loop, so when the function returns, the content of stdout is 1 instead of 0
try to compile it with --model-small
sdcc --version
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.4.2 (Jun 27 2004) (UNIX)
---------------------
#include "8051.h"
#include <stdio.h>
data unsigned char stdout=0;
void putchar(char x) {}
volatile unsigned char ch;
void main(void)
{
while (1)
{
stdout=1;
printf("x");
stdout=0; // this load is moved before the loop
if (ch=='Z') return;
}
}
-------------------
_main:
;bg.c:8: while (1)
; genAssign
mov _stdout,#0x00
00104$:
;bg.c:10: stdout=1;
; genAssign
mov _stdout,#0x01
;bg.c:11: printf("x");
Logged In: YES
user_id=888171
Fixed in SDCCloop.c 1.42