I am working on a project where I need to take values contained in a hexadecimal value and split it. I will have a register that contains a value, 0xAA00BBCC and need to split it into 3 different integers, AA, BB, and CC
For example:
if the value is: 0x88000232, I need to split it into 3 integers: A: 88, B: 02, and C: 32.
How would I go about doing this?
With a combination of SRL and ANDI, but sometimes one of them is unnecessary. For example:
srl $t0, $a0, 8
andi $t0, $t0, 0xFF
This shifts the value so that the BB from 0xAA00BBCC is at the bottom (0x00AA00BB) and then the andi
resets the bits that don't belong to that BB part.
When the shift count is 24, the andi
is not needed. And of course shifting by 0 positions is not useful so in that case only the andi
is needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.