For this task, you need to write MARIE code that can print any string (no matter how
Question:
For this task, you need to write MARIE code that can print any string (no matter how long) using the Output instruction. Start by using a label CurrentCharacterAddress that you initialize with the address of the string (for example with StringtobePrinted in the template). The code should then output the character at the address, increment it by one, and keep doing that until the character at the address is a 0 (which signals the end of the string).
Task 2
Turn your code from the previous task into a subroutine that takes the address of a string as an argument and outputs it. Use the template for this task. Your code needs to start reading the string from the address stored in PrintString, stopping when it finds a 0, otherwise printing the character using the Output instruction. Submit your MARIE code, including a test case that calls the subroutine with with the address of the string representing your name. my name is pat
Hint: You need to find out the concrete address by first assembling your code and then looking up where the string ended up being placed in memory, then adapt your code).
Task 3
The next step is to implement a subroutine that reads a string, character by character, using the Input instruction. The subroutine takes an address as its argument which is the location in memory where the string should start. Your code needs to input a character, store it at a given address (use the last two digits of your student ID in HEX with prefix '1', for example, if last two digits of student ID is 01 then 101), then increment the address by 1 and loop back to the input. Once a user enters a 0, the subroutine finishes. Note that you can switch the input box in the MARIE simulator into different modes: use the UNICODE mode to enter the characters, and use Hex or Decimal to enter the final 0 (since the character '0' is different from the integer 0).
Task 4
Some people write emails with lots of uppercase characters, which is a bit rude and unpleasant to read. So we will implement a subroutine that turns all characters in a string into lower case. The subroutine takes the address of a string as its argument. For each character in the string, it tests whether it is upper case (i.e., whether it is between the ASCII values for A and Z), and if it is, it turns it into lower case (modifying the string stored in memory). It finishes when it reaches the 0 signaling the end of the string. Hint: to turn a character from upper case into lower case, just add the difference between the ASCII values for "a" and "A".