HOW DOES PBP handle bits varables to bytes


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: HOW DOES PBP handle bits varables to bytes

    Hi,
    I've looked at this and although I'm not that good at assembly here how I believe it works.
    When you create a BIT variable the compiler allocates a BYTE of RAM and calls it PB1, your bit variable is then defined as the first bit in that byte. When you create a second BIT variable it gets defined as the second bit in the previously allocated BYTE (ie still only a single byte). When you create the 9th BIT variable a new BYTE is allocated (PB2) and so on. So, one BIT variable takes 1 BYTE but 8 bit variables still only takes ONE byte.

    Basically, this is what it looks like in the assembly listing:
    Code:
    00081 PB01                            EQU     RAM_START + 019h
    00083 PB02                            EQU     RAM_START + 01Ah
    00092 #define _myBit1                  PB01, 000h
    00093 #define _myBit2                  PB01, 001h
    00094 #define _myBit3                  PB01, 002h
    00095 #define _myBit4                  PB01, 003h
    00096 #define _myBit5                  PB01, 004h
    00097 #define _myBit6                  PB01, 005h
    00098 #define _myBit7                  PB01, 006h
    00099 #define _myBit8                  PB01, 007h
    00100 #define _myBit9                  PB02, 000h
    As you can see, for 9 BIT variables only TWO bytes of RAM is allocated - thankfully and as expected.

    /Henrik.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,686


    Did you find this post helpful? Yes | No

    Default Re: HOW DOES PBP handle bits varables to bytes

    that's good to know , after misreading the manual at some stage I have been micro-managing bit vars needlessly for years .

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: HOW DOES PBP handle bits varables to bytes

    Good question and answers!
    Like Richard, I have also been doing the same when it was already taken care of.
    Louie

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 08:55
  2. Configuation bits setting in PBP
    By Max_Gauss in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th September 2010, 19:25
  3. Pickit 2 saving varables?
    By jessey in forum Off Topic
    Replies: 5
    Last Post: - 7th June 2010, 10:14
  4. 16/32 bits PIC support in PBP?
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2010, 16:40
  5. Bits & Bytes
    By electronicsuk in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th April 2006, 12:52

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts