Menu

Word Variable Low Byte and GPR's

kent_twt4
2009-03-07
2013-05-30
  • kent_twt4

    kent_twt4 - 2009-03-07

    My mind gets all messed up when thinking about the memory organization of the PIC, so forgive me if this is off track.  Trying to port some assembly code that uses a lot of 16 bit/word variables, and its been a struggle.

    In GCBasic it would be nice to deal with the Low byte of a word variable by being able to address its particular general purpose register, just as you would say, WordVariable_H.  So like in assembler, using WordVariable_L would reduce unnecessary math (deconstruction of the word) and dummy variables (ram).  With the current GCBasic interpretation, WordVariable is the Low byte in the GPR's.  Unfortunately, the WordVariable (Low byte) also implies the 16bit/word value, when used with math operations, or Print/LCD display functions, and the like.

    Comments?

     
    • Santiago

      Santiago - 2009-03-08

      I agree with the idea.

      It could be very useful when the word variables created in the asm code where called: "variable_L" and "variable_H", then we could use "variable" for the whole word variable, "variable_L" for the low byte and "variable_H" for the high byte.

      Now in the generated asm there are: "variable" for low byte and "variable_H" for high byte; is possible managing low byte from GCBasic, but using asm instrucctions...

       
      • Hugh Considine

        Hugh Considine - 2009-03-15

        There is a way to do this manually, but it's not properly documented yet. You can use an alias to combine 2 byte variables into a word, like so:

        Dim BigVar As Word Alias HighByte, LowByte

        HighByte = 2
        LowByte = 100

        if BigVar = 612 Then something

         
    • kent_twt4

      kent_twt4 - 2009-03-08

      Yes of course, can see now, that using the banksel asm instruction could be a solution.  Assembly.... still learning....:-).

      Well, its possible using the "variable" as the low byte register has its advantages.  Say like, when the compiler is parsing out the GCBasic commands.  I try not to think about that, or more like, avoid thinking about that.

       
    • kent_twt4

      kent_twt4 - 2009-03-15

      Weirdness happening with the forum postings being out of order.

      Thanks Hugh, the Alias high and low bytes will work just great.  Vague memory of seeing that in a-d.h, now that you have mentioned it.

       

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.