Task 1 – Assembly programming
Your task is to write a program in assembly for the WASP processor. The program will work as a calculator. The user can input sums and the program will display the answer in decimals (base-10). I suggest you develop the program incrementally. Get a basic version working and then make it more complicated in stages. You will get marks for an incomplete program. If you want to attempt an easier version of the program, that’s okay.
I suggest five stages of development. For each of these, I will give you an indication of the mark you are likely to get, if this is as far as you have got. The exact mark will depend on other factors, such as whether it works reliably and how well you have used programming concepts in your code.
Very basic implementation – The user can enter three characters. The first will be a digit from 0 to 5. The second will be the “+” character. The third will be a digit from 0 to 4. Your program will add the two digits together and display the result.
For example, if the user enters:
CopyEdit
3+4
The program will display:
CopyEdit
7
A very basic implementation will get a mark of about 10 out of 50, depending on correctness and code quality.
Basic implementation – The user can enter three characters. The first will be a digit from 0 to 9. The second will be the “+” character or the “-“ character. The third will be a digit from 0 to 9. If the middle character is “+” the program will add the two numbers and display the result. If the middle character is “-“ the program will subtract the second number from the first and display the result. (It doesn’t have to work correctly for negative answers.)
For example, if the user enters:
CopyEdit
3+4
The program will display:
CopyEdit
7 or 07
If the user enters:
CopyEdit
7-2
The program will display:
CopyEdit
5 or 05
If the user enters:
https://youtu.be/PKVEIBirv-c
CopyEdit
9+7
The program will display:
CopyEdit
16
A basic implementation will get a mark of about 20 out of 50, depending on correctness and code quality.
Good implementation – The user can enter five characters. The first two will be a number from 00 to 99. The third will be the “+” character or the “-“ character. The last two characters will be a number from 00 to 99. If the middle character is “+” the program will add the two numbers and display the result. If the middle character is “-“ the program will subtract the second number from the first and display the result. (It doesn’t have to work correctly for negative answers or for answers greater than 99.)
For example, if the user enters:
CopyEdit
30+41
The program will display:
CopyEdit
71
If the user enters:
CopyEdit
77-22
The program will display:
CopyEdit
55
A good implementation will get a mark of about 30 out of 50, depending on correctness and code quality.
Full implementation – The user can enter five characters. The first two will be a number from 00 to 99. The third will be the “+” character or the “-“ character. The last two characters will be a number from 00 to 99. If the middle character is “+” the program will add the two numbers and display the result. If the middle character is “-“ the program will subtract the second number from the first and display the result. (It does not have to work correctly for negative answers.) The program will repeat in a loop, so the user can keep entering new sums without having to re-start the program. If the user makes an incorrect input, the program will display an error message.
For example, if the user enters:
CopyEdit
80+41
The program will display:
CopyEdit
121
If the user enters:
CopyEdit
x5+12
The program will display:
Developing an Assembly Language Calculator for the WASP Processor
go
CopyEdit
error
A full implementation should make use of functions and variables. The program should be clearly organised.
A full implementation will get a mark of about 40 out of 50, depending on correctness and code quality.
Advanced implementation
For marks above 40 out of 50, you should impress us. There are many ways to impress, and you don’t need to do all of them:
xx
as input.*
and /
.You may think of your own ways to make the program more complex or useful. That’s great. Show us at the demo, and if we are impressed, we can give you marks.
Demonstration
In the week 20th January to 24th January 2025, you will be asked to demonstrate your WASP program to the tutors. This will take place in a computing lab at the university. We will give you more information (including dates and times) before December 2024.
You do not need to prepare a presentation for this. We just want to see your program working. You will be sitting in front of a computer to demonstrate your code to a tutor, not presenting to the class. It should only take a few minutes. We will also ask you a few questions about your code, to make sure that you understand it and have written it yourself.
If you have a Student Accessibility Plan, and would like to demonstrate at an individual, private session, contact Chris Rook before 20th December 2024.
Paradigms of computation
You have a choice of three tasks: 2A, 2B, and 2C. You only need to complete one of these tasks.
Task 2A – Set theory
Use your understanding of set theory to explore the scenario below.
On a school sports day, there are several events at different times.
Event | Time |
---|---|
100 metre sprint | 10am |
1 kilometre run | 11am |
Javelin | 2pm |
Long jump | 2pm |
Cross country run | 3pm |
The children are arranged into three teams:
Team | Children |
---|---|
Thames | Ann, Dave, Gita, Jack |
Avon | Ben, Ellen, Harry, Karen |
Mersey | Claire, Fred, Ivy, Li, Mahmud |
Children take part in different events:
Event | Children |
---|---|
100 metre sprint | Ann, Ben, Harry, Ivy, Li |
1 kilometre run | Claire, Dave, Karen, Li, Gita |
Javelin | Ann, Ellen, Ivy, Jack, Mahmud |
Long jump | Ben, Harry, Karen, Jack, Li |
Cross country run | Claire, Dave, Ellen, Mahmud, Gita |
Write no more than 1000 words to answer the following questions:
Your word count does not include: anything written in set notation (including the contents of sets), reference lists, titles, diagrams, tables, program code or pseudocode.
Task 2B – Logic circuits
We want you to make a logic circuit similar to the ones we have done in class. To make sure you all have a different problem, we will use your student code to generate the problem. Your student code has eight digits. For example:
CopyEdit
20016432
Each digit is a number from 0 to 9.
You are going to create a logic circuit using Digital Works that provides four switches so the user can enter a number from 0 to 15 in binary. This number will be used to represent a possible value of a decimal digit from 0 to 9. (A four-digit binary number goes up to 15, of course. The numbers 10 to 15—or 1010 to 1111 in binary—are special cases, see below.)
For example, the switches below represent the binary value 0101
, or the digit "5".
The circuit will light up one or more LEDs, depending on the decimal equivalent of the binary value entered.
There are four LEDs, labelled as shown below:
Some digits will cause more than one LED to light up. For example, using the student code 20016432
:
1000
represents the digit "8". This is not part of the student code, so this will light up the "Not included" LED.0010
represents the digit "2". This is used twice in the student code, so will light up both the "Included" and "More than once" LEDs.0110
represents the digit "6". This is used in the student code and is the largest digit, so will light up both the "Included" and "Highest" LEDs.Other digits 0, 1, 3, 4, 5, 7, 9
will also light up one or more LEDs.
Binary values 1010
to 1111
represent numbers that cannot be a single decimal digit (larger than 9!) so these will always cause the "Not included" LED to light up.
Note that for this question, you should use your own student code, not the code 20016432
used in the examples above. This is to ensure that every student has a slightly different problem.
First, create a truth table showing all possible values of the four inputs and the four outputs for each binary value. You should label each column in the truth table.
Then use the Digital Works template provided to create a single circuit that has this behaviour. The template looks like this:
[Template image is likely referenced here in the original document]
Your circuit goes in the big space in the middle and connects the four vertical lines on the left (the input binary digit) to the four LEDs on the right. If you need more space, you can move the LEDs further right and/or down.
Q: Why are we using a template?
Q: What are all the things in the template?
[Further template details and explanation likely follow in the document]
Q: What are all the things in the template? (continued)
This line of four interactive inputs is where you can enter any 4-bit binary number. This is the "input" of the circuit. For convenience, we have attached a display so you can see what the decimal equivalent is of the binary number.
These four wires hold the binary input number. You will notice that they are not directly attached to the interactive inputs—that there is a macro box in between. That will be explained next. You should use these wires as the starting point for your circuit, connecting from them to your circuit to the right of them. The LEDs at the bottom show what values are held on the wires. There is another decimal output display showing the value of the current binary number on these wires. If you wish, you may add more vertical wires, for example, connected to NOT gates from each input wire. This seems to be a popular thing to do.
The mysterious macro box that separates the input from the signal wires is actually a counter. By default, it passes the input binary number straight through to the output binary number. This is how we expect you will work most of the time. If the interactive input labelled "count" is switched "on", instead of passing the input number through to the output, an internal binary counter counts from 0 to 15 and then starts again, continuously. This is included to allow rapid checking that the outputs are correct for all inputs. It is intended to speed up marking, but of course, you are free to use it for your own checking if you wish. The "reset" input to the left resets the counter to 0. It is only mildly useful.
Finally, write a short essay of up to 600 words, explaining:
The word count does not include: code, pseudocode, diagrams, tables, references, titles.
IMPORTANT:
Your submission for this task has three elements: the truth table, the circuit, and the essay. Your submission document should contain the truth table, a screenshot of the circuit, and the essay. You should also hand in the Digital Works circuit file. There are marks for submitting the file, so if you neglect to do so, you will not be awarded those marks.
Hints:
Task 2C – Turing machines and von Neumann architecture
You have been asked to create a video about Turing Machines for the "True Geek" channel. (Don’t look for it – I made it up.) You should aim the video for an audience of computer enthusiasts, such as knowledgeable students in their first year of a Computer Science degree.
Hi. Thanks for offering to make a video for the channel. A lot of our subscribers have been asking about Turing Machines. I can find information on Wikipedia, but it doesn’t have many good examples to explain what is going on. I would like a video that includes:
The video should be no more than 15 minutes long, or our subscribers will get bored and switch off. You can maybe go over by 10% if you are really interesting. You can use lecture slides if you want but try to make use of lots of visuals – preferably technical details, which our subscribers like. Don’t be afraid to include mathematics, as long as you explain it. If you use images from somewhere else, that’s fine, but make sure you provide references so we can get permission from the copyright owners.
You will use a tool called Panopto to create the video. It is the same tool I use for my lecture videos. I will provide guides showing you how to create and submit the video. There will be information about alternative tools, if you have trouble with Panopto.
What is a "walkthrough"? In this case, it means that you should show the system working step-by-step. Each execution cycle should be shown. If your example is long, it is okay to show the first five or six steps in detail, then the rest much more quickly.
You are not being marked for the quality of your editing or how many special effects you use. The marks are for the information you convey in the presentation.
To approach Task 1 – Assembly programming for the WASP processor, here's how you can systematically go about it:
3+4
or 7-2
) and output the result.3+4
).30+41
) for both addition and subtraction.+
and -
).
Here's a sample implementation for Stage 1 of Task 1 – a very basic calculator that adds two single-digit numbers. I'll walk you through the process and the code.
+
character, and a digit from 0 to 4.assembly
START: IN R1 ; Input first character (digit 0-5) IN R2 ; Input second character (must be '+') IN R3 ; Input third character (digit 0-4) SUB R1, R1, #48 ; Convert ASCII character to numeric value (R1 = R1 - '0') SUB R3, R3, #48 ; Convert ASCII character to numeric value (R3 = R3 - '0') ADD R4, R1, R3 ; Add the two numbers (R4 = R1 + R3) ADD R4, R4, #48 ; Convert numeric value to ASCII character (R4 = R4 + '0') OUT R4 ; Output the result character HALT ; Stop the program
3+4
.7
.+
or -
) and adjust the arithmetic operation accordingly.
Let's move on to Stage 2 of Task 1, where we enhance the calculator to support both addition and subtraction and handle digits from 0 to 9.
+
or -
), and another digit from 0 to 9.+
or -
.assembly
CopyEdit
START: IN R1 ; Input first character (digit 0-9) IN R2 ; Input second character (operator '+' or '-') IN R3 ; Input third character (digit 0-9) SUB R1, R1, #48 ; Convert ASCII character to numeric value (R1 = R1 - '0') SUB R3, R3, #48 ; Convert ASCII character to numeric value (R3 = R3 - '0') CMP R2, #43 ; Compare operator to ASCII value of '+' BEQ ADDITION ; If equal, branch to ADDITION label CMP R2, #45 ; Compare operator to ASCII value of '-' BEQ SUBTRACTION ; If equal, branch to SUBTRACTION label ERROR: OUT R2 ; Output an error character or message (optional) HALT ; Stop the program ADDITION: ADD R4, R1, R3 ; Perform addition (R4 = R1 + R3) B OUTPUT ; Branch to OUTPUT label SUBTRACTION: SUB R4, R1, R3 ; Perform subtraction (R4 = R1 - R3) B OUTPUT ; Branch to OUTPUT label OUTPUT: ADD R4, R4, #48 ; Convert numeric result back to ASCII character OUT R4 ; Output the result HALT ; Stop the program
R2
to the ASCII value of +
(which is 43).+
, branch to the ADDITION
section to perform addition.-
(which is 45).-
, branch to the SUBTRACTION
section.+
or -
.3+4
should output 7
.7-2
should output 5
.9+7
should output 16
.30+41
).Copyright © 2012 - 2025 Apaxresearchers - All Rights Reserved.