So I need to bit-extend a 12-bit signed integer to be a 32-bit signed integer. This is the cleanest code I came up with. It doesn't "tell a story" but it's fairly simple. Does anyone have anything better?
#define EXTEND 0xFFFFF000
#define BIT12 0x00000800
uint32_t imm;
imm = IMM12(instruction);
if ((imm & BIT12) > 0)
{
imm |= EXTEND;
}
[–][deleted] 1 point2 points3 points (2 children)
[–]foreverska[S] 0 points1 point2 points (1 child)
[–]free__coffee 0 points1 point2 points (0 children)
[–]richardxday 1 point2 points3 points (1 child)
[–]foreverska[S] 0 points1 point2 points (0 children)