PDA

View Full Version : Concatenating two bytes together to into a word.



Kevin Harris
02-02-2007, 06:03 AM
Is there an elegant way to take two byte variables and concatenate them into a word. For instance, I have something like...

CMD VAR Word
ByteOne VAR Byte
ByteTwo VAR Byte

ByteOne = $A1
ByteTwo = $03

Then I want CMD to = $A103. How do I go about doing that in PBasic?

Martin Hebel
02-02-2007, 06:08 AM
cmd VAR Word
HB VAR cmd.HIGHBYTE
LB VAR cmd.LOWBYTE


HB = $10
LB = $20
DEBUG IHEX4 cmd

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters (http://www.selmaware.com/)
Southern Illinois University Carbondale, Electronic Systems Technologies (http://www.siu.edu/~isat/est)

PJ Allen
02-02-2007, 09:31 AM
·CMD = ByteOne *·$100 + ByteTwo·

·???

·Update -- Scratch that.

·It works.

Post Edited (PJ Allen) : 2/2/2007 1:36:37 AM GMT