Joining 5 bit variables and splitting them into 8 bit ones later?


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    Well, I'm designing fonts for last 30 years, so no surprise mine is better
    proof of concept of what?
    Any code was posted?

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


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    basically this , modded slightly for the 4x8 font
    http://www.picbasic.co.uk/forum/showthread.php?t=24171
    Warning I'm not a teacher

  3. #3
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    And this is proof of my code working
    So if I understood correctly, there is no HSHIFTOUT statement, like HSEROUT ?

    Name:  proof.jpg
Views: 3743
Size:  232.0 KB

  4. #4
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    But I still have an issue - why reading from a bit array from arbitrary position (not byte justified) returns garbage?

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,643


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    why reading from a bit array from arbitrary position (not byte justified) returns garbage?
    a minimal, complete and verifiable example MCVE
    https://stackoverflow.com/help/minim...ucible-example


    here is one that shows no problem at all pbp3, examination of lst file confirms reservation of the 4 bytes required for the bit array
    if there was ever any doubt
    Code:
    ; pbp3 16f1825
    define OSC 32  
    #CONFIG
                 __config        _CONFIG1,    _FOSC_INTOSC & _CP_OFF & _WDTE_OFF &  _PWRTE_ON  &  _MCLRE_ON  & _CLKOUTEN_OFF
                  __config      _CONFIG2, _PLLEN_ON & _LVP_OFF
    #ENDCONFIG
    
    
    DEFINE DEBUG_REG PORTA
    DEFINE DEBUG_BIT 0      
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 0    
       
        
     
       OSCCON=$70
       ANSELA=0
       ANSELC=0
       
       barray var bit[32]
       bbyte var byte ext
       another var word
       cnt var byte
       tst var bit
       more var byte
    @bbyte = PBA01
        clear
       
       
        bbyte[0]=5 
        bbyte[1]=$55  
        
        lata.0=1
        pause 2000
        Debug "Start",13 ,10 
        for cnt=31 to 0      step -1
            Debug #barray[cnt]
        next
        Debug " array by bit",13 ,10
        for cnt =3  to 0      step -1
            Debug bin8 bbyte[cnt]
        next
      
        barray[11] =1
        Debug " array by byte in bin",13,10,"set bit 11",13 ,10
        for cnt=31 to 0      step -1
            Debug #barray[cnt]
        next
        Debug 13 ,10
        for cnt =3  to 0      step -1
            Debug bin8 bbyte[cnt]
        next
       
        bbyte[3] =255
        Debug 13 ,10,"set byte 3",13 ,10
        for cnt=31 to 0      step -1
            Debug #barray[cnt]
        next
        Debug 13 ,10
        for cnt =3  to 0      step -1
            Debug bin8 bbyte[cnt]
        next
        
           barray[11] =0
        Debug 13 ,10,"clr bit 11",13 ,10
        for cnt=31 to 0      step -1
            Debug #barray[cnt]
        next
        Debug 13 ,10
        for cnt =3  to 0      step -1
            Debug bin8 bbyte[cnt]
        next
       
        bbyte[3] =0
        Debug 13 ,10,"clr byte 3",13 ,10
        for cnt=31 to 0      step -1
            Debug #barray[cnt]
        next
        Debug 13 ,10
        for cnt =3  to 0      step -1
            Debug bin8 bbyte[cnt]
        next
    printout

    Start
    00000000000000000101010100000101 array by bit
    00000000000000000101010100000101 array by byte in bin
    set bit 11
    00000000000000000101110100000101
    00000000000000000101110100000101
    set byte 3
    11111111000000000101110100000101
    11111111000000000101110100000101
    clr bit 11
    11111111000000000101010100000101
    11111111000000000101010100000101
    clr byte 3
    00000000000000000101010100000101
    00000000000000000101010100000101
    Last edited by richard; - 6th January 2021 at 06:16.
    Warning I'm not a teacher

  6. #6
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Joining 5 bit variables and splitting them into 8 bit ones later?

    Will take a look tomorrow...
    Meanwhile, added decimal point, C and F sign support...

Similar Threads

  1. 32 Bit NEC IR Constants/Variables
    By Zebryk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd July 2013, 14:51
  2. Joining variables and displaying on an LCD
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th April 2009, 04:12
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 07:23
  4. How to tell which PICs can handle 16 bit variables?
    By MikeTamu in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st August 2005, 08:44
  5. Bit variables... typo?
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th November 2004, 18:11

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