Split a WORD into 2 BYTES?
TC
Posts: 1,019
I need to find a way to split a word into 2 bytes, a high byte, and a low byte.
Thanks
TC
Thanks
TC

Comments
Just trying to get a hang of it.
K,
Also, Oh Wow!
But...
Would you expand on that some?
Perhaps with an example or two?
CON _clkmode = XTAL1|PLL16X _xinfreq = 5_000_000 OBJ serial: "FullDuplexSerial" PUB null : n serial.start(31, 30, %0000, 115200) waitcnt(clkfreq*3 + cnt) ' expected output 80000000 7FFFFFFF n := NEGX repeat 2 serial.hex(n.word[1], 4) ' high word serial.hex(n.word[0], 4) ' low word n-- serial.tx(32) serial.tx(13) ' Using table instead ... 7FFFFFFE serial.hex(table.word[(@n - @table)/2 +1], 4) ' high word serial.hex(table.word[(@n - @table)/2 +0], 4) ' low word serial.tx(13) ' expected output BA98 FEDC 3210 7654 FFFF FFFF 4567 0123 CDEF 89AB repeat n from -4 to 5 serial.hex(table.word[n], 4) ' print all words surrounding table serial.tx(32) serial.tx(13) ' access/print clkfreq ' ' With table being at address A we have to go back A bytes or A/2 words. serial.hex(table.word[-@table/2 +1], 4) ' high word serial.hex(table.word[-@table/2 +0], 4) ' low word serial.tx(13) DAT long $FEDCBA98, $76543210 ' -3/-4, -1/-2 table long -1 ' +1/+0 long $01234567, $89ABCDEF ' +3/+2, +5/+4 DATI'll get on this in the morning.
Thank you. sir.