2.1 Your name as a MARIE string (5 marks)
The following example of a MARIE string “myString” encodes a name and an ID using ASCII characters. The “name” is separated from the ID by an ASCII character “Hex 00A” ( ). Different parts of a name are separated by another ASCII character “Hex 020” (Space). And the entire string, consisting of a name and an ID, is terminated by a dot ‘.’ character. Please see the example below. The label “myStringAddr” holds the address of the first character of the string. You need to follow this MARIE string while solving the task given below.
myStringAddr,
Copyright By PowCoder代写 加微信 powcoder
ADR myString
HEX 044 /’D’
HEX 06F /’o’
HEX 06E /’n’
HEX 067 /’g’
HEX 020 /Space
HEX 053 /’S’
HEX 061 /’a’
HEX 074 /’t’
HEX 072 /’r’
HEX 069 /’i’
HEX 061 /’a’
HEX 00A /NL( )
HEX 032 /’2’
HEX 031 /’1’
HEX 038 /’8’
HEX 033 /’3’
HEX 039 /’9’
HEX 039 /’9’
HEX 030 /’0’
HEX 030 /’0’
HEX 02E /’.’
Prepare a MARIE program to encode a string that includes your full name (first name and last name) and your student ID using ASCII characters. Following the above example, you need to use two labels, one label (e.g. “myString”) to store the first character of the string, and another label (e.g. “myStringAddr”) to store the address of the first character of the same string.
You need to submit a MARIE file that contains codes, using the ADR command and HEX keywords (like the above example), so that after assembling, your name, ID and the address (of the first character of the string) is stored in MARIE memory. The codes must be accompanied by appropriate comments (as a paragraph before any block of code or subroutine or as inline comments wherever appropriate).
2.2 Printing your name and ID (10 marks)
Prepare a MARIE program that can print the ASCII ‘.’ terminated string of your name and your student ID that you have implemented in task 2.1. You may use the “Output” instruction to print characters in the MARIE output space.
Hint: In your program, you need to use a label “myString” that holds the start address of the string (like, myStringAddr) that you want to print. Then, you should load a character from the address “myString”, print the character, then increment the address by one, and keep doing that up to the character loaded from the address is a ‘.’ (which signals the end of the string). The output may look similar to the output below. The codes must be accompanied by appropriate comments (as a paragraph before any block of code or subroutine or as inline comments wherever appropriate).
Inside the Memory
Figure 1: Print your name and ID
2.3 A subroutine for printing your name and ID in a backward order
(15 marks)
Prepare a MARIE subroutine called subPrintBackward that can print the ASCII ‘.’ terminated string of your name and your student ID in a backward order that you have implemented in task 2.1. You may use the “Output” instruction to print characters in the MARIE output space.
To receive full marks, your code needs to be in the form of a subroutine that can be called using the JnS instruction. You need to write a MARIE main program to call this subroutine.
Hint: In your main program, you need to use a label “myString” that holds the start address of the string (like, myStringAddr) that you want to print. Then, you should call the subroutine subPrintBackward. In the subroutine, the codes should then load the last character from the end of the string, print the character, then decrement the address by one, and keep doing that up to the character loaded from the address is address of “myString”, (which the first character of the string). The output may look similar to the output below. The codes must be accompanied by appropriate comments (as a paragraph before any block of code or subroutine or as inline comments wherever appropriate).
Figure 2: Print your name and ID in a backward order
2.4 A subroutine to find student grade (20 marks)
Prepare a MARIE subroutine called studentGrade which takes three assessment marks that are related to one student. Then count the total marks and check whether the student passes or fails. The total marks will be in the range of 0-100, while the individual assessments can be in any range. You need to display the following message related to the total mark:
Excellent (total mark more than 80)
Very Good (total mark between 70 and 79)
Good (total mark between 60 and 69)
Pass (total mark between 50 and 59)
Fail (total mark less than 50)
Write a main program where the user will be:
a. Asked to enter (input) three marks (one after the other),
b. Add them to the totalMark variable, then
c. Find and display (output) the appropriate message.
The codes must be accompanied by appropriate comments (as a paragraph before any block of code or subroutine or as inline comments wherever appropriate).
To receive full marks, your code needs to be in the form of a subroutine that can be called using the JnS instruction. You need to write a MARIE main program to call this subroutine.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com