// opt01.c // efficient linear memory access /* Copyright (C) 2016 H.Poetzl ** ** This program is free software: you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation, either version ** 2 of the License, or (at your option) any later version. */ // sdcc -mpic14 -p16f1718 --use-non-free -Wl-C opt01.c extern __at(0x010C) __sfr LATA; extern __at(0x010D) __sfr LATB; extern __at(0x010E) __sfr LATC; static volatile __data unsigned char * const cptr = (volatile __data unsigned char *)0x2000; static volatile __data unsigned char * ptr = (volatile __data unsigned char *)0x2000; static unsigned char idx = 255; // -------------------------------------------------- // main void main() { while (idx) { LATA = cptr[idx]; LATB = ptr[idx]; __asm ; inline asm version BANKSEL _idx MOVF _idx,W MOVWF FSR0L MOVLW high(0x2000) MOVWF FSR0H MOVF INDF0,W BANKSEL LATC MOVWF LATC __endasm; } }