0

I'm working on some 65802 code (don't ask :P) and I need to separate a 16-bit value into two 8-bit bytes to store it in memory. How would I go about this?

EDIT:

Also, how would I take two similar bytes and combine them into one 16-bit value?

EDIT:

To clarify, many of the solutions available on the internet are not possible with the programming language I'm using (a version of MS-BASIC). I can't take modulo, and I can't left or rightshift. I've figured out that I can put the two bytes together by multiplying the high byte by 256 and adding it to the low byte, but how would I reverse the process?

Schilcote
  • 2,344
  • 1
  • 17
  • 35
  • It's not, actually, I'm working with the Redpower Control 65EL02 modded into Minecraft. Anyway, I think I figured it out: Multiply the high byte by 256 and add the low byte to get the short, and divide the short by 256, to get the high byte and subtract the high byte from the short to get the low byte. – Schilcote Oct 21 '12 at 13:26
  • In some BASIC dialects bitwise operators are available, I had pne, where AND/OR/NOT worked bitwise. In that case (lobyte = word AND 255) may be an alternative to (lobyte = word - (highbyte*256)) – guidot Dec 21 '12 at 08:38

0 Answers0