Question: Question:User inputs a sequence of characters from the set A - Z ( capital letters only ) , stores each character inmemory after it is
Question:User inputs a sequence of characters from the set AZ capital letters only stores each character inmemory after it is transformed by the trivial ROT cipher, and then, after character input completes, outputs the transformed characters.
The program should work for any inputs A through Z and a period terminates input In the interest of keeping the program simple, the program does not need to validate inputs.
ORG Start the program at location hexadecimal
Input characters, transform, and store in memory until is input
Load Start Initialize character pointer to start of block
Store Ptr
Input loop
InputLoop, Input Input a character
Store InVal Store input character in InVal
Load InVal Load InVal into AC
Subt ChPe Compare with the period character
Skipcond If input character is comma, skip the next instruction
Jump InputDone If it's a comma, jump to InputDone
JnS ROT Transform the character using ROT subroutine
StoreI Ptr Store the transformed character in memory
Load Ptr Load the pointer into AC
Add One Increment the pointer
Store Ptr Store the updated pointer
Jump InputLoop Continue the input loop
Input complete, now output the transformed characters
InputDone, Load Start Initialize character pointer to start of block
Store Ptr Save it to Ptr
OutputLoop, LoadI Ptr Load the character from memory
Subt ChPe Compare with the period character
Skipcond If character is comma, skip the next instruction
Jump OutputDone If it's a comma, jump to OutputDone
Output Output the transformed character
Load Ptr Load the pointer into AC
Add One Increment the pointer
Store Ptr Store the updated pointer
Jump OutputLoop Continue the output loop
OutputDone, Halt Stop the program
Rotate subroutine: Apply ROT to input character in location InVal and return in AC
ROT Load InVal Get character
Add Val Add
Store Hold Save it
Subt ChZ Check if modulo adjust is needed past Z
Skipcond Adjust needed if past Z skip next instruction
Jump NoAdj
Load Hold No adjust needed, get result
Store InVal Save adjusted result back to InVal
JumpI ROT Return with result in AC
NoAdj, Load Hold
Subt Val Subtract for wraparound
Store InVal
JumpI ROT Return with result in AC
Constants the program should not write to these locations
CHA, HEX Constant value A
ChZ HEX A Constant value Z
ChPe, HEX C Constant period character comma
Val DEC Constant rotate value of
Val DEC Constant value for modulo operation letters
One, HEX Constant value
Start, HEX Starting address for data
Data area these locations are for reading and writing
InVal, HEX Reserved for subroutine input value
Hold, HEX Reserved for temporary variable for subroutine
Ptr HEX Reserved for character pointer
I got this code from chegg other answers but it is not working. It keeps outputting a special character. can you give me back a whole corrected answer?
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
