I am trying to encode an ARM architecture branch instruction into a printout (converting a 32-bit number to an assembly). For branch instructions. I need to increase the signed_immed_24 value to 32 bits and shift it to the left to get the value for the assembly code.
Currently an unsigned integer. I was wondering if anyone has any helpful tips for converting it to a signed integer, converting 9991764 to -6785452. And then logically moving to the left to give the final answer -27141808
32-bit data is contained in a specific data structure.
typedef struct { uint32_t in; int cnd; char *cndbits; char *cndname; int IOO; char *IOObits; char *IOOname; int L; char *Lbits; char *Lname; int im; char *imbits; char *imname; } arm_b;
Where im is the integer value to be converted.
This is a function that (at work) prints assembly code.
void print_b_ass(arm_b *b_instr) { printf("\t B 0x3e61d950 <PC + -27141808 (-6785452 << 2)>\n\n"); }
source share