Menu

10F200 and lookup tables

2006-11-09
2013-05-30
  • Stefano Delfiore

    I tried this code:
    '-----------------------
    #chip 10F200, 4
    #mem 16
    #config  _MCLRE_OFF & _CP_OFF &  _WDT_OFF & _IntRC_OSC

    readtable test,1,val1

    TABLE test
    b'00000100'
    b'00000001'
    b'00000100'
    END TABLE
    '------------------------

    the assembler that I got is:

    ;Program compiled by GCBASIC, which is the best language for PICs, ever!
    ;Something not working? Email me at hconsidine@bigpond.com
    ;GCBASIC Version: 0.9 7/11/2006

    ;********************************************************************************

    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
    LIST p=10F200, r=DEC
    #include <P10F200.inc>
    __CONFIG _MCLRE_OFF&_CP_OFF&_WDT_OFF&_INTRC_OSC

    ;********************************************************************************

    ;Set aside memory locations for variables
    DataPointer    equ    16
    VAL1    equ    17

    ;********************************************************************************

    ;Jump to initialisation code when PIC is reset
        ORG    0
        call    INITSYS
        goto    SystemInitialise

    ;********************************************************************************

    ;Various initialisation routines, automatically called by GCBASIC
    SystemInitialise

    ;********************************************************************************

    ;Start of the main program
        movlw    1
        call    TEST
        movwf    VAL1
    BASPROGRAMEND       
        sleep   
        goto    $
           
    ;********************************************************************************
           
    ; Data Lookup Tables
    TEST       
        bcf    STATUS, C
        addlw    1
        addlw    low TableTEST
        movwf    DataPointer
        movlw    high TableTEST
        btfsc    STATUS, C
        addlw    1
        movwf    PCLATH
        movf    DataPointer, W
    TableTEST       
        movwf    PCL
        retlw    3
        retlw    4
        retlw    1
        retlw    4
        return   
           
    ;********************************************************************************
    ;Subroutines included in program
    ;********************************************************************************
           
    InitSys       
        return   
           
    ;********************************************************************************

    END

    In the assembler there is the opcode "addlw" that is not in the instruction set of 10F200, then there is the special function register PCLATH that 10F200 doesn't have.
    So I get some errors from compiler (gputils)

    ---------- Capture Output ----------
    > "C:\Programmi\GCBASIC_eng\COMPILE.BAT" C:\Programmi\GCBASIC\10F200-02.txt
    Great Cow BASIC (0.9 7/11/2006)

    Compiling C:\Programmi\GCBASIC\10F200-02.txt ...

    Program compiled successfully!

    Assembling and downloading program ...
    compiled.asm:45:Error [174] Unknown opcode "addlw"
    compiled.asm:46:Error [174] Unknown opcode "addlw"
    compiled.asm:50:Error [174] Unknown opcode "addlw"
    compiled.asm:51:Error [113] Symbol not previously defined (PCLATH).

    > Terminated with exit code 0.

    Ciao
    Stefano

     
    • Hugh Considine

      Hugh Considine - 2006-11-19

      GCBASIC has been fixed so that it can detect the chip family it is compiling for (12-bit or 14-bit instruction width), and add the correct type of lookup table. When compiling for 12 bit chips such as the 10F series, it only uses addwf PCL, F for the calculated goto, not addlw or PCLATH. The update is available from http://gcbasic.sourceforge.net/newfiles/update.zip

      The update also fixes a bug that you mentioned in another post - GCBASIC will now warn if too much memory is used.

       
    • Stefano Delfiore

      Thank you very much!

      Stefano

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.