Tables of Signed Integers

  • Thomas Henry
    Thomas Henry

    Hi Gang,

    Could someone please put me out of my misery on this? It appears that a Table consisting of signed integers doesn't compile correctly under some circumstances. If you get a chance, try compiling this code (you don't have to burn it to a PIC--just see if the .asm file looks correct):

    #chip 16F88, 4              ;PIC16F88 running at 4 MHz
    #config mclr=off            ;reset handled internally
    #config osc=int             ;use internal clock
    ;************************ Constants ************************
    #define LCD_IO 4            ;4-bit mode
    #define LCD_RS      PortB.0 ;LCD Register Select on pin 6
    #define LCD_Enable  PortB.1 ;LCD Enable on pin 7
    #define LCD_DB4     PortB.2 ;DB4 on pin 8
    #define LCD_DB5     PortB.3 ;DB5 on pin 9
    #define LCD_DB6     PortB.4 ;DB6 on pin 10
    #define LCD_DB7     PortB.5 ;DB7 on pin 11
    #define LCD_NO_RW   1       ;ground the RW line on LCD
    ;************************ Variables ************************
    dim signed as integer 
    table dataI                 ;signed integer data
    end table
    ;********************** Main Program **********************
    print "Integer data"
    for i = 1 to 7
      readTable dataI, i, signed
      locate 1,0
      print "               "
      locate 1,0
      print signed                  ;show on LCD
      wait 1 S
    next i

    It seems that the high bytes (signed integers take up two bytes) don't get compiled if all of the integers have absolute values that are less than 256.

    But if you change any one of the integers in the code to something greater than or equal to 256 then both the high and low bytes get compiled okay. For example, change the -1 to -1000 in the above and notice how it compiles properly.

    Would someone be willing to try compiling this? I'm just curious if it's me or Great Cow Basic!


    Thomas Henry

  • Edward LaBudde
    Edward LaBudde

    Hi Thomas, as far as I know the Tables accept positive integers only.  Ran into the same problem myself sometime back.  Ed.

  • Thomas Henry
    Thomas Henry

    Thanks for the comment, Ed.

    However, that's not what my experiment (see above) shows. If I compile it as is, then the high bytes are not accounted for (which includes the sign bit). But if I make the absolute value of any one of the integers greater than 255, then both the high and low bytes are compiled properly, even for the negative integers.

    So, again, could someone please try this experiment (it'll only take a minute) and see if you get the same results?

    Many thanks,

    Thomas Henry