联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

您当前位置:首页 >> Python编程Python编程

日期:2021-04-15 11:23

MCD4700 - Introduction to Computer Systems,

Networks and Security

Assignment 1 - Trimester 1, 2021

Submission guidelines

This is an individual assignment, group work is not permitted

Deadline: 7 April, 2021, 11:55 pm

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 5

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

1. Boolean Algebra and Logisim Task (35 marks)

Input Output

A B C D Z1 Z2

0 0 0 0 1 0

0 0 0 1 0 1

0 0 1 0 1 0

0 0 1 1 0 1

0 1 0 0 0 1

0 1 0 1 1 0

0 1 1 0 0 1

0 1 1 1 1 0

1 0 0 0 1 0

1 0 0 1 0 1

1 0 1 0 1 0

1 0 1 1 0 1

1 1 0 0 0 1

1 1 0 1 1 0

1 1 1 0 0 1

1 1 1 1 1 0

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.

2

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. Your documentation should show how the equations have been changed to NAND

only.

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. 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.

3

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.

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.

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

J o h n N g u y e n .

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).

4

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).

Memory

Location

(Hex)

Memory

Content

Character

0FFH 048H ‘H’

100H 069H ‘i’

101H 020H ‘ ’

102H 04AH ‘J’

Figure 1 (a)

Memory

Location

(Hex)

Memory Content Character

103H 06FH ‘o’

104H 068H ‘h’

105H 06EH ‘n’

106H 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 put this string into 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 /’.’

5

Here, the label “myAdd” refers to the memory location of the label “myName”. So,

“myAdd=0001” referring to the first character ‘J.’

Instr.

No.

Memory

Location

Label Code Memory

Contents

1 000 myAdd, ADR myName 0001

2 001 myName, HEX 04A /J 004A

002 HEX 06F /o 006F

003 HEX 068 /h 0068

004 HEX 06E /n 006E

005 HEX 02E /Space 002E

006 HEX 04E /N 004E

007 HEX 06F //o 006F

008 HEX 061 //a 0061

009 HEX 068 //h 0068

00A HEX 02E //. 002E

Figure 2

6

2.1 Your name as a MARIE 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 /’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 00A /NL(New Line)

HEX 032 /’2’

HEX 031 /’1’

HEX 032 /’2’

HEX 033 /’3’

HEX 039 /’9’

HEX 037 /’7’

HEX 039 /’9’

HEX 038 /’8’

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. “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 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.

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:

7

Figure 3

2.2 A subroutine for printing a string (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 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 “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:

8

Figure 4

2.3 A subroutine to count the number of Alphabets in a string (15 marks)

Prepare a MARIE subroutine called subCountAlpha to count the number of alphabets ([‘A’

- ‘Z’] or [‘a’ - ‘z’]) that are present in the ASCII ‘.’ terminated string of your name and your

student ID that you have implemented in task 2.1 as an example. The subroutine also needs

to print this count (i.e. the total number of alphabets that are present in the string).

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 “StringAdd” that holds the start address

of the string (like, addrNameID) that you want to use. Then, you should call the subroutine

subCountAlpha. In the subroutine, the codes should then load a character from that

address, include it in your count if it is an alphabet, then increment the address by one, and

keep doing that until the character loaded from the address is a ‘.’ (which signals the end of

the string). After completing the counting process, your program will print the count, for which

the output may look similar to the output below.

10

Note: it is not always name followed by ID, it could be any mixed (ex, John, 2123, Nguyen.),

it includes 10 alphabets and 4 numbers.

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:

9

Figure 5

2.4. A subroutine to count the number of numeric characters in a string

(15 marks)

Prepare a MARIE subroutine called subCountNumerics that can count the number of

numeric characters [‘0’ - ‘9’] that are present in the ASCII ‘.’ terminated string of your name

and your student ID that you have implemented in task 2.1. The subroutine also needs to print

this count (i.e. the number of numeric characters that are present in the string).

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 “StringAdd” that holds the start address

of the string (like, addrNameID) that you want to use. Then, you should call the subroutine

subCountNumerics. In the subroutine, the codes should then load a character from that

address, include it in your count if it is a numeric character, then increment the address by

one, and keep doing that until the character loaded from the address is a ‘.’ (which signals the

end of the string). After completing the counting process, your program will print the count, for

which the output may look similar to the output below.

8

10

Note: it is not always name followed by ID, it could be any mixed (ex, John, 2123, Nguyen.),

it includes 10 alphabets and 4 numbers.

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 6

2.5 A subroutine to read alphabets from keyboard, store them in a

string, and later, print the string (10 marks)

Prepare a MARIE subroutine called subSeperateAlpha that should read any character

from keyboard, and accepts only the alphabets ([‘A’ - ‘Z’] or [‘a’ - ‘z’]), to store in an ASCII ‘.’

terminated string. You need to store the ‘.’ character in the memory to mark the end of the

string. The subroutine also needs to print this string.

You may use the memory address “Hex100” or “Hex 200” to store your string depending on

the length of your program code. Ideally, the string location should be well higher in memory

than the last memory location used by your program.

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 “StringAdd” that will hold a memory

location in MARIE as the start address of the string that you are going to enter from the

keyboard. Then, you should call the subroutine subSeperateAlpha. In the subroutine,

the codes should then read a character from the keyboard, accept it if it is an alphabet, then

increment the address by one, and keep doing that until the character entered is a ‘.’, which

signals the end of the data entry process. You need to store the ‘.’ character as well. After

completing the name entry process, your program will print the string, for which the output may

look similar to the output below.

11

Input: Australi3700a,.

Output: Australia

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.

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.5 name them as below:

● 2_1_NameIDString.mas

● 2_2_PrintNameID.mas

● 2_3_CountAlpha.mas

● 2_4_CountNumeric.mas

● 2_5_SeperateAlpha.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).


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。