Question: Question:You are to design, write, test, and debug a MARIE assembly language program that inputs a sequence of characters from the set A - Z

Question:You are to design, write, test, and debug a MARIE assembly language program that inputs a
sequence of characters from the set A-Z (capital letters only), stores each character in
memory after it is transformed by the trivial ROT13 cipher, and then, after character input
completes, outputs the transformed characters.
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 '.', skip the next instruction
Jump InputDone / If it's a period, 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
/ Output loop
OutputLoop, LoadI Ptr / Load the character from memory
Add ChPe / Compare with the period character
Skipcond 000/ If character is '.', skip the next instruction
Jump OutputDone / If it's a period, 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
/-----
/ 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
Add ChA / Add 'A' back to difference to perform modulo
Add One / Add 1 to perform correct modulo operation
NoAdj, Load Hold / No adjust needed, get result
Done, JumpI ROT13/ Return with result in AC
/-----
/ Constants (the program should not write to these locations)
/-----
ChA, HEX 0041/ Constant value 'A' for modulo adjust in subroutine
ChZ, HEX 005A / Constant value 'Z' for modulo check in subroutine
ChPe, HEX 2E / Constant period character that marks end of input
Val13, DEC 13/ Constant rotate value of 13 for subroutine
One, HEX 1/ Constant value 1
Start, HEX 200/ Constant address for start of character block
/-----
/ 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
This code is not working.

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!