hi guys
im working on making a program where u get given a machine code. The first 6 bits are the opcode, the next 5 bits is the source register, the next 5 bits is destination register and the last 16bits is the immediate.
What we have to do is take the value of the immediate and add it to the value on the source register, which is given to us. I know how to isolate the 16bits on the 32bit instruction, by shitfting it 16bits left the shifting it 16bits right again. But apparently i have to sign extend this number coz im adding to a 32 bit register which is the source register. Any ideas on how to do this? Very confused..
thanks