You are on page 1of 3

Total marks: 20

Good effort
See solution file for detailed solution. Follow this
marked file for detailed marking

Assignment #01
CS101
NIAZ ALI (BC210205800)
Question No. 1
Solution:
Consider the following table when the PROGRAM COUNTER take “E2” as initial value and
then incremented by 2 till the end. For each value of the program counter the machine
language code is fetched into the instruction register. For each value of the program counter
the corresponding instruction code is written in the same row and is explained.

Program Instruction Register Instruction decoding/Explanation/execution


Counter
E2 15F2 Load the register 5 with contents of cell at address F2:
Register5=cell at F2=02
E4 12F4 Load the register 2 with contents of cell at address F4:
Register2=cell at F4=05
E6 5115 Add the contents of register 1 and 5 and place the result in 1:
Register1=Register1 + Register5 = 01+02=03
E8 31F3 Store the contents of register 1 in the cell at address F3:
Cell at F3=Register1=03
EA 5003 Add the contents of register 0 and 3 and place the result in 0:
Register0=Register0 + Register3 = 02+01=03
EC B1F0 Compare contents of register 1 with register 0, if same JUMP to
memory address F0 otherwise continue:
Register1=Register0; Jump to address F0
F0 C000 Halt

Ans (1): When the machine halts register 1 has content: 03.
Ans (2): When the halt instruction is executed the bit pattern at memory address F3 is: 03.
Ans (3): The machine instruction at EE is never executed before the machine halts.
Ans (4): the content of register 0 is: 03 after the instruction at address EC is executed
Ans (5): the content of register 2 is: 05 when the instruction at address F0 is executed
Marks: 10

correct solution

Question No. 2
1 1
(a): Perform binary addition on 20 and 7
16 4
Solution:

1 1 1 1
16 8 4 2 1 Radix
2 4 8 16
1
20
16 1 0 1 0 0 . 0 0 0 1

1
7 0 0 1 1 1 . 0 1 0 0
4

5
27 1 1 0 1 1 . 0 1 0 1
16

(20 161 ) =( 10100.001 )


10
2

(7 14 ) =( 00111.0100 )
10
2

5
(
( 10100.001 )2+ ( 00111.0100 )2=( 11011.0101 )2= 27
16 )
10

Marks: 5

correct solution

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

Solution:

Each ASCII code consists of 8 bits (1 byte). So we have the following ASCII codes
01001001

01000001

01001101

01011100

From appendix A of the text book, the above codes represents the following characters

01001001 I
01000001 A
01001101 M
01011100 \
Each of the above codes is converted into decimal as follows:

( 01001001 )2=26 +23 +20 =64+8+ 1=(73)10

( 01000001 )2=26 +20 =64+1=(65)10

( 01001101 )2 =26+ 23+ 22+2 0=64+ 8+4 +1=(77)10

( 01011100 )2=26 +2 4+ 23+ 22=64+16 +8+ 4=(92)10

Marks: 5

correct solution

The End

You might also like