Menu

Problems with Hex Notation

2007-01-14
2013-05-30
  • Russ Hensel

    Russ Hensel - 2007-01-14

    This program:

    ' example of problems with hex  Great Cow BASIC (0.9 12/1/2007)

    'Chip model
    #chip 16F819, 8

    #config _INTRC_CLKOUT 

    '======== begin program ====

    T_cyc_mx      = 0x'F0'

        Table A_StepperSteps
        1
        2
        0x'2'
        ox'4'
        0x'6'
        b'1111000'
        b'00001111'
        x0'4'
        Ox'9'
        End Table   

    ' ================= end prog ================

    Assembles to this ( some deletions to shorten file ) . Note that Hex variables are not correct, in the table I tried several possible notations, all result in 0's being assembled.  The assignment created a variable with the name 0X.

    ;Program compiled by Great Cow BASIC (0.9 12/1/2007)
    *****************************************************************************
    ....
    ;Set up the assembler options (Chip type, clock source, other bits and pieces)
    LIST p=16F819, r=DEC
    #include <P16F819.inc>
    __CONFIG _INTRC_CLKOUT & _WDT_OFF & _LVP_OFF & _MCLR_OFF

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

    ;Start of the main program
        movlw    0X
        movwf    T_CYC_MX
    BASPROGRAMEND       
        sleep   
        goto    $
           
    ;********************************************************************************
           
    ; Data Lookup Tables
    A_STEPPERSTEPS       
        bcf    STATUS, C
        addlw    1
        addlw    low TableA_STEPPERSTEPS
        movwf    DataPointer
        movlw    high TableA_STEPPERSTEPS
        btfsc    STATUS, C
        addlw    1
        movwf    PCLATH
        movf    DataPointer, W
    TableA_STEPPERSTEPS       
        movwf    PCL
        retlw    9
        retlw    1
        retlw    2
        retlw    0
        retlw    0
        retlw    0
        retlw    120
        retlw    15
        retlw    0
        retlw    0
        return   
           
    ......
       
           
    ;********************************************************************************

    END

    Russ

     
    • Hugh Considine

      Hugh Considine - 2007-01-14

      In GCBASIC at present, binary is represented like this:

      b'01010101'

      And hex like this:

      0xAB

      In the newest version of GCBASIC, h'AB' and 0b01010101 are also supported. The format for binary and hex numbers is something that I had forgotten to document - thanks for reminding me!

       

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.