CS计算机代考程序代写 data structure assembly MCD4700 – Introduction to Computer Systems, Networks and Security

MCD4700 – Introduction to Computer Systems, Networks and Security
Assignment 1 – Trimester 2, 2021
Submission guidelines
This is an individual assignment, group work is not permitted Deadline: 10 August , 2021, 11:55pm
Submission format: docx for the written tasks, LogiSim circuit files for task 1, MARIE assembly files for task 2. All files must be uploaded electronically via Moodle.
Late submission:
● By submitting a Special Consideration Form or visit this link: https://lms.monashcollege.edu.au/course/view.php?id=1331
● Or, without special consideration, you lose 5 marks of your mark per day that you submit late (including weekends). Submissions will not be accepted more than 14 days late. This means that if you got Y marks, only Y-n*5 will be counted where n is the number of days you submit late.
● Assessment items will not be accepted after more than 14 calendar days unless a Special Consideration application has been approved. This 14-day time frame does not apply to assessments due in Week 12..
In-class interviews: See instructions for Task 2 for details.
Marks: This assignment will be marked out of 100 points, and count for 20% of your total
unit marks.
Plagiarism: It is an academic requirement that the work you submit be original. If there is any evidence of copying (including from online sources without proper attribution), collaboration, pasting from websites or textbooks, Zero marks may be awarded for the whole assignment, the unit or you may be suspended or excluded from your course. Monash Colleges policies on plagiarism, collusion, and cheating are available here or see this link: https://www.monashcollege.edu.au/__data/assets/pdf_file/0010/17101/dip-assessment-policy.pdf
Further Note: When you are asked to use Internet resources to answer a question, this does not mean copy-pasting text from websites. Write answers in your own words such that your understanding of the answer is evident. Acknowledge any sources by citing them.

1. Boolean Algebra and Logisim Task (35 marks)
Input Output A B C D Z1 Z2 000000 000110 001000 001110 010001 010111 011001 011100 100000 100110 101000 101110 110001 110100 111001 111111
Truth table for Z1 and Z2
Step 1: Boolean Algebra Expressions (10 marks)
Write the Boolean equation for your truth table in sum of products form (your choice). First, think about how to deal with the two outputs. Then, describe each single row in terms of Boolean algebra. Finally, combine the boolean terms for each row into a larger term. Briefly explain these steps for the truth table given.
1

Step 2: Logical Circuit in Logisim (10 marks)
Model the resulting Boolean terms from Step 1 in a single Logisim circuit, using the basic gates AND, OR, NOT. Use the original boolean expression for drawing the circuit (do not simplify the expression). You can use logic gates with more than two inputs.
To do this task you have to use a template Logisim file “task_1.2_and_1.3_template” that has been provided with this assignment. Do not forget to rename it and do not change the labels or add any extra label, otherwise 2 marks will be detected.
Step 3: Optimised Circuit (15 marks)
The goal of this task is to find a minimal circuit (using only universal NAND gates). Based on the truth table and Boolean algebra terms from Step 1, optimize the function using Karnaugh maps.
You need to create two Karnaugh maps, one for each output. Your documentation should show the maps as well as the groups found in the maps and how they relate to terms in the optimized Boolean function. Then use Logisim to create a logic circuit. Don’t use any other gates, other than NAND. Your documentation should also show how the equations have been
Use the template Logisim file “task_1.2_and_1.3_template” that has been provided with this assignment. Do not forget to rename it.
changed to “NAND only”.
2

2. MARIE (65 marks)
In this task you will develop a MARIE application that performs some manipulation of characters, strings and numbers. We will break it down into small steps for you. Most of the tasks require you to write code, test cases and some small analysis. The code must contain comments, and you submit it as .mas files together with the rest of your assignment. The test cases should also be working, self-contained MARIE assembly files (without requiring much input from the user). The analysis needs to be submitted as part of the main PDF file you submit for this assignment.
Name as a String
This section introduces the concepts you need for the rest of the assignment. A string is a sequence of characters. It’s the basic data structure for storing text in a computer. There are several different ways of representing a string in memory and how to deal with strings of arbitrary length.
For this assignment, we will use the following string representation:
● A string is represented in contiguous memory locations, with each address containing one character.
● The characters are encoded using the ASCII encoding.
● End of a string is marked by the ASCII character ‘.’ (i.e. dot or full-stop).
● A string can be of any arbitrary length, and will be terminated by a ’.’, and it may
contain any of the following: alphabets (A-Z, a-z), numbers (0-9) and ASCII Space Character (Hex 020).
Here is an example. A string “John Nguyen.” will be represented in memory (written as hexadecimal numbers):
04A 06F 068 06E 020 04E 067 075 079 065 06E 02E John Nguyen.
Note that, for a string with n characters, we need (n+2) words of MARIE memory in order to store all the characters belonging to that string (including a space and a ‘.’ characters).
When a program inputs a series of characters (i.e. a string is a sequence of characters) using Unicode input mode, and stores them in the MARIE memory starting from location #0FFH, it may look like the Figure 1 below. Note that all the entered characters (alphabets, numbers and punctuation marks) are represented in ASCII (using Hexadecimal format).
In-Class interviews: You will be required to demonstrate your code to your tutor after the
submission deadline. Failure to demonstrate will lead to “zero marks” being awarded to the
entire programming part of this assignment.
3

Memory Location (Hex)
0FFH 100H
Memory Content
048H 069H
Character
‘H’ ‘i’
Memory Location (Hex)
103H 104H 105H
106H
Memory Content
Character
101H 020H ‘’ 102H 04AH ‘J’
Figure 1 (a)
06FH ‘o’ 068H ‘h’ 06EH ‘n’
02EH ‘.’ Figure 1 (b)
In MARIE assembly language programming, we can make use of the ADR command, the HEX keyword and a label “myName” to store this string in memory:
myAdd, ADR myName myName, HEX 04A /’J’ HEX 06F /’o’ HEX 068 /’h’ HEX 06E /’n’
HEX 020 /Space HEX 04E /’N’ HEX 067 /’g’ HEX 075 /’u’ HEX 079 /’y’ HEX 065 /’e HEX 06E /’n’ HEX 02E /’.’
Here, the label “myAdd” refers to the memory location of the label “myName”. So, “myAdd=0001” referring to the first character ‘J.’
Instr. Memory No. Location
1 000
2 001 002 003 004 005
Label Code
Memory Contents
myAdd, myName,
ADR myName 0001 HEX 04A /J 004A HEX 06F /o 006F HEX 068 /h 0068 HEX 06E /n 006E HEX 02E /Space 002E
4

006 HEX 04E
007 HEX 06F
008 HEX 061
009 HEX 068
00A HEX 02E
Figure 2
/N 004E
//o 006F //a 0061 //h 0068 //. 002E
5

2.1 Write a MARIE program to encode your name and ID as a string (10 marks)
The following example of a MARIE string “nameID” encodes a name and an ID using ASCII characters. The “name” is separated from the ID by an ASCII character “Hex 00A” (New Line). Different parts of a name are separated by another ASCII character “Hex 020” (Space). And, the string is terminated by a dot ‘.’ character. The label “addrNameID” holds the address of the first character of the string. You need to follow this MARIE string while solving the task given below.
addrNameID, ADR nameID
nameID, HEX 04A HEX 06F HEX 068 HEX 06E HEX 020 HEX 04E HEX 067 HEX 075 HEX 079 HEX 065 HEX 06E HEX 00A HEX 032 HEX 031 HEX 032 HEX 033 HEX 039 HEX 037 HEX 039 HEX 038 HEX 02E
/’J’
/’o’
/’h’
/’n’ /Space /’N’
/’g’
/’u’
/’y’
/’e’
/’n’
/NL(New Line) /’2’
/’1’ /’2’ /’3’ /’9’ /’7’ /’9’ /’8’ /’.’
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. “nameID”) to store the first character of the string, and another label (e.g. “addrNameID”) to store the address of the first character of the same string.
You need to use 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.
Document at least two test cases using screenshots of what the Memory (in MARIE) looks like after saving the string into the memory (one test for your name and your ID and the other test for anything). The document should be written into the report. Such as this screenshot:
6

Figure 3
7

2.2 Write a MARIE program to print the name and ID using subroutines
(15 marks)
Prepare a MARIE subroutine called subPrintString that can print the ASCII ‘.’ terminated string of your name and your student ID that you have implemented above. You may use the “Output” instruction to print characters in the MARIE output space.
To receive full marks, your program must have a subroutine to print the name and ID string. The subroutine needs to be called from a MARIE main program using a JnS instruction.
Hint: In your main program, you need to use a label “StringAdd” that holds the start address of the string (like, addrNameID) that you want to print. Then, you should call the subroutine subPrintString. In the subroutine, the codes should then load a character from the address “StringAdd”, print the character, then increment the address by one, and keep doing that upto the character loaded from the address is a ‘.’ (which signals the end of the string). The output may look similar to the output below.
John Nguyen 21239798
Document at least two test cases using screenshots of what the output screen and the Memory (in MARIE) looks like after printing a string (one test for your name and your ID and the other test for anything). The document should be written into the report. Such as this screenshot:
Figure 4
8

2.3 Implementation of Caesar Cipher Substitution to encrypt a string
(20 marks)
In this section, we are going to implement Caesar Cipher (a type of substitution cipher) encryption that we have learned in the Cryptography lab. It replaces each character in a string by a different character of the alphabet defined by a simple shift. An encryption “Key” using a shift of 3 positions, shown in the table below.
abcdefghijklmnopqrstuvwxyz defghijklmnopqrstuvwxyzabc
This is a very simple form of encryption. Please note the use of lower case alphabets only, and we will encrypt or decrypt only “alphabets”. One more example “Key” below is showing a Caesar Cipher with a shift of 5 positions.
abcdefghijklmnopqrstuvwxyz fghijklmnopqrstuvwxyzabcde
To encrypt, each letter in the top row is replaced by the corresponding letter in the bottom row, and to decrypt, each letter in the bottom row is replaced by the corresponding letter in the top row.
In this part, your task is to implement subroutines that perform Caesar cipher substitution on a string, either performing encryption or decryption (cipher or decipher). You will implement the mapping in MARIE by a lookup table, storing the result of the substitution for each letter. The lookup table below maps an encryption key using a shift of 3 positions.
myEncKey1Addr, ADR myEncKey1
myEncKey1, HEX 064 / a -> d
HEX 065 /b->e HEX 066 /c->f HEX 067 /d->g HEX 068 /e->h HEX 069 /f->i HEX 06A /g->j HEX 06B /h->k HEX 06C /i->l HEX 06D /j->m HEX 06E /k->n HEX 06F /l->o HEX 070 /m->p HEX 071 /n->q HEX 072 /o->r HEX 073 /p->s HEX 074 /q->t HEX 075 /r->u HEX 076 /s->v HEX 077 /t->w HEX 078 /u->x HEX 079 /v->y
9

HEX 07A /w->z HEX 061 /x->a HEX 062 /y->b HEX 063 /z->c
A subroutine to perform encryption on a string
In this task, you will implement a MARIE subroutine called subCaesarEnc that can perform encryption using Caesar cipher substitution on a string whose start address is passed as an argument in the EncryptStr label. You need to use the “name” part of the string referred to in section 2.1 (nameID containing your first name and last name) to encrypt. You need to display the string before and after the encryption process.
You can assume that the string only contains lower case characters. For each letter in the string, you will need to load the correct value for its substitution from the table “myEncKey1”, and then store that value back into memory (overwriting the original letter).
Think about how to get “a value” from a table. E.g., assume that the original letter is ‘k’, which is the 11th letter in the alphabet. So we need to load the 11th entry in the table– in other words, the entry at address myEncKey1Addr + 10 (which is HEX 06E or DEC 110, or the letter ‘n’). The letter ‘k’ has an ASCII value of HEX 06B (DEC 107). So, how do we determine to add ‘10’ to the address “myEncKey1Addr”? We simply subtract the ASCII value for the letter ‘a’, which is HEX 061 (DEC 97). So, in decimal notation, “117 – 97 = 10” or in HEX notation, “HEX 06B – HEX 061 = HEX A.” The following illustrated example explains the encryption process further. Here, the first name is “patrick”, and the last name is “lee.” And, it will be stored in the memory as shown below.
070 061 074 072 069 063 06B 020 06C 065 065 02E patrick lee.
During the encryption process, the following transformation (in the memory) will occur.
patricklee sdwulfnohh
And, the new encrypted string will be stored in the memory as shown below.
073 064 077 075 06C 066 06E 020 06F 068 068 02E
sdwulfn ohh.
Please note that, during the encryption process, ASCII value for “SPACE” and ‘.’ remains unchanged.
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. You may use the following template to begin with. Here, we are (re)using the subPrintString subroutine from section 2.2, to print the original string then on the second line print the encrypted string. You may use the following template to begin with.
10

/printing the string before encryption
Load addrNameID Store PrintStringAddr Jns subPrintString
/ Load string start address
/ Pass as an argument
/ Call printing subroutine
/calling the subroutine to perform encryption
Load addrNameID Store EncryptStr Jns subCaesarEnc
/ Load string start address
/ Pass as an argument
/ Call the cipher subroutine
/printing the string after encryption
Load addrNameID Store PrintStringAddr Jns subPrintString Halt
/ Load string start address
/ Pass as an argument
/ Call printing subroutine
/Your subroutine “subCaesarEnc” begins here.
EncryptStr, Dec 0 subCaesarEnc, HEX 0
/ Your codes…..
………
………
/Your subroutine ends here.
/ variable or label to store the start
/ address of a string
/ label (subroutine name) to begin the
/ subroutine
Document at least two test cases using screenshots of what the output screen and the hardcoded name (in MARIE) looks like after printing a string (one test for your name and the other test for anything). The document should be written into the report. Such as this screenshot:
Figure 4
11

2.4 A subroutine to perform decryption on a string (20 marks).
In this part, we want to decrypt a string. To do that, we need a second table (in addition to the encryption table “myEncKey1” in section 2.3) that has the reverse mapping. Add a table “myDecKey1” to your code that is exactly the inverse of the “myEncKey1” table above.
myDecKey1Addr, ADR myDecKey1 myDecKey1, HEX???/a->x HEX??? /b->y
……..
HEX??? /z->w
Modify your subroutine in section 2.3 to create a new subroutine performing decryption. You can assume that the string only contains lower case characters. For each letter in the string, you will need to load the correct value for its substitution from the table, and then store that value back into memory (overwriting the original letter).
The following illustrated example explains the decryption process further. Here, you will encrypt the string first, storing the encrypted string back in the memory, and then, decrypt this string back to the original form. In this example, the first name is “patrick”, and the last name is “lee.” And, it will be stored in the memory as shown below.
070 061 074 072 069 063 06B 020 06C 065 065 02E patrick lee.
During the encryption process, the following transformation (in the memory) will occur.
patricklee sdwulfnohh
And, the new encrypted string will be stored in the memory as shown below.
073 064 077 075 06C 066 06E 020 06F 068 068 02E sdwulfn ohh.
Now, you will decrypt the above string “sdwulfn ohh.” to its original form “patrick lee.”
12

070 061 074 072 069 063 06B 020 06C 065 065 02E patrick lee.
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. Please note that, as you need to encrypt the string first, so that you can decrypt an already encrypted string, there is a series of activities involved here [Print the original string-> Encryption -> Print the encrypted string-> Decryption -> Print the original string]. You may use the following template to begin with.
/To print the original string
Load addrNameID Store PrintStringAddr Jns subPrintString
/Encrypting the string
/Loadstringstartaddress / Pass as an argument
/ Call printing subroutine
Load addrNameID
Store EncryptStr
Jns subCaesarEnc
/print the encrypted string Load addrNameID
Store PrintStringAddr Jns subPrintString
/Decrypting the string Load addrNameID Store DecryptStr
Jns subCaesarDec
/print the decrypted string Load addrNameID
Store PrintStringAddr
Jns subPrintString
Halt
/Your subroutine “subCaesarDec” begins here.
DecryptStr, DEC 0 subCaesarDec, HEX 0
/ Your codes…..
………
………
/Your subroutine ends here.
/ variable or label to store the start
/ address of a string
/ label (subroutine name) to begin the
/ subroutine
/ Load string start address
/ Pass as an argument
/ Call the Encryption cipher subroutine
/ Load string start address
/ Pass as an argument
/ Call printing subroutine
/ Load string start address
/ Pass as an argument
/ Call the Decryption cipher subroutine
/ Load string start address
/ Pass as an argument
/ Call printing subroutine
13

Document at least two test cases using screenshots of what the output screen and the hardcoded name (in MARIE) looks like after printing the strings (the original string, the encrypted string and the decrypted string). One test for your name and the other test for anything, the document should be written into the report. Such as this screenshot:
Figure 5
Files to be submitted:
One folder named “YourFirstNameLastNameStudentID” containing the following files:
1. Report for the written tasks (One Word file called YourFirstNameLastName
StudentID.doc / docx). The report should include your Full name, your student ID,
your class number and your tutor’s name.
2. Two Logisim files, one for task 1.2 and one for 1.3, name them LogicalCircuit.circ and
OptimizedCircuit.circ respectively.
3. MARIE files for tasks 2.1 to 2.4 name them as below:
● 2_1_NameID.mas
● 2_2_PrintNameID.mas
● 2_3_SubCaesarEncrypt.mas ● 2_4_SubCaesarDecrypt.mas
Zip the folder under the same name and submit it to moodle. You need to make sure there are no spaces in any of the filenames.
NOTE! Your submitted files must be correctly identified (as described above).
Any submission that does not comply will receive an automatic 10 marks penalty
(applied after marking).
14