Answered step by step
Verified Expert Solution
Question
1 Approved Answer
After creating a new . mas file with the adjusted code that was suggested by the expert it appears the problem is still persisting when
After creating a new mas file with the adjusted code that was suggested by the expert it appears the problem is still persisting when I run through test cases. However now it appears to move to the CheckROT loop which is an improvement from being stuck in the main loop I had previously.
Here is the code as it stands currently. The aim is to have the program move to output after a single period is entered.
Initialization
ORG
Initialize Ptr pointer
Load Start
Store Ptr
Main Program
MainLoop, Input Input a character
Store InVal Store input in InVal
Load InVal Load input value to AC
Subt ChPer Check if input is a period
Skipcond If AC input is jump to OutputStart
Jump CheckROT
CheckROT Jns ROT Call ROT subroutine to transform the character
StoreI Ptr Store the transformed character in memory
Load Ptr Load pointer address
Add One Increment pointer
Store Ptr Store updated pointer
Jump MainLoop Repeat the input loop
Output Phase
OutputStart, Load Start Initialize pointer to the start of stored characters
Store Ptr
OutputLoop, LoadI Ptr Load the character from memory
Subt ChPer Check if the character is
Skipcond If AC character is jump to EndProgram
Output Output the character
Load Ptr Load pointer address
Add One Increment pointer
Store Ptr Store updated pointer
Jump OutputLoop Repeat the output loop
EndProgram, Halt End the program
ROT Subroutine
ROT HEX
Load InVal
Add Val
Store Hold
Subt ChZ
Skipcond
Jump NoAdj
Add ChA
Jump Done
NoAdj, Load Hold
Done, JumpI ROT
Constants
ChA, HEX Constant value A
ChZ HEX A Constant value Z
ChPer, HEX E Constant period char
Val DEC Constant ROT value
One, HEX Constant value
Start, HEX Constant address for starting memory location
Data Area
InVal, HEX Subroutine input value
Hold, HEX Temporary variable
Ptr HEX Character pointer
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