CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Bug in table read with large tables ...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mpfj



Joined: 09 Sep 2003
Posts: 95
Location: UK

View user's profile Send private message Send e-mail Visit poster's website

Bug in table read with large tables ...
PostPosted: Mon Feb 02, 2004 8:46 am     Reply with quote

I'm sure people have come across this before, but it still appears to be present in version 3.184 (with a PIC18F8720)

In the code below, I'm printing some text using two different methods ... one looks up each character and calls the "putch" routine, the other calls a "print string" routine.

The first version works fine, the second fails horribly ... because ...

... just before the line that reads "CALL 1000", the register 0xFF7 (TBLPTRH) is initialised by the first method, but *not* by the second !! Shocked

Code:

....................    // display item text 
....................    for (j = 0; (c = setup_item_text[i][j]) != 0x00; j++) { 
6C8C:  MOVLB  A
6C8E:  CLRF   xFC
6C90:  MOVLB  B
6C92:  CLRF   x8C
6C94:  MOVLB  0
6C96:  MOVFF  AFB,B8B
6C9A:  MOVLB  B
6C9C:  CLRF   x8E
6C9E:  MOVLW  19
6CA0:  MOVWF  x8D
6CA2:  MOVLB  0
6CA4:  CALL   1C5A
6CA8:  MOVFF  02,B01
6CAC:  MOVFF  01,B00
6CB0:  MOVLB  A
6CB2:  MOVF   xFC,W
6CB4:  MOVLB  B
6CB6:  ADDWF  01,W
6CB8:  MOVWF  01
6CBA:  MOVLW  00
6CBC:  ADDWFC 02,W
6CBE:  MOVWF  03
6CC0:  MOVF   01,W
6CC2:  MOVLB  0
6CC4:  MOVFF  FF2,B02
6CC8:  BCF    FF2.7
6CCA:  MOVFF  03,FF7
6CCE:  CALL   1000             <----- this calls the table read function
6CD2:  MOVLB  B
6CD4:  BTFSC  x02.7
6CD6:  BSF    FF2.7
6CD8:  MOVWF  01
6CDA:  MOVLB  0
6CDC:  MOVFF  01,AFD
6CE0:  MOVLB  A
6CE2:  MOVF   xFD,F
6CE4:  BTFSC  FD8.2
6CE6:  GOTO   6CFC
....................       display_putch(c); 
6CEA:  MOVLB  0
6CEC:  MOVFF  AFD,B77
6CF0:  CALL   22FE
....................    } 
6CF4:  MOVLB  A
6CF6:  INCF   xFC,F
6CF8:  GOTO   6C90
....................     
....................    display_put_string(setup_item_text[i]); 
6CFC:  MOVLB  B
6CFE:  CLRF   x8C
6D00:  MOVLB  0
6D02:  MOVFF  AFB,B8B
6D06:  MOVLB  B
6D08:  CLRF   x8E
6D0A:  MOVLW  19
6D0C:  MOVWF  x8D
6D0E:  MOVLB  0
6D10:  CALL   1C5A
6D14:  MOVFF  02,03
6D18:  MOVF   01,W
6D1A:  MOVLB  B
6D1C:  MOVWF  x00
6D1E:  MOVLB  0
6D20:  MOVFF  B00,B01
6D24:  MOVLB  B
6D26:  MOVF   x01,W
6D28:  MOVLB  0
6D2A:  CALL   1000             <----- this calls the table read function
6D2E:  IORLW  00
6D30:  BTFSC  FD8.2
6D32:  GOTO   6D48
6D36:  MOVLB  B
6D38:  INCF   x01,F
6D3A:  CLRF   x19
6D3C:  MOVWF  x18
6D3E:  MOVLB  0
6D40:  CALL   5DB8
6D44:  GOTO   6D24


In fact, I've just experminented with some code and found the breaking point. I haven't tested these, but consider the two pieces of code below ...

First, set the second array dimension to 0x80 and ... tada ... a "CLRF FF7" instruction is created.

Code:

const char setup_test_text[2][0x080] = {
   "12345678901234567890",
   "12345678901234567890"
};

0FF0:  MOVFF  FF2,0E
0FF4:  BCF    FF2.7
0FF6:  CLRF   FF7
0FF8:  ADDLW  0E
0FFA:  MOVWF  FF6
0FFC:  MOVLW  10
0FFE:  ADDWFC FF7,F
1000:  MOVLW  00
1002:  MOVWF  FF8
1004:  TBLRD*+
1006:  MOVF   FF5,W
1008:  BTFSC  0E.7
100A:  BSF    FF2.7
100C:  RETURN 0

....................    display_put_string(setup_test_text[i]); 
6E2A:  MOVLB  B
6E2C:  CLRF   x8C
6E2E:  MOVLB  0
6E30:  MOVFF  AFB,B8B
6E34:  MOVLB  B
6E36:  CLRF   x8E
6E38:  MOVLW  80
6E3A:  MOVWF  x8D
6E3C:  MOVLB  0
6E3E:  CALL   1D34
6E42:  MOVFF  02,03
6E46:  MOVF   01,W
6E48:  MOVLB  B
6E4A:  MOVWF  x00
6E4C:  MOVLB  0
6E4E:  MOVFF  B00,B01
6E52:  MOVLB  B
6E54:  MOVF   x01,W
6E56:  MOVLB  0
6E58:  CALL   0FF0
6E5C:  IORLW  00
6E5E:  BTFSC  FD8.2
6E60:  GOTO   6E76
6E64:  MOVLB  B
6E66:  INCF   x01,F
6E68:  CLRF   x19
6E6A:  MOVWF  x18
6E6C:  MOVLB  0
6E6E:  CALL   5E9A
6E72:  GOTO   6E52


Now if we change the dimension to 0x81 ... whoops ... the FF7 register does not get set up !!

Code:

const char setup_test_text[2][0x081] = {
   "12345678901234567890",
   "12345678901234567890"
};

0FF0:  MOVFF  FF2,0E
0FF4:  BCF    FF2.7
0FF6:  ADDLW  0C
0FF8:  MOVWF  FF6
0FFA:  MOVLW  10
0FFC:  ADDWFC FF7,F
0FFE:  MOVLW  00
1000:  MOVWF  FF8
1002:  TBLRD*+
1004:  MOVF   FF5,W
1006:  BTFSC  0E.7
1008:  BSF    FF2.7
100A:  RETURN 0

....................    display_put_string(setup_test_text[i]); 
6E2A:  MOVLB  B
6E2C:  CLRF   x8C
6E2E:  MOVLB  0
6E30:  MOVFF  AFB,B8B
6E34:  MOVLB  B
6E36:  CLRF   x8E
6E38:  MOVLW  81
6E3A:  MOVWF  x8D
6E3C:  MOVLB  0
6E3E:  CALL   1D34
6E42:  MOVFF  02,03
6E46:  MOVF   01,W
6E48:  MOVLB  B
6E4A:  MOVWF  x00
6E4C:  MOVLB  0
6E4E:  MOVFF  B00,B01
6E52:  MOVLB  B
6E54:  MOVF   x01,W
6E56:  MOVLB  0
6E58:  CALL   0FF0
6E5C:  IORLW  00
6E5E:  BTFSC  FD8.2
6E60:  GOTO   6E76
6E64:  MOVLB  B
6E66:  INCF   x01,F
6E68:  CLRF   x19
6E6A:  MOVWF  x18
6E6C:  MOVLB  0
6E6E:  CALL   5E9A
6E72:  GOTO   6E52


Am I doing something wrong, or have CCS still not got table lookup sorted out properly ?

Regards
Mark
mpfj



Joined: 09 Sep 2003
Posts: 95
Location: UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Feb 27, 2004 3:40 am     Reply with quote

This has been fixed in 3v186
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group