FIT1047 Assignment
Task 2.1 Your name as a MARIE string (2 points)
Similar to the FIT1047 example above, encode your name using ASCII characters. You
Copyright By PowCoder代写 加微信 powcoder
should encode at least 10 characters – if your name is longer, you can shorten it if you want,
if it’s shorter, you need to add some characters (such as !?! or …, or invent a middle name
including space).
You need to submit a MARIE file that contains the code that stores your name into
Note that this code will not actually do anything else than storing your name in memory and
you will not need to use the template for this.
Task 2.2 Printing a string (4 points)
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).
Submit your MARIE code that shows the test case of printing your name from the
previous task.
Task 2.3: A subroutine for printing a string (4 points)
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 the
address of the string representing your name. Document your test with a screen shot
showing MARIE memory after executing the code.
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 2.4: User input (5 points)
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 ‘O’ is different from the integer 0).
Submit your MARIE code. Document at least two test cases using screenshots of
what the memory looks like after entering a string.
Task 2.5 Lower case (5 points)
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 O 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”.
Submit your MARIE code and documentation of two test cases (i.e. document your
Input into the program and the output you observe, so that it can be repeated during
the interview.
Task 2.6 ROT13 (12 points)
Now we combine the previous subroutines and add another subroutine that implements a
simple substitution cipher known as ROT 13. The idea is to replace each character in a string
by the character 13 places further in the alphabet, wrapping around from z to a. For
example, the letter a is mapped to n, and the letter p is mapped to c.
Your task is to implement a subroutine that performs ROT13 encoding on a string with
lowercase letters. It does not need to work or provide any meaningful output on wrong input,
e.g. upper case or other characters.
For example:
Input: abp
Output: noc
Input: abp?A!
Output: noc?A!
Thus, for this task you need to do the following:
Implement a subroutine that can do ROT13 on a string that contains only lower case
Combine the new subroutine and all the previous subroutines into a program that
does the following:
Let a user input a string (input one character at a time)
Perform ROT13 on the string
Output the result
Submit the complete MARIE code and document 3 test cases,
Task 2.7 Extend the ROT13 code to work for all ASCII characters (8
For this task, you need to extend the ROT13 subroutine in your code from Task 2.6 to ignore
all characters that are not lower case letters. Thus, your new program should apply ROT13
to all letters and keep other characters as they are (remember that upper case letters are
turned into lower case before applying ROT13).
For example:
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com