Question
Please use the Code template at the bottom. Objective The purpose of this assignment is to familiarize students with the basics of LC3 assembly language
Please use the Code template at the bottom.
Objective
The purpose of this assignment is to familiarize students with the basics of LC3 assembly language programming, the SIMPL simulator, and rudimentary debugging.
High Level Description
Prompt the user to input two single digit numbers; the second will then be subtracted from the first, and the operation reported in the console:
Low Level Breakdown:
This assignment comprises five tasks:
1. Prompt the user, and read two numeric characters ('0' ... '9') from the user using Trap x20 (GETC). Echo the characters to the console as they are input, and store them as character data in separate registers.
2. Output to the console the operation being performed e.g. 5 - 7 =
3. Using the same registers, convert the numeric characters into the actual numbers they represent (e.g. convert the ASCII code for 7 into the binary representation of the number 7). 4. Perform the subtraction operation, and determine the sign (+/-) of the result; if negative, determine the magnitude of the result (i.e. take 2's complement)
5. Convert resulting number back to a printable character and print it, together with minus sign if necessary
Example algroithm:
1. Program prompts for user input, user enters 5, which is echoed to console and stored in a register.
2. Program prompts for user input, user enters 7, which is echoed to console and stored in a register.
3. Program outputs 5 - 7 =
4. Program converts 5 into 5 and stores it back in the same register.
5. Program converts 7 into 7 and stores it back in the same register.
6. Program performs (5-7) and stores the result, -2, in a register(obviously as a 2's complement number)
7. Program recognizes that result is negative, converts -2 to 2, and sets flag for minus sign
8. Program converts 2 into '2', and stores it back in same register
9. Program outputs the two characters -2 followed by a newline, thus completing the subtraction operation output
USET HIS CODE TEMPLATE
.ORIG x3000 ; Program begins here | |
;------------- | |
;Instructions | |
;------------- | |
;---------------------------------------------- | |
;outputs prompt | |
;---------------------------------------------- | |
LEA R0, intro ; | |
PUTS ; Invokes BIOS routine to output string | |
;------------------------------- | |
;INSERT CODE STARTING FROM HERE | |
;-------------------------------- | |
HALT ; Stop execution of program | |
;------ | |
;Data | |
;------ | |
; String to explain what to input | |
intro .STRINGZ "ENTER two numbers (i.e '0'....'9') " | |
NEWLINE .STRINGZ " " ; String that holds the newline character | |
;--------------- | |
;END of PROGRAM | |
;--------------- | |
.END |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started