Question
NEED HELP WITH LC3 LANGUAGE PROGRAM IN PART 2 PART 2: Add code that parses the non-numeric part of the input string, and calls the
NEED HELP WITH LC3 LANGUAGE PROGRAM IN PART 2
PART 2: Add code that parses the non-numeric part of the input string, and calls the appropriate parser for decimal or hexadecimal. You do not need to parse the number part yet. Your code should be placed in the file where it says Insert your code for part 2 here!. Also, you need to copy the code you wrote for part 1 to where it says Insert your code from part 1 here!. Copy only the code you wrote in part 1, do not copy the code that was already there. Your code must start with a label named ProcessInputCore. On entry to your code, R2 will contain the address of a null terminated string containing the number to parse On exit from your code, R1 must contain zero if the number is positive and -1 if it is negative R2 must contain the memory location of the first digit of the number (ie. after the minus sign and x or #). The code should branch to ParseHex if it determines that the number is hexadecimal, and ParseDecimal if it determines that it is decimal. Style requirements: Beyond making sure that your programs function correctly, it is important that they are documented thoroughly and correctly. Good programming style makes your programs easy to read and to understand, both by you and by anyone else who needs to understand or to change your code in some way. Furthermore, programs written following appropriate style guidelines are easier to write and debug than programs written in a haphazard, disorganized style. While the assembler does not care about the programming style you use, the goal of good style is to make the program easy for people to read. 1. Your assembly language programs should have the following comment block at the top of the file. ; ; Name(s): ; Course number: ; Lab number/problem number: ; Due date: ; 2. All symbolic labels must be meaningful. It is helpful to use both lower and upper case to help make the names easy to read. For example, use SaveR1 as a label instead of something more cryptic, such as SR1. Other good examples include names such as, EndProgram, ReadKeyboard, PrintResult, ShiftLeft, and so on. 3. Add a comment after each instruction to describe what it is doing with regard to the overall program. 4. Use white space (i.e., spaces, tabs, carriage returns) generously to emphasize the structure of your program and to make it easy to read. Make sure you indent and align statements and comments appropriately. 5. No lines should be more than 80 characters long.
HERE'S MY CODE
--------------------------
;;; File: lab6a_2.asm
.ORIG x3000
ReadString
LEA R0, Prompt
PUTS ; Display a prompt requesting input
LD R1, InBuffLen ; Set R1 to length of input buffer
LEA R2, InBuffPtr ; Set R2 to address of input buffer in memory
BRnzp ReadCore ; Goto the core input code
Prompt
.STRINGZ "Enter a number: " ; The prompt string
InBuffLen
.FILL 10 ; The length of the input buffer
InBuffPtr
.BLKW 10 ; The memory reserved for the input buffer
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Insert your code from part 1 here!!!!!!!!!!!!!
ReadCore
ADD R1,R1,#-1
BRz Full
GETC
OUT
ADD R5,R0,#-13
BRz Full
LD R3,lowerCase
ADD R6,R3,R0
BRn Store
LD R3, UpperCase
ADD R0,R0,R3
Store
STR R0,R2,#0
ADD R2,R2,#1
BRnzp ReadCore
Full
AND R0,R0,#0
STR R0,R2,#0
BRnzp ProcessInput
lowerCase .FILL x-61
UpperCase .FILL x-20
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ProcessInput
LEA R2, InBuffPtr ; Set R2 to address of buffer in memory
BRnzp ProcessInputCore
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Insert your code for part 2 here!!!!!!!!!!!!!
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ParseHex
LEA R0, HexStr
PUTS ; Output the string "hex"
BRnzp ParseCommon
ParseDecimal
LEA R0, DecimalStr
PUTS ; Output the string "decimal"
ParseCommon
ADD R1, R1, #0 ; Check if negative
BRzp NotNeg
LEA R0, MinusStr
PUTS ; If negative output string "negative"
NotNeg
ADD R0, R2, #0
PUTS ; Output the number
LEA R0, EndOfLineStr
PUTS ; Output the a newline after the result
BRnzp ReadString
MinusStr
.STRINGZ "negative "
HexStr
.STRINGZ "Answer: hex "
DecimalStr
.STRINGZ "Answer: decimal "
EndOfLineStr
.STRINGZ " " ; A newline
.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