Menu

#785 global variable load error

closed-fixed
None
5
2013-05-25
2004-07-01
No

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");

Discussion

  • Maarten Brock

    Maarten Brock - 2004-08-03
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     
  • Maarten Brock

    Maarten Brock - 2004-08-03

    Logged In: YES
    user_id=888171

    Fixed in SDCCloop.c 1.42

     

Log in to post a comment.

MongoDB Logo MongoDB