converting values

Started by
2 comments, last by Wilhelm van Huyssteen 15 years, 3 months ago
hey. im currently fooling around with emulation. more specifick im trying to emulate the Chip-8 that was used long ago to power some of the first game consoles anyway. im at a point where i have 2 sequential bytes in a array and of those 2 bytes i need to get the decimal value of the last 12 bits. in other words i want to ignore the first 4 bits of the first byte. now this sounds pretty simple but i need this to be as fast as possible and im not quite sure how to do this properly since im not used to such low level stuff. im writing this thing in java but i dont mind a c/c++ explanation thnx in advance
Advertisement
Is this an 8bit processor your are playing with?
Do you have a bit format table for 2byte decimals?
In C/C++ the smallest decimal is of type 'float'
which is four bytes in size.
The only way to do it in these languages is to
use a 2byte value with some fancy masks/shifts.
sixteen_bit_value = (first_byte << 8) + second_byte;twelve_bit_value = sixteen_bit_value & 0x3f;


EDIT: I don't know why you think you need the "decimal value" of this number. You probably don't.
thnx for the reply.. yes i dont "need" the decimal value i just want it :p just to c if its working at least

This topic is closed to new replies.

Advertisement