#188 please check this "goto" error

closed-rejected
nobody
1
2014-08-09
2001-10-19
Anonymous
No

// The followin is my source code
// I have a problem when it is compiled and run.
//
// The program abort before the end of the code.
// I have made comment in the following source code
//
#include "8051.h"

xdata char * data LCDWIR;
xdata char * data LCDWDR;
xdata char * data LCDRIR;
xdata char * data LCDRDR;

#define CLEAR 0x01
#define CUR_HOME 0x02
#define ENTRY2 0x06
#define DCB6 0x0e
#define FUN5 0x38
#define LINE_1 0x80
#define LINE_2 0xc0

void instrd() { // wait the resonse of LCD
again1:
if (*LCDRIR & 0x80) goto again1;
}

mov_cur(char c) { // LCD cursor position
instrd();
if(c==1) *LCDWIR = LINE_1;
else *LCDWIR = LINE_2;

}

void main() {
xdata char message1[15] = "do your best!";
xdata char message2[15] = "I can do it.";
data char i;

LCDWIR = 0xffe0;
LCDWDR = 0xffe1;
LCDRIR = 0xffe2;
LCDRDR = 0xffe3;

*LCDWIR = FUN5;
instrd();
*LCDWIR = DCB6;
instrd();
*LCDWIR = CLEAR;
instrd();
*LCDWIR = ENTRY2;

mov_cur(1);

for(i=0;i<13;i++) {

instrd();
*LCDWDR = message1[i];
}
//ERROR
//ERROR The program terminate at this point
//ERROR
mov_cur(2);

for(i=0;i<13;i++) {
instrd();
*LCDWDR = message2[i];
}
}

//----------------------------------------
// The following is the generated source code
// THE USED COMPILE OPTIONS ARE
// C:\sdcc\sdcc.exe -c --no-peep lcd.c
//
// Note the Error location is marked with ERROR.
//

_instrd:
ar2 = 0x02
ar3 = 0x03
ar4 = 0x04
ar5 = 0x05
ar6 = 0x06
ar7 = 0x07
ar0 = 0x00
ar1 = 0x01
; lcd.c 19
00103$:
; lcd.c 18
mov dpl,_LCDRIR
mov dph,(_LCDRIR + 1)
movx a,@dptr
mov r2,a
mov a,r2
jnb acc.7,00107$
ljmp 00103$
00107$:
00104$:
ret
;------------------------------------------------------
------
;Allocation info for local variables in
function 'mov_cur'
;------------------------------------------------------
------
;c Allocated to registers r2
; lcd.c 21
; -----------------------------------------
; function mov_cur
; -----------------------------------------
_mov_cur:
; lcd.c 0
mov r2,dpl
; lcd.c 22
push ar2
lcall _instrd
pop ar2
; lcd.c 23
cjne r2,#0x01,00107$
sjmp 00108$
00107$:
ljmp 00102$
00108$:
mov dpl,_LCDWIR
mov dph,(_LCDWIR + 1)
mov a,#0x80
movx @dptr,a
ljmp 00104$
00102$:
; lcd.c 24
mov dpl,_LCDWIR
mov dph,(_LCDWIR + 1)
mov a,#0xC0
movx @dptr,a
00104$:
ret
;------------------------------------------------------
------
;Allocation info for local variables in function 'main'
;------------------------------------------------------
------
;i Allocated to registers
;message1 Allocated to in memory with
name '_main_message1_1_1'
;message2 Allocated to in memory with
name '_main_message2_1_1'
; lcd.c 28
; -----------------------------------------
; function main
; -----------------------------------------
_main:
; lcd.c 29
mov dptr,#_main_message1_1_1
mov a,#0x64
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0001)
mov a,#0x6F
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0002)
mov a,#0x20
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0003)
mov a,#0x79
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0004)
mov a,#0x6F
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0005)
mov a,#0x75
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0006)
mov a,#0x72
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0007)
mov a,#0x20
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0008)
mov a,#0x62
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x0009)
mov a,#0x65
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x000a)
mov a,#0x73
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x000b)
mov a,#0x74
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x000c)
mov a,#0x21
movx @dptr,a
mov dptr,#(_main_message1_1_1 + 0x000d)
mov a,#0x00
movx @dptr,a
; lcd.c 30
mov dptr,#_main_message2_1_1
mov a,#0x49
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0001)
mov a,#0x20
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0002)
mov a,#0x63
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0003)
mov a,#0x61
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0004)
mov a,#0x6E
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0005)
mov a,#0x20
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0006)
mov a,#0x64
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0007)
mov a,#0x6F
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0008)
mov a,#0x20
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x0009)
mov a,#0x69
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x000a)
mov a,#0x74
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x000b)
mov a,#0x2E
movx @dptr,a
mov dptr,#(_main_message2_1_1 + 0x000c)
mov a,#0x00
movx @dptr,a
; lcd.c 33
mov _LCDWIR,#0xE0
mov (_LCDWIR + 1),#0xFF
; lcd.c 34
mov _LCDWDR,#0xE1
mov (_LCDWDR + 1),#0xFF
; lcd.c 35
mov _LCDRIR,#0xE2
mov (_LCDRIR + 1),#0xFF
; lcd.c 36
mov _LCDRDR,#0xE3
mov (_LCDRDR + 1),#0xFF
; lcd.c 38
mov dpl,#0xE0
mov dph,#0xFF
mov a,#0x38
movx @dptr,a
; lcd.c 39
lcall _instrd
; lcd.c 40
mov dpl,_LCDWIR
mov dph,(_LCDWIR + 1)
mov a,#0x0E
movx @dptr,a
; lcd.c 41
lcall _instrd
; lcd.c 42
mov dpl,_LCDWIR
mov dph,(_LCDWIR + 1)
mov a,#0x01
movx @dptr,a
; lcd.c 43
lcall _instrd
; lcd.c 44
mov dpl,_LCDWIR
mov dph,(_LCDWIR + 1)
mov a,#0x06
movx @dptr,a
; lcd.c 46
mov dpl,#0x01
lcall _mov_cur
; lcd.c 48
mov r2,#0x00
00101$:
clr c
mov a,r2
xrl a,#0x80
subb a,#0x8d
jc 00115$
ljmp 00104$ // ERROR
// The program terminates before end!!!
00115$:
; lcd.c 50
push ar2
lcall _instrd
pop ar2
; lcd.c 51
mov r3,_LCDWDR
mov r4,(_LCDWDR + 1)
mov a,r2
add a,#_main_message1_1_1
mov dpl,a
mov a,#0x00
addc a,#(_main_message1_1_1 >> 8)
mov dph,a
movx a,@dptr
mov r5,a
mov dpl,r3
mov dph,r4
mov a,r5
movx @dptr,a
; lcd.c 48
inc r2
ljmp 00101$
00104$:
; lcd.c 54
mov dpl,#0x02
lcall _mov_cur
; lcd.c 56
mov r2,#0x00
00105$:
clr c
mov a,r2
xrl a,#0x80
subb a,#0x8d
jc 00116$
ljmp 00109$
00116$:
; lcd.c 57
push ar2
lcall _instrd
pop ar2
; lcd.c 58
mov r3,_LCDWDR
mov r4,(_LCDWDR + 1)
mov a,r2
add a,#_main_message2_1_1
mov dpl,a
mov a,#0x00
addc a,#(_main_message2_1_1 >> 8)
mov dph,a
movx a,@dptr
mov r5,a
mov dpl,r3
mov dph,r4
mov a,r5
movx @dptr,a
; lcd.c 56
inc r2
ljmp 00105$
00109$:
ret
.area CSEG (CODE)
__str_0:
.ascii "do your best!"
.db 0x00
__str_1:
.ascii "I can do it."
.db 0x00

Discussion

  • Johan Knol
    Johan Knol
    2001-10-20

    Logged In: YES
    user_id=63512

    00104$ refers to the label in main() not to the label in
    instrd() or mov_cur().

    Suggestions:

    Keep strings in code space (without the "xdata") and
    use "xdata char *LCDWR at 0xffe0": much more efficient.

    Do your best, you can do it :)

     
  • Johan Knol
    Johan Knol
    2001-10-20

    • milestone: --> non_bugs
    • priority: 5 --> 1
    • summary: please check this "goto" error --> please check this "goto" error
    • status: open --> open-rejected
     
  • Johan Knol
    Johan Knol
    2001-10-23

    • summary: please check this "goto" error --> please check this "goto" error
    • status: open-rejected --> closed-rejected