Computers, Data and Programming - Assignment 1
VerifiedAdded on 2023/01/16
|9
|2055
|2
AI Summary
This document is Assignment 1 for the subject Computers, Data and Programming. It includes questions related to base conversion, number representation, and programming in MARIE simulator. The document also discusses interrupts in a computer system and the benefits of using a multiple-bus architecture.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Assignment 1
Computers, data and programming
ITC544
Student Name
Student numebr
Computers, data and programming
ITC544
Student Name
Student numebr
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
Question 1.
a) Determine the value of base b if (152)b = 0x6A. Please show all steps. [3 marks]
b^2 * 1 + b^1 *5 + b^0 *2 = b2 + 5b + 2
0x6A = 16^1 *6 + 16^0*10 = 96 + 10 = 106d
Comparing two sides
b2 + 5b + 2 = 106
solving equation gives
b2 + 5b + -104 = 0
(b - 8) (b + 13) = 0
b = 8 or b = 13
b is base and cannot be –ve so Base b = 8
b) Convert the followings: (Please show all steps; no marks will be awarded if no steps are
shown) [1.5x4 = 6 marks]
i) 0xBAD into 3-base representation
0xBAD = B * 16^2 + A*16^1 + D *16^0
= 11 * 256 + 10 * 16 + 13 * 1
= 2989
Conversion to Base 3
2989/3 = 996 R 1
996/3 = 332 R 0
332/3 = 110 R 2
110/3 = 36 R 2
36/3 = 12 R 0
12 / 3 = 4 R 0
4 / 3 = 1 R 1
1 / 3 = 0 R 1
Then 0xBAD = 110022013
ii) 3217 into 2-base (binary) representation
3217 /2 = 1608 R 1
1608/2 = 804 R 0
804/2 = 402 R 0
402/2 = 201 R 0
Page 2 of 9
a) Determine the value of base b if (152)b = 0x6A. Please show all steps. [3 marks]
b^2 * 1 + b^1 *5 + b^0 *2 = b2 + 5b + 2
0x6A = 16^1 *6 + 16^0*10 = 96 + 10 = 106d
Comparing two sides
b2 + 5b + 2 = 106
solving equation gives
b2 + 5b + -104 = 0
(b - 8) (b + 13) = 0
b = 8 or b = 13
b is base and cannot be –ve so Base b = 8
b) Convert the followings: (Please show all steps; no marks will be awarded if no steps are
shown) [1.5x4 = 6 marks]
i) 0xBAD into 3-base representation
0xBAD = B * 16^2 + A*16^1 + D *16^0
= 11 * 256 + 10 * 16 + 13 * 1
= 2989
Conversion to Base 3
2989/3 = 996 R 1
996/3 = 332 R 0
332/3 = 110 R 2
110/3 = 36 R 2
36/3 = 12 R 0
12 / 3 = 4 R 0
4 / 3 = 1 R 1
1 / 3 = 0 R 1
Then 0xBAD = 110022013
ii) 3217 into 2-base (binary) representation
3217 /2 = 1608 R 1
1608/2 = 804 R 0
804/2 = 402 R 0
402/2 = 201 R 0
Page 2 of 9
201/2 = 100 R 1
100/2 = 50 R 0
50/2 = 25 R 0
25/2 = 12 R 1
12/2 = 6 R 0
6/2 = 3 R 0
3/2 = 1 R 1
1 / 2 = 0 R 1
3217 = 110010010001b
iii) 1235 into octal representation
1235 / 8 = 154 R 3
154 / 8 = 19 R 2
19 / 8 = 2 R 3
8 / 3 = 0 R 2
1235 = 23238
iv) 21.218 into decimal representation
21.218 = 21.218 * 1000 / 1000
= 21218 / 1000
c) Given a (very) tiny computer that has a word size of 3 bits, what are the lowest value
(negative number) and the highest value (positive number) that this computer can represent in
each of the following representations? [3 marks]
i) One's complement
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1) -1) = - (2(3-1) -1) = -(22 -1) = - 3
ii) Two's complement
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1)) = - (2(3-1)) = -(22 ) = - 4
iii) Signed Magnitude
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1) -1) = - (2(3-1) -1) = -(22 -1) = - 3
Page 3 of 9
100/2 = 50 R 0
50/2 = 25 R 0
25/2 = 12 R 1
12/2 = 6 R 0
6/2 = 3 R 0
3/2 = 1 R 1
1 / 2 = 0 R 1
3217 = 110010010001b
iii) 1235 into octal representation
1235 / 8 = 154 R 3
154 / 8 = 19 R 2
19 / 8 = 2 R 3
8 / 3 = 0 R 2
1235 = 23238
iv) 21.218 into decimal representation
21.218 = 21.218 * 1000 / 1000
= 21218 / 1000
c) Given a (very) tiny computer that has a word size of 3 bits, what are the lowest value
(negative number) and the highest value (positive number) that this computer can represent in
each of the following representations? [3 marks]
i) One's complement
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1) -1) = - (2(3-1) -1) = -(22 -1) = - 3
ii) Two's complement
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1)) = - (2(3-1)) = -(22 ) = - 4
iii) Signed Magnitude
Highest Positive Value = 2(N-1) -1 = 2(3-1) -1 = 22 -1 = + 3
Highest Negative Value = -(2(N-1) -1) = - (2(3-1) -1) = -(22 -1) = - 3
Page 3 of 9
Question 2.
a) The Fibonacci numbers are the numbers in the following integer sequence, called the
Fibonacci sequence, and are characterised by the fact that every number after the first two is
the sum of the two preceding ones: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 114, … etc.
By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each
subsequent number is the sum of the previous two. We define Fib(0)=0, Fib(1)=1, Fib(2)=1,
Fib(3)=2, Fib(4)=3, etc. The first 22 Fibonacci numbers given below:
Fib(0)
Fib(1)
Fib(2)
Fib(3)
Fib(4)
Fib(5)
Fib(6)
Fib(7)
Fib(8)
Fib(9)
Fib(10)
0
1
1
2
3
5
8
13
21
34
55
Fib(11)
Fib(12)
Fib(13)
Fib(14)
Fib(15)
Fib(16)
Fib(17)
Fib(18)
Fib(19)
Fib(20)
Fib(21)
89
144
233
377
610
Page 4 of 9
a) The Fibonacci numbers are the numbers in the following integer sequence, called the
Fibonacci sequence, and are characterised by the fact that every number after the first two is
the sum of the two preceding ones: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 114, … etc.
By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each
subsequent number is the sum of the previous two. We define Fib(0)=0, Fib(1)=1, Fib(2)=1,
Fib(3)=2, Fib(4)=3, etc. The first 22 Fibonacci numbers given below:
Fib(0)
Fib(1)
Fib(2)
Fib(3)
Fib(4)
Fib(5)
Fib(6)
Fib(7)
Fib(8)
Fib(9)
Fib(10)
0
1
1
2
3
5
8
13
21
34
55
Fib(11)
Fib(12)
Fib(13)
Fib(14)
Fib(15)
Fib(16)
Fib(17)
Fib(18)
Fib(19)
Fib(20)
Fib(21)
89
144
233
377
610
Page 4 of 9
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
987
1597
2584
4181
6765
10946
Write a MARIE program to calculate Fib(n), where the user inputs n. For example, if the user
inputs 7, the program outputs the value 13; if the user inputs 15, the program outputs the
value 610; if the user inputs 20, the program outputs the value 6765 and so on. You need to
write and run the program using MARIE simulator. Please include appropriate comments to
make your code readable.[8 marks]
ORG 0
/ Get user input for Fib (n)
INPUT
SUBT ONE / Skip Fib0
STORE Fibn / Store input in Variable Fibn
/ Check if Fibn is greater than 0
fibloop, LOAD Fibn / Get Fibn into AC
SKIPCOND 800 / Skip cond if AC = 0
JUMP exitfib
/ Here if Fibn is > 0 ; start loop to calculate Fibn
/ Fibn2 = Fibn1 + Fibn0
LOAD Fibn
SUBT ONE / Set AC = Fibn - 1
STORE Fibn / Fibn = Fibn - 1
CLEAR / Set AC to 0
ADD Fibn0 / AC + Fibn0
ADD Fibn1
/ AC + Fibn1 => AC = Fibn0 + Fibn1
STORE Fibn2
/ Fibn2 = AC => Fibn2 = Fibn0 + Fibn1
/ OUTPUT / for Debug output result every iteration
/ Update Fibn1 and Fibn0 for next iteration
LOAD Fibn1
STORE Fibn0 / Fibn0 = Fibn1
LOAD Fibn2
STORE Fibn1 / Fibn1 = Fibn2
Page 5 of 9
1597
2584
4181
6765
10946
Write a MARIE program to calculate Fib(n), where the user inputs n. For example, if the user
inputs 7, the program outputs the value 13; if the user inputs 15, the program outputs the
value 610; if the user inputs 20, the program outputs the value 6765 and so on. You need to
write and run the program using MARIE simulator. Please include appropriate comments to
make your code readable.[8 marks]
ORG 0
/ Get user input for Fib (n)
INPUT
SUBT ONE / Skip Fib0
STORE Fibn / Store input in Variable Fibn
/ Check if Fibn is greater than 0
fibloop, LOAD Fibn / Get Fibn into AC
SKIPCOND 800 / Skip cond if AC = 0
JUMP exitfib
/ Here if Fibn is > 0 ; start loop to calculate Fibn
/ Fibn2 = Fibn1 + Fibn0
LOAD Fibn
SUBT ONE / Set AC = Fibn - 1
STORE Fibn / Fibn = Fibn - 1
CLEAR / Set AC to 0
ADD Fibn0 / AC + Fibn0
ADD Fibn1
/ AC + Fibn1 => AC = Fibn0 + Fibn1
STORE Fibn2
/ Fibn2 = AC => Fibn2 = Fibn0 + Fibn1
/ OUTPUT / for Debug output result every iteration
/ Update Fibn1 and Fibn0 for next iteration
LOAD Fibn1
STORE Fibn0 / Fibn0 = Fibn1
LOAD Fibn2
STORE Fibn1 / Fibn1 = Fibn2
Page 5 of 9
/ Compare Fibn to 1 if not then loop
JUMP fibloop
exitfib, LOAD Fibn2
OUTPUT
End, HALT / HALT process
/<<<<<<<<< Data Section
Fibn, DEC 0 / Input from user is stored here
Fibn2, DEC 0 / Fib (n + 2) = Fib (n + 1) + Fib (n + 0)
Fibn1, DEC 1
Fibn0, DEC 0
/<<<<<<<< Constant values
ZERO, DEC 0
ONE, DEC 1
b) For some values of n, your program will not produce correct results. You can check this by
gradually increasing the values of n and checking for the correct outputs. What is the
maximum value of n for which your program produces a correct result? Why? Please
comment on this [3 marks].
Received Fib numbers till 23 correctly, it started giving out negative numbers
from 24 onwards. Reason is limited size of registers in MARIE i.e. 16 bits.
Given that it needs to handle negative numbers as well total positive numbers
that can be represented are limited to 15 bits. That turns out to be from 0 to
2^15 -1 ( 0 to 32767)
Page 6 of 9
JUMP fibloop
exitfib, LOAD Fibn2
OUTPUT
End, HALT / HALT process
/<<<<<<<<< Data Section
Fibn, DEC 0 / Input from user is stored here
Fibn2, DEC 0 / Fib (n + 2) = Fib (n + 1) + Fib (n + 0)
Fibn1, DEC 1
Fibn0, DEC 0
/<<<<<<<< Constant values
ZERO, DEC 0
ONE, DEC 1
b) For some values of n, your program will not produce correct results. You can check this by
gradually increasing the values of n and checking for the correct outputs. What is the
maximum value of n for which your program produces a correct result? Why? Please
comment on this [3 marks].
Received Fib numbers till 23 correctly, it started giving out negative numbers
from 24 onwards. Reason is limited size of registers in MARIE i.e. 16 bits.
Given that it needs to handle negative numbers as well total positive numbers
that can be represented are limited to 15 bits. That turns out to be from 0 to
2^15 -1 ( 0 to 32767)
Page 6 of 9
Question 3.
a) What are the 'interrupts' in a computer system? Describe the approache****** deal ******
multiple interrupts in a system. [4 marks]
Interrupts are signal to the computer asking it to halt current execution stream of
instructions and execute a specialized sequence of operations to service a
request. An I/O device uses this process to ask CPU for work or notify CPU
about completion of previous activity. Some interrupts have higher priority than
other interrupts. In this case higher priority interrupt is serviced before the lower
priority interrupt.
Switching of computer from one program to another or to interrupt service
routine is called context switching. Computer handles multiple interrupts using
two approaches.
i. Masking other interrupts: once it enters a service routine for a choosen
interrupt, it disables or masks the other interrupt sources and hence
cannot be interrupted by any other device.
ii. Nested interrupts: the system is into middle of a service routine and it
receives another interrupt of higher priority, then computer would
perform another context switch, jump to service routine of the new
interrupt finish its execution there and return to this lower priority
interrupt. Finish this routine and return to main program. This nesting
of interrupts can happen at more than one level of nesting depending
upon number of interrupts and priorities of incoming interrupts.
types-of-interrupts-and-how-to-handle-interrupts. (2015, 08 20). Retrieved from
https://www.electronicshub.org/: https://www.electronicshub.org/types-of-interrupts-and-how-to-
handle-interrupts/
Page 7 of 9
a) What are the 'interrupts' in a computer system? Describe the approache****** deal ******
multiple interrupts in a system. [4 marks]
Interrupts are signal to the computer asking it to halt current execution stream of
instructions and execute a specialized sequence of operations to service a
request. An I/O device uses this process to ask CPU for work or notify CPU
about completion of previous activity. Some interrupts have higher priority than
other interrupts. In this case higher priority interrupt is serviced before the lower
priority interrupt.
Switching of computer from one program to another or to interrupt service
routine is called context switching. Computer handles multiple interrupts using
two approaches.
i. Masking other interrupts: once it enters a service routine for a choosen
interrupt, it disables or masks the other interrupt sources and hence
cannot be interrupted by any other device.
ii. Nested interrupts: the system is into middle of a service routine and it
receives another interrupt of higher priority, then computer would
perform another context switch, jump to service routine of the new
interrupt finish its execution there and return to this lower priority
interrupt. Finish this routine and return to main program. This nesting
of interrupts can happen at more than one level of nesting depending
upon number of interrupts and priorities of incoming interrupts.
types-of-interrupts-and-how-to-handle-interrupts. (2015, 08 20). Retrieved from
https://www.electronicshub.org/: https://www.electronicshub.org/types-of-interrupts-and-how-to-
handle-interrupts/
Page 7 of 9
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
b) Analyse the benefits of using a multiple-bus architecture compared to single-bus architecture for
a computer system. [3 marks]
Multiple bus architecture enhances use of pipelined architecture by allowing
parallel access to memory for data and instruction at same clock cycle. This
allows stall free execution of program from memory perspective. Single bus
stalls access to data or to instruction in memory causing process to wait either
for data or instruction and hence leading to inefficient utilization.
Same case applies to I/O Access from CPU. When multiple buses are available,
CPU can access I/O devices in parallel to memory access without halting the
fetch or memory read write operations. These together affect the speed and
performance of the CPU and enhance its throughput.
Papiewski, John. (n.d.). What Are the Benefits of Using Multiple-Bus Architecture Compared to
Single-Bus Architecture? Small Business - Chron.com. Retrieved from
http://smallbusiness.chron.com/benefits-using-multiplebus-architecture-compared-singlebus-
architecture-72173.html
Page 8 of 9
a computer system. [3 marks]
Multiple bus architecture enhances use of pipelined architecture by allowing
parallel access to memory for data and instruction at same clock cycle. This
allows stall free execution of program from memory perspective. Single bus
stalls access to data or to instruction in memory causing process to wait either
for data or instruction and hence leading to inefficient utilization.
Same case applies to I/O Access from CPU. When multiple buses are available,
CPU can access I/O devices in parallel to memory access without halting the
fetch or memory read write operations. These together affect the speed and
performance of the CPU and enhance its throughput.
Papiewski, John. (n.d.). What Are the Benefits of Using Multiple-Bus Architecture Compared to
Single-Bus Architecture? Small Business - Chron.com. Retrieved from
http://smallbusiness.chron.com/benefits-using-multiplebus-architecture-compared-singlebus-
architecture-72173.html
Page 8 of 9
Rationale
back to top
This assessment task will assess the following learning outcome/s:
be able to investigate and describe the essential elements of a computer and their
functionalities.
be able to apply an understanding of data representations and calculations to practical
situations.
be able to develop an elementary computer program.
Presentation:
File naming convention: When you upload files to the TURNITIN for this subject, please use
your student ID and Assignment number to name your files. For example,
123456_Assignment1.doc or 123456_Assignment1.docx etc (where 123456 is your Student
ID)
Please also adhere to the following formatting rules:
Please also adhere to the following formatting rules:
1. For Q2(a) you need to submit a *.mas file.
2. Please compose the answers of rest of the questions 3 in a document file (doc or docx
format). Please do not submit in pdf formats. Please upload the document in the TURNITIN
within deadline.
3. You may put the mas file and document file in a folder, compress the folder and upload the
compressed file to the TURNITIN. You may also upload the two files separately.
4. The first page (cover page) of the document file should have the following information
clearly mentioned:
a. Your full name
b. Your Student ID
c. Subject Code (ITC544)
d. Assessment item number and name (Assignment 1: Computers, data and programming)
5. Each page should have page numbers in “page x of y” format (including the cover page).
6. Please use APA version 6 referencing style where appropriate.
Page 9 of 9
back to top
This assessment task will assess the following learning outcome/s:
be able to investigate and describe the essential elements of a computer and their
functionalities.
be able to apply an understanding of data representations and calculations to practical
situations.
be able to develop an elementary computer program.
Presentation:
File naming convention: When you upload files to the TURNITIN for this subject, please use
your student ID and Assignment number to name your files. For example,
123456_Assignment1.doc or 123456_Assignment1.docx etc (where 123456 is your Student
ID)
Please also adhere to the following formatting rules:
Please also adhere to the following formatting rules:
1. For Q2(a) you need to submit a *.mas file.
2. Please compose the answers of rest of the questions 3 in a document file (doc or docx
format). Please do not submit in pdf formats. Please upload the document in the TURNITIN
within deadline.
3. You may put the mas file and document file in a folder, compress the folder and upload the
compressed file to the TURNITIN. You may also upload the two files separately.
4. The first page (cover page) of the document file should have the following information
clearly mentioned:
a. Your full name
b. Your Student ID
c. Subject Code (ITC544)
d. Assessment item number and name (Assignment 1: Computers, data and programming)
5. Each page should have page numbers in “page x of y” format (including the cover page).
6. Please use APA version 6 referencing style where appropriate.
Page 9 of 9
1 out of 9
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.