1. Not sure why you are concatenating and calculating offsets at the time of parsing.
You need to do that in part1.c which is where you are printing.
2. It appears to me your sign extension is broken.
e.g., lets say offset is 0x800 (12 bit sign to be sign extended)
You will be calculating
line 10 sign = 0x1
line 11 0x100,,, (followed by 31 0s)
line 12 0x00001(13thbit)000000 (you are doing unsigned shifts so 0s are going to come in from the left)
.....
All you seem to be doing is sign extending by 1 bit.