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 A-Z (capital letters only), stores each character inmemory after it is transformed by the trivial ROT13 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 100/ Start the program at location 100 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 000/ If input character is comma, skip the next instruction
Jump InputDone / If it's a comma, jump to InputDone
JnS ROT13/ Transform the character using ROT13 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 000/ 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-13 subroutine: Apply ROT13 to input character in location InVal and return in AC
/-----
ROT13, Load InVal / Get character
Add Val13/ Add 13
Store Hold / Save it
Subt ChZ / Check if modulo adjust is needed (past 'Z')
Skipcond 400/ 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 ROT13/ Return with result in AC
NoAdj, Load Hold
Subt Val26/ Subtract 26 for wrap-around
Store InVal
JumpI ROT13/ Return with result in AC
/-----
/ Constants (the program should not write to these locations)
/-----
CHA, HEX 0041/ Constant value 'A'
ChZ, HEX 005A / Constant value 'Z'
ChPe, HEX 002C / Constant period character (comma)
Val13, DEC 13/ Constant rotate value of 13
Val26, DEC 26/ Constant value for modulo operation (26 letters)
One, HEX 0001/ Constant value 1
Start, HEX 200/ Starting address for data
/-----
/ Data area (these locations are for reading and writing)
/-----
InVal, HEX 0/ Reserved for subroutine input value
Hold, HEX 0/ Reserved for temporary variable for subroutine
Ptr, HEX 0/ 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!