In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: Here's a collection of similar routines that I use for sending values to a PC: [code]' Use: TX_BYTE theByte ' -- transmit "theByte" at "Baud" on "TX" SUB TX_BYTE tmpB1 = __PARAM1 ' get byte to send SEROUT TX, Baud, tmpB1 ENDSUB ' ------------------------------------------------------------------------- ' Use: TX_STR [string | label] ' -- "string" is an embeded string constant ' -- "label" is DATA statement label for stored z-String SUB TX_STR tmpW1 = __WPARAM12 ' get base+offset DO READINC tmpW1, tmpB1 ' read a character IF tmpB1 = 0 THEN EXIT ' if 0, string complete TX_BYTE tmpB1 ' send character LOOP ENDSUB ' ------------------------------------------------------------------------- ' Use: TX_BIN8 theByte ' -- transmits value of "theByte" in BIN8 format SUB TX_BIN8 tmpB2 = __PARAM1 ' get byte to send FOR tmpB3 = 1 TO 8 ' loop through eight bits IF tmpB2.7 = 1 THEN ' if MSB is set TX_BYTE "1" ' send "1" ELSE ' else TX_BYTE "0" ' send "0" ENDIF tmpB2 = tmpB2 << 1 ' shift next bit to MSB NEXT ENDSUB ' ------------------------------------------------------------------------- ' Use: TX_HEX2 theByte ' -- transmits value of "theByte" in HEX2 format SUB TX_HEX2 tmpB2 = __PARAM1 ' get byte to send tmpB3 = tmpB2 ' make copy SWAP tmpB3 ' swap hi/lo tmpB3 = tmpB3 & $0F ' mask to isolate hi READ Hex_Digits + tmpB3, tmpB1 TX_BYTE tmpB1 ' send hi nib tmpB2 = tmpB2 & $0F ' mask to isolate lo READ Hex_Digits + tmpB2, tmpB1 TX_BYTE tmpB1 ENDSUB Hex_Digits: DATA "0123456789ABCDEF"[/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=190314#m190582 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)