Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Description and Synopsis - Computer Organization and Assembly Language | CS 061, Assignments of Computer Science

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

Typology: Assignments

2009/2010

Uploaded on 03/28/2010

koofers-user-c9b
koofers-user-c9b 🇺🇸

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 4 - due Thursday 10/21, 11 pm
Instructions:
Turn in your source code (.asm file) to the folder assn:
Remember to include your personal header (name, id, team partners, etc.)
Synopsis
Enter a multi-digit decimal integer at the keyboard, and translate it into 16-bit 2’s complement
binary for storage in the computer.
Description
WARNING: you will not be able to handle this assignment until you have completely understood
assignment 3!
Prompt the user to enter a 4 digit decimal integer (positive or negative) at the keyboard, and produce
the following outputs to the console:
a) the number as entered (i.e. echo the input to the console);
b) the 16-bit 2’s complement binary representation of the number ;
You must check each of the input digits to see if it is a valid number component, i.e. '0' to '9' (x30 to
x39), or '+' (x2B) or '–' (x2D); If not, disregard the whole input, and output an error message.
You may require that the input number be always 4 digits (i.e. 27 must be input as 0027), but this is not
the preferred solution.
Some tips:
Experiment with TRAP x20 (GETC) and TRAP x21 (OUT) to make sure you understand exactly
how they work.
The CR/LF (newline) character is ASCII x0A.
store the negative of the ASCII values for '+' and '-' and '0' and '9' to simplify testing (why?)
if the number is negative (i.e. if the first character entered is '-'), you will need to flag that fact so as
to take the 2's complement after translating the number into binary.
set up a .BLKW #4 to store the entered digits (this makes it easier to separate data entry &
verification from the conversion processing).
you already know how to extract the binary integer corresponding to each decimal symbol ('0' to '9'):
what is the "weight" of each succeeding digit in the decimal number? (Note: there are a couple of
ways of doing the conversion to binary - by column weight, as suggested, or by lookup table. Think
about both & choose whichever you like).
you already know how to print out a binary number as a series of ASCII ‘1’s and ‘0’s
Make sure you have complete and consistent comments in your code.
pf2

Partial preview of the text

Download Description and Synopsis - Computer 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 4 - due Thursday 10/21, 11 pm

Instructions:

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

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

Synopsis

Enter a multi-digit decimal integer at the keyboard, and translate it into 16-bit 2’s complement

binary for storage in the computer.

Description

WARNING: you will not be able to handle this assignment until you have completely understood assignment 3! Prompt the user to enter a 4 digit decimal integer (positive or negative) at the keyboard, and produce the following outputs to the console: a) the number as entered (i.e. echo the input to the console); b) the 16-bit 2’s complement binary representation of the number ; You must check each of the input digits to see if it is a valid number component, i.e. '0' to '9' (x30 to x39), or '+' (x2B) or '–' (x2D); If not, disregard the whole input, and output an error message. You may require that the input number be always 4 digits (i.e. 27 must be input as 0027), but this is not the preferred solution. Some tips:  Experiment with TRAP x20 (GETC) and TRAP x21 (OUT) to make sure you understand exactly how they work.  The CR/LF (newline) character is ASCII x0A.  store the negative of the ASCII values for '+' and '-' and '0' and '9' to simplify testing (why?)  if the number is negative (i.e. if the first character entered is '-'), you will need to flag that fact so as to take the 2's complement after translating the number into binary.  set up a .BLKW #4 to store the entered digits (this makes it easier to separate data entry & verification from the conversion processing).  you already know how to extract the binary integer corresponding to each decimal symbol ('0' to '9'): what is the "weight" of each succeeding digit in the decimal number? (Note: there are a couple of ways of doing the conversion to binary - by column weight, as suggested, or by lookup table. Think about both & choose whichever you like).  you already know how to print out a binary number as a series of ASCII ‘1’s and ‘0’s

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

Grading policy: Possible points: 10 Program assembles without errors: 3 Program runs correctly on LC- 3 simulator 5 Well commented code: 2 Assignment submitted without name and SSN: - 5 points (if we can figure out who you are!)