UMBC CMSC 313, Computer Organization & Assembly Language,
Fall 2002, Section 0101
Project 2: Hexadecimal to Octal Conversion
Also available in PDF.
Due: Thursday September 26, 2002
Objective
The objective of this programming project is to practice designing
your own loops and branching code in assembly language and to gain
greater familiarity with the i386 instructions set.
Assignment
Write an assembly language program that prompts the user to enter
a string to be interpreted as a number in base 16. Your program
must convert the ASCII string representation of this hexadecimal
number into a 32-bit unsigned binary number. Finally, your program
must prepare and store an ASCII string for the octal (base 8)
representation of the same number and print it out.
Your program should generate an error if the input string contains
a character that is not 0 through 9 or A through F (except for the
linefeed at the end). You may disallow lower case 'a' through 'f'
in the hexadecimal representation. You may also assume that any
input string with more than 9 characters (including the linefeed)
is invalid.
Example:
Enter hex digits: 2345ABCD
Original: 2345ABCD
Octal: 04321325715
Implementation Issues:
- The user input has a linefeed character at the end.
You do not want to consider this character when you convert from
a hexadecimal string to binary.
- It is OK to print out extra leading zeroes for the
octal representation of the number.
- You will find the shift left and shift right instructions
SHL and SHR especially useful.
- Note that the character 'A' does not follow the digit
'9' in ASCII. Remember this when you convert the hex string to
binary.
Turning in your program
Use the UNIX script command to record some sample runs of your
program. You should use inputs that result in a variety of octal
string outputs and also inputs that demonstrate the error checking
features of your program.
You should submit two files: 1) your assembly language program and
2) a typescript file of your sample runs. The class name for submit
is 'cs313-0101' and the assignment name is 'proj2'. The UNIX
command to do this should look something like:
submit cs313-0101 proj2 hex2oct.asm typescript
Last Modified:
22 Jul 2024 11:27:49 EDT
by
Richard Chang
to Fall 2002 CMSC 313 Section Homepage