Jump to content


Photo

Pic16 Boostc Far Array Indexing Error

array index pic16 boostc

No replies to this topic

#1 Albert

Albert

    Newbrie

  • Members
  • 3 posts

Posted 29 March 2017 - 03:44 PM

Hi,

 

I found that the index of a far array is only calculated with an 8-bit addition without considering the overflow.

You will find a code example and the resulting assembler file in the attachment.

I think this is an error, at least in the documentation this is not mentioned.

 

Best regards,

 

PS attaching a .asm or .casm don't work, so you will find it below:

 

#include "PIC16F1847.h"
 
unsigned char uc_arr[192] @0x2270;
 
void main(void)
 
{
unsigned char cnt;
 
for(cnt = 0; cnt < 192; cnt++) {
0004  0020   MOVLB 0x00
0005  01A0   CLRF main_1_cnt
0006        label1
0006  30C0   MOVLW 0xC0
0007  0220   SUBWF main_1_cnt, W
0008  1803   BTFSC STATUS,C
0012  0AA0   INCF main_1_cnt, F
0013  2806   GOTO label1
 
uc_arr[cnt] = cnt;
000A  3022   MOVLW HIGH(gbl_uc_arr)
 
000B  0085   MOVWF FSR0H
000C  3070   MOVLW LOW(gbl_uc_arr+D'0')
000D  0084   MOVWF FSR0L
000E  0820   MOVF main_1_cnt, W
000F  0784   ADDWF FSR0L, F
0010  0820   MOVF main_1_cnt, W
0011  0080   MOVWF INDF0
 
}
}
0009  0008   RETURN
 
 
////////////////////////////////////////
// Code with no source :-)
////////////////////////////////////////
0000  2814   GOTO _startup
 
0014        _startup
0014  3180   MOVLP 0x00
0015  2804   GOTO main
 

 

Attached Files





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users