

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Assignment; Class: MACHINE ORG&ASSEMBLY LANG PRGRM; Subject: Computer Science; University: University of California-Riverside; Term: Fall 2004;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
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
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!)