TrietPhan_FinalProject.c
// Print the correct sign of the offset while dumping memory
Print the correct sign of the offset while dumping memory
Print the correct sign of the offset while dumping memory
Word print_offset(Word value, int start, int end) {
  Word offset;
  Word sign_bit = extract_bits(value, end - 1, end);
  if(sign_bit) {
    offset = - (extract_bits(~(value), start, end) + 1);
  }
  else {
    offset = extract_bits(value, start, end);
  }
  return offset;
}
Word print_offset ( Word value , int start , int end ) { Word offset ; Word sign_bit = extract_bits ( value , end - 1 , end ) ; if ( sign_bit ) { offset = - ( extract_bits ( ~ ( value ) , start , end ) + 1 ) ; } else { offset = extract_bits ( value , start , end ) ; } return offset ; }
Print the correct sign of the offset while dumping memory
Print the correct sign of the offset while dumping memory
// If the offset is negative, take 2s complement of first 5 bits