Assignment 2 on Organization and Assembly Language | CS 061, Assignments of Computer Science

Material Type: Assignment; Professor: Linard; Class: MACHINE ORG&ASSEMBLY LANG PRGRM; Subject: Computer Science; University: University of California-Riverside; Term: Fall 2004;

Typology: Assignments

Pre 2010

Uploaded on 03/28/2010

koofers-user-cs8-1
koofers-user-cs8-1 🇺🇸

5

(2)

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 061 – Computer Org. & Assembly Lang. Fall - 2004
Assignment 2 - due Thursday 10/7, 11 pm
Instructions:
Turn in your source code (.asm file) to the folder assn2:
Remember to include your personal header (name, id, team partners, etc.)
Synopsis
Subtract one number from another (both 1 digit decimal integers) and output the result as an
ASCII-coded decimal number to the console. These two decimal numbers are to be typed in as
single digit (positive) numbers by the user from the console, and the second is subtracted from
the first.
Description
The program comprises five parts:
1. read the two ASCII numbers from the console using TRAP instructions;
2. convert both numbers to binary representation.
3. make the second negative (i.e. take its 2’s complement), and add the two resulting
numbers;
4. determine the sign of the result;
5. convert the result (including the sign!) back to ASCII representation, and output the
result to the console.
Example: input ‘8’ and ‘9’ from the console; these are translated from their respective ASCII
codes to 0000 0000 0000 1000 and 0000 0000 0000 1001 (and then to 1111 1111 1111 0111
= -9); the sum is 1111 1111 1111 1111; and the program prints out ‘-1’.
Hints:
Experiment with TRAP x20 (GETC) and TRAP x21 (OUT) to make sure you understand exactly
how they work. Note that the LC-3 stores ASCII characters as the lower byte of a 2-byte word.
Study the ASCII table carefully to understand how to convert between the ASCII binary
representation of the numerical symbol '9' (0011 1001) and the actual binary number equivalent to
decimal 9 (0000 1001).
How will you display the result if it is negative?
To get the display cursor to move to a new line, output the newline character CR/LF = ASCII x0A
Make sure you have complete and consistent comments in your code.
pf2

Partial preview of the text

Download Assignment 2 on Organization and Assembly Language | CS 061 and more Assignments Computer Science in PDF only on Docsity!

CS 061 – Computer Org. & Assembly Lang. Fall - 2004

Assignment 2 - due Thursday 10/7, 11 pm

Instructions:

Turn in your source code (.asm file) to the folder assn2 :

Remember to include your personal header (name, id, team partners, etc.)

Synopsis

Subtract one number from another (both 1 digit decimal integers) and output the result as an

ASCII-coded decimal number to the console. These two decimal numbers are to be typed in as

single digit (positive) numbers by the user from the console, and the second is subtracted from

the first.

Description

The program comprises five parts:

1. read the two ASCII numbers from the console using TRAP instructions;

2. convert both numbers to binary representation.

3. make the second negative (i.e. take its 2’s complement), and add the two resulting

numbers;

4. determine the sign of the result;

5. convert the result (including the sign!) back to ASCII representation, and output the

result to the console.

Example: input ‘8’ and ‘9’ from the console; these are translated from their respective ASCII

codes to 0000 0000 0000 1000 and 0000 0000 0000 1001 (and then to 1111 1111 1111 0111

= -9); the sum is 1111 1111 1111 1111; and the program prints out ‘-1’.

Hints:

 Experiment with TRAP x20 (GETC) and TRAP x21 (OUT) to make sure you understand exactly how they work. Note that the LC-3 stores ASCII characters as the lower byte of a 2-byte word.  Study the ASCII table carefully to understand how to convert between the ASCII binary representation of the numerical symbol '9' (0011 1001) and the actual binary number equivalent to decimal 9 (0000 1001).  How will you display the result if it is negative?  To get the display cursor to move to a new line, output the newline character CR/LF = ASCII x0A

Make sure you have complete and consistent comments in your code.

Grading policy: Possible points: 10 FROM NOW ON, IF YOUR CODE DOES NOT ASSEMBLE IT WILL NOT BE GRADED – i.e. YOUR SCORE WILL BE 0 Well commented code: 2 Correct use of TRAPs 2 Correct ASCII – binary conversion 2 Correct 2’s complement operations 2 Correct output 2 Assignment submitted without name and SSN: - 5 points (if we can figure out who you are!)