Docsity

Programming Assignment 1 - Computer Organization Architecture | CSC 320, Assignments of Computer Architecture and Organization

Toggle sidebar
bg1
SCHOOL OF COMPUTER & INFORMATION SCIENCES
CSC 320
Programming Assignment 1.
You are to write a program in which a user enters hexadecimal number strings, and the corresponding signed
decimal numbers are outputted. The program is exited when the user enters a blank string.
For hexadecimal number strings, leading blanks are ignored, and then the number starts with โ€œ0xโ€ or โ€œ0Xโ€. The
digits can be numbers, or either uppercase or lowercase characters โ€žaโ€Ÿ-โ€žfโ€Ÿ. A message saying โ€œInvalid hexadecimal
numberโ€ should be output if the entered string is not a valid hexadecimal string (by these specifications).
The only system calls you may use are read_ string, write_string, and write_int.
You must write and use a procedure to convert the inputted hexadecimal string with the following specifications:
1. Input: $a0 contains the address of a null-terminated string (not necessarily preserved).
Output: $v0 contains the number, $v1 contains 0 if no error, 1 if error.
2. The converted signed integer number must fit into a 32-bit word.

Partial preview of the text

Download Programming Assignment 1 - Computer Organization Architecture | CSC 320 and more Assignments Computer Architecture and Organization in PDF only on Docsity!

SCHOOL OF COMPUTER & INFORMATION SCIENCES CSC 320 Programming Assignment 1.

You are to write a program in which a user enters hexadecimal number strings, and the corresponding signed decimal numbers are outputted. The program is exited when the user enters a blank string.

For hexadecimal number strings, leading blanks are ignored, and then the number starts with โ€œ0xโ€ or โ€œ0Xโ€. The digits can be numbers, or either uppercase or lowercase characters โ€žaโ€Ÿ-โ€žfโ€Ÿ. A message saying โ€œInvalid hexadecimal numberโ€ should be output if the entered string is not a valid hexadecimal string (by these specifications).

The only system calls you may use are read string_ , write_string , and write_int.

You must write and use a procedure to convert the inputted hexadecimal string with the following specifications:

  1. Input: $a0 contains the address of a null-terminated string (not necessarily preserved). Output: $v0 contains the number, $v1 contains 0 if no error, 1 if error.
  2. The converted signed integer number must fit into a 32-bit word.