invert byte and display


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37

    Default invert byte and display

    Hello,

    I'm simply trying to invert a byte and display it. earlier in the code, I have already verified that the byte contains %01010000, which is 'AF' in hex, inverted. I just want to see 'AF' displayed in Hyperterminal.

    my code goes like this.

    Code:
     
    DEBUG REP $00\8,13,10,"Before inversion, binary"
    DEBUG BIN DIAGNBYTE
    DEBUG REP $00\8,13,10,"Hex"
    DEBUG HEX DIAGNBYTE
    
    DIAGNBYTE = NOT DIAGNBYTE    	'invert 
    
    DEBUG REP $00\8,13,10,"AFTER inversion:"
    DEBUG BIN DIAGNBYTE
    DEBUG REP $00\8,13,10,"Hex"
    DEBUG HEX DIAGNBYTE

    This is what is displayed in Hyperterminal:

    Before inversion, binary1010000
    Hex50
    AFTER inversion:0
    Hex0


    Thanks for helping.

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    >>DIAGNBYTE = NOT DIAGNBYTE

    You have used a logical NOT, which returns 1 or 0. You need to use a bitwise NOT. Try

    DIAGNBYTE = ~ DIAGNBYTE
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default that was it.

    Thanks so much. that was so easy. THANK YOU!

Similar Threads

  1. Hdsp 21xx display
    By Original in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th June 2012, 20:07
  2. Help with Circuit
    By Art in forum General
    Replies: 14
    Last Post: - 23rd December 2009, 13:21
  3. How to set sequence of interrupt for PIC
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2008, 11:17
  4. select case question
    By ronjodu in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th March 2006, 10:01
  5. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47

Members who have read this thread : 1

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