Incrementing Upper Nibble Only (HighNibble)


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2013
    Posts
    41

    Default Incrementing Upper Nibble Only (HighNibble)

    Hello Again,

    How does one increment only the upper nibble of a byte?

    Apparently there is no HighNibble or LowNibble function in PICBASIC?

    My goal is to add 1, to the value of Bits [7654] leaving Bits [3210] alone.

    And/or how to set just the high bits to some number?

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default Re: Incrementing Upper Nibble Only (HighNibble)

    number var byte
    number=number+16 will increment high nibble

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: Incrementing Upper Nibble Only (HighNibble)

    how to set just the high bits to some number?
    number var byte
    somenumber var byte

    number =$11
    somenumber =2

    number =(number&$f) |( somenumber<<4 );note (for a meaningful result somenumber <16)

    result number=$21
    Last edited by richard; - 6th March 2015 at 21:37. Reason: add some more brackets just in case

  4. #4
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: Incrementing Upper Nibble Only (HighNibble)

    Richard,

    Wonderful! Works beautifully!

    number var byte
    number=number+16 will increment high nibble

    Again, very clean and easy.

    Thank you very much!

    Jay Zebryk
    Zebryk Engineering
    Southbridge, Massachusetts
    www.zebryk.com

Similar Threads

  1. 32 bit seconds math (how do I include the upper 16 bits?)
    By Heckler in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 5th February 2015, 03:46
  2. Combining 4 nibble to 16bits
    By isaac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th November 2006, 21:40
  3. Accessing the upper 64Kbytes with READCODE
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th March 2006, 21:22
  4. Incrementing Help
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st April 2005, 21:57
  5. writecode at upper half of 128K parts?
    By Tomasm in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd November 2004, 19:02

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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