7rots51
Advanced Member level 4
- Joined
- May 17, 2002
- Messages
- 1,183
- Helped
- 25
- Reputation
- 50
- Reaction score
- 12
- Trophy points
- 1,318
- Activity points
- 9,636
hdlc_transmit
Hello
I have a problem with keil in this project ,please read this code and find the problem,my guess is that code optimization levels may produce the bug.
Open this project in keil 7.06:
State 1:
compile it with this options: AT89C52(use extended linker and assembler LX51 AX51),code optimization in level 8,remove tick of linker code packing.
go to debug mode and open disassembly window and c:0x0142 you can see that MT9092_Rd returns byte in R7 and the main program use it as status varible.
there is no problem and everything goes well.
exit debug mode.
---------------------------------------------------------------------------------------------------------------
State 2:
compile it with this options: AT89C52(use extended linker and assembler LX51 AX51),add tick of linker code packing,code optimization in level 11.
go to debug mode and open disassembly window and c:0x006A you can see that MT9092_Rd returns byte in R7 and the main program doe not use it as status varible.the return value of MT9092_Rd function in R7 (status variable in main
function) does not used and missed!
This is my problem,please help me to solve it.
------------------------------------------------------------------------------------------------------------------
Only this part of code is under verify:
at main fuction,return value of HDLC_Status_R() as status variable.
while(1)
{
status = HDLC_Status_R();
status = status >> 2;
status = status & 0x03;
if(status == TxEMPTY)
{
TXX = 0;
HDLC_Transmit();
---------------------------------------------------------------------------
State 1 disaasembly:
34: while(1)
35: {
36: status = HDLC_Status_R();
C:0x0136 7F04 MOV R7,#0x04
C:0x0138 120159 LCALL MT9092_Rd(C:0159)
37: status = status >> 2;
C:0x013B EF MOV A,R7
C:0x013C 13 RRC A
C:0x013D 13 RRC A
C:0x013E 543F ANL A,#0x3F
C:0x0140 FF MOV R7,A
38: status = status & 0x03;
C:0x0141 530703 ANL 0x07,#0x03
39: if(status == TxEMPTY)
C:0x0144 BF020E CJNE R7,#0x02,C:0155
40: {
41: TXX = 0;
C:0x0147 C2B4 CLR T0(0xB0.4)
42: HDLC_Transmit();
C:0x0149 1201D9 LCALL HDLC_Transmit(C:01D9)
---------------------------------------------------------------------------
State 2 disaasembly:
34: while(1)
35: {
36: status = HDLC_Status_R();
37: status = status >> 2;
C:0x006A 3188 ACALL C:0188
C:0x006C 13 RRC A
C:0x006D 13 RRC A
C:0x006E 543F ANL A,#0x3F
C:0x0070 FF MOV R7,A
38: status = status & 0x03;
C:0x0071 530703 ANL 0x07,#0x03
39: if(status == TxEMPTY)
C:0x0074 BF020D CJNE R7,#0x02,C:0084
40: {
41: TXX = 0;
C:0x0077 C2B4 CLR T0(0xB0.4)
42: HDLC_Transmit();
C:0x0079 31AC ACALL HDLC_Transmit(C:01AC)
Bye
Hello
I have a problem with keil in this project ,please read this code and find the problem,my guess is that code optimization levels may produce the bug.
Open this project in keil 7.06:
State 1:
compile it with this options: AT89C52(use extended linker and assembler LX51 AX51),code optimization in level 8,remove tick of linker code packing.
go to debug mode and open disassembly window and c:0x0142 you can see that MT9092_Rd returns byte in R7 and the main program use it as status varible.
there is no problem and everything goes well.
exit debug mode.
---------------------------------------------------------------------------------------------------------------
State 2:
compile it with this options: AT89C52(use extended linker and assembler LX51 AX51),add tick of linker code packing,code optimization in level 11.
go to debug mode and open disassembly window and c:0x006A you can see that MT9092_Rd returns byte in R7 and the main program doe not use it as status varible.the return value of MT9092_Rd function in R7 (status variable in main
function) does not used and missed!
This is my problem,please help me to solve it.
------------------------------------------------------------------------------------------------------------------
Only this part of code is under verify:
at main fuction,return value of HDLC_Status_R() as status variable.
while(1)
{
status = HDLC_Status_R();
status = status >> 2;
status = status & 0x03;
if(status == TxEMPTY)
{
TXX = 0;
HDLC_Transmit();
---------------------------------------------------------------------------
State 1 disaasembly:
34: while(1)
35: {
36: status = HDLC_Status_R();
C:0x0136 7F04 MOV R7,#0x04
C:0x0138 120159 LCALL MT9092_Rd(C:0159)
37: status = status >> 2;
C:0x013B EF MOV A,R7
C:0x013C 13 RRC A
C:0x013D 13 RRC A
C:0x013E 543F ANL A,#0x3F
C:0x0140 FF MOV R7,A
38: status = status & 0x03;
C:0x0141 530703 ANL 0x07,#0x03
39: if(status == TxEMPTY)
C:0x0144 BF020E CJNE R7,#0x02,C:0155
40: {
41: TXX = 0;
C:0x0147 C2B4 CLR T0(0xB0.4)
42: HDLC_Transmit();
C:0x0149 1201D9 LCALL HDLC_Transmit(C:01D9)
---------------------------------------------------------------------------
State 2 disaasembly:
34: while(1)
35: {
36: status = HDLC_Status_R();
37: status = status >> 2;
C:0x006A 3188 ACALL C:0188
C:0x006C 13 RRC A
C:0x006D 13 RRC A
C:0x006E 543F ANL A,#0x3F
C:0x0070 FF MOV R7,A
38: status = status & 0x03;
C:0x0071 530703 ANL 0x07,#0x03
39: if(status == TxEMPTY)
C:0x0074 BF020D CJNE R7,#0x02,C:0084
40: {
41: TXX = 0;
C:0x0077 C2B4 CLR T0(0xB0.4)
42: HDLC_Transmit();
C:0x0079 31AC ACALL HDLC_Transmit(C:01AC)
Bye