This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A simple C code doesn't work in LARGE mode

A Keil C program, it will send data "1" when it receives data "55H" on serial port.
The code is as below:

#include <REG52.H>
void main (void)
{
SP=0x5F;
TMOD=0x20; //timer1,Mode2
TH1=0xFD; //baudrate 9600
TR1=1; //start timer1
SCON=0x50; //#0101 0000B; Mode 3, SM2=0 enable int
IE=0x90; //#1001 0000B; enable total int, enable serial int
while(1);
}

void ReceiveFrameStateMachine(void) interrupt 5 //using 2 //serial int
{
unsigned int xdata c;
if(TI!=0) TI=0; //clear and not care about TI
if(RI==0) return; //just care RI
ACC=SBUF;
c=ACC;
if (c==0x55) SBUF=1;
RI=0;
}
This program runs correctly when complied in SMALL mode,however it won't send any data when compiled in LARGE mode.

After compiled in LARGE mode, the asm code as below:
; FUNCTION main (BEGIN)
0000 75815F MOV SP,#05FH
0003 758920 MOV TMOD,#020H
0006 758DFD MOV TH1,#0FDH
0009 D28E SETB TR1
000B 759850 MOV SCON,#050H
000E 75A890 MOV IE,#090H
0011 ?C0001:
0011 80FE SJMP ?C0001
; FUNCTION main (END)

; FUNCTION ReceiveFrameStateMachine (BEGIN)
0000 C0E0 PUSH ACC
0002 C0D0 PUSH PSW
0004 75D000 MOV PSW,#00H
0007 C006 PUSH AR6
0009 C007 PUSH AR7
000B 309902 JNB TI,?C0004
000E C299 CLR TI
0010 ?C0004:
0010 30980B JNB RI,?C0006
0013 ?C0005:
0013 E599 MOV A,SBUF
;---- Variable 'c' assigned to Register 'R6/R7' ----
0015 6455 XRL A,#055H
0017 7003 JNZ ?C0007
0019 759901 MOV SBUF,#01H
001C ?C0007:
001C C298 CLR RI
001E ?C0006:
001E D007 POP AR7
0020 D006 POP AR6
0022 D0D0 POP PSW
0024 D0E0 POP ACC
0026 32 RETI
; FUNCTION ReceiveFrameStateMachine (END)
The asm code seems right. but I cannot receive data "1" on the srial prot.

My questions are:
1.The asm code seems right,but I cannot receive data "1" on the serial prot of my PC.
2. "PUSH AR6" and "PUSH AR7", I cannot find the definition of AR6 and AR7. What do they mean?
Please tell me why instead of just telling me how to midfy the code.

Thanks,
Z.Y. Xu

0