0% found this document useful (0 votes)
64 views

Introduction To Computing (CS101) : Assignment # 01 Spring 2021

The document provides instructions for Assignment #01 in the course CS101 Introduction to Computing. It outlines rules for marking including submission format and deadline. It also notes that no late assignments or extensions will be accepted. The document includes two questions worth 10 marks each related to binary addition and conversion to ASCII and decimal codes.

Uploaded by

Tahir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Introduction To Computing (CS101) : Assignment # 01 Spring 2021

The document provides instructions for Assignment #01 in the course CS101 Introduction to Computing. It outlines rules for marking including submission format and deadline. It also notes that no late assignments or extensions will be accepted. The document includes two questions worth 10 marks each related to binary addition and conversion to ASCII and decimal codes.

Uploaded by

Tahir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Introduction to Computing Total marks = 20

(CS101)
Assignment # 01 24 May 2021
Spring 2021

Please carefully read the following instructions before attempting assignment.

RULES FOR MARKING


It should be clear that your assignment would not get any credit if:
 The assignment is submitted after the due date.
 The submitted assignment does not open or file is corrupt.
 Strict action will be taken if submitted solution is copied from any other student or
from the internet.

You should consult the recommended books to clarify your concepts as handouts are not
sufficient.

You are supposed to submit your assignment in .doc or docx format.


Any other formats like scan images, PDF, zip, rar, ppt and bmp etc will not be accepted.

Objectives:
 To understand how computers manipulate and store data.
 To learn how computers are programmed by means of machine language
instructions.

NOTE

No assignment will be accepted after the due date via email in any case (whether it is the
case of load shedding or internet malfunctioning etc.). Hence, refrain from uploading
assignment in the last hour of deadline. It is recommended to upload solution file at least
two days before its closing date.

If you find any mistake or confusion in assignment (Question statement), please consult
with your instructor before the deadline. After the deadline, no queries will be entertained
in this regard.

For any query, feel free to email at:


[email protected]
Questions No 01 Marks (10)

Given is a snapshot of memory addresses E2 to F4 and CPU registers 0 to F. All bit patterns
in the memory cells are represented in hexadecimal notation.

Figure 1: Snapshot of a program stored in main memory for execution

Assume that the Program Counter has E2 as its initial value. Using the information provided
in the above Figure 1, answer the following questions.
1. Determine the contents of register 1 when the machine halts.
2. Write down the bit pattern (in hexadecimal) at memory address F3 when the Halt
instruction is executed.
3. How many times the machine instruction at address EE is executed before the machine
halts.
4. Determine the contents of register 0 after the instruction at address EC is executed.
5. Determine the contents of register 2 when the instruction at address F0 is executed.
Note: Use the table provided in Appendix C at page 581 of book.
Solution:
1. 03 (Check step 7)
2. 03 (Check step 7)
3. Never (Program halts without executing this instruction)
4. 03 (Check step 6)
5. 05 (Check step 7)
Note: Simple dry run of the program is given as follows. You can go through it to verify answers
of question#1.
Since, a machine cycle starts at fetch stage, then decode and lastly execution. Hence, CPU will
start executing stored program in memory by fetching first instruction pointed to by the Program
Counter (PC).

Step 1

Fetch:
PC=E2
IR=15F2
PC is then incremented to the address of next instruction in program sequence that is,
PC=E4.
Decode:
We have 15F2 in IR and its opcode is 1, which means it is a LOAD instruction.
Execute:
Contents of memory address F2 will be copied from memory to register 5. Register 5
now contains 02.
Step 2

Fetch:
PC=E4
IR=12F4
PC is incremented, PC=E6.
Decode:
IR contains 12F4. Opcode is 1, so it is a LOAD instruction.
Execute:
Contents of memory address F4 will be copied from memory to register 2. Register 2
now contains 05.
Step 3

Fetch:
PC=E6
IR=5115
PC is incremented, PC=E8.
Decode:
IR contains 5115. Opcode is 5, so it is an ADD instruction.
Execute:
Hexadecimal numbers in register 1 and register 5 are added.
Register 1 = 01
Register 5 = 02
By adding them, we get 01+02=00000001 + 00000010 = 00000011 = 03
This 03 will be copied to register 1.
Step 4

Fetch:
PC=E8
IR=31F3
PC is incremented, PC=EA.
Decode:
IR contains 31F3, opcode is 3 so, this is a STORE instruction.
Execute:
Contents of register 1 are copied to memory address F3.
Step 5

Fetch:
PC=EA
IR=5003
PC is incremented, PC=EC.
Decode:
IR contains 5003, this is an ADD instruction.
Execute:
Hexadecimal numbers in register 0 and register 3 are added.
Register 0 = 02
Register 3 = 01
By adding them, we get 02+01=00000010 + 00000001 = 00000011 = 03
This 03 will be copied to register 0.
Step 6

Fetch:
PC=EC
IR=B1F0
PC is incremented, PC=EE.
Decode:
IR contains B1F0, this is a JUMP instruction.
Execute:
Contents of register 1 are compared with register 0. Since, both registers have same
numbers in them, hence, PC is updated with memory address F0. Now, PC=F0
Step 7

Fetch:
PC=F0
IR=C000
PC is incremented, PC=F2
Decode:
IR contains C000, this is a HALT instruction.
Execute:
When machine instruction C000 is executed then the program halts. No more
instructions of this program will be executed.
Questions No 02 Marks (10)

a. Perform binary addition on given numbers:


1 1
20 16 and 7 4.

Solution:
1
1 0 1 0 0 . 0 0 0 1 = 20
16
1
00111.0100=74
_________________
5
1 1 0 1 1 . 0 1 0 1 = 27 16

b. Convert the following binary number into ASCII code and then into its equivalent
decimal representation.
01001001010000010100110101011100

Solution:
Binary: 01001001 01000001 01001101 01011100
ASCII: I A M \
Decimal: 73 65 77 92

You might also like