Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

COMPUTER ORGANIZATION &

ASSEMBLY LANGUAGE (EE-229)


ASSIGNMENT # 3
ID: __________ NAME: __________________ SECTION: ____
Read the Instructions Carefully

 Assigned number is given to you in excel sheet provided with this assignment. Consider the assigned number as a
decimal number. Also, your name will be used too, look at the below examples.

FOR EXAMPLE: If your assigned number is 7823, A0 is the first digit of the assigned number.

Assign Digit 0 Assign Digit 1 Assign Digit 2 Assign Digit 3


Short for Assigned Digit A0 A1 A2 A3
Write Assigned Number Digit By Digit 7 8 2 3
Assigned Byte 0 Assigned Byte 1
Short for Assigned BYTE B0 B1
Byte in DECIMAL 78 23
Convert byte to HEX B0H, B1H

Convert byte BINARY B0B, B1B

Assigned WORD
Short for Assigned WORD W
WORD in DECIMAL(W) 7823
Convert WORD to HEX (WH)

Convert byte BINARY (WB)

Assigned double WORD in HEXA (DH) 78237823H


EXAMPLE: Name is HAMZA DAUD
 If your name starts with MUHAMMAD kindly use your second name

ZERO FIRST SECOND THIRD FOURTH FIFTH SIXTH


CHARACTER CHARACTER CHARACTER CHARACTER CHARACTER CHARACTER CHARACTER
OF YOUR OF YOUR OF YOUR OF YOUR OF YOUR OF YOUR OF YOUR
NAME NAME NAME NAME NAME NAME NAME
Short for
C0 C1 C2 C3 C4 C5 C6
CHARACTER
YOUR NAME
CHARACTER
BY H A M Z A D A
CHARACTER
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
1. Consider the following code and fill the given registers and memory accordingly after each step?

.data
Multiplicand db A0 ; Consider Assigned Number Digit A0
Multiplier db A3 ; Consider Assigned Number Digit A3
Result db 0
.code
mov ax,@data
mov ds,ax
mov ax,0
mov cl,4
mov al,multiplicand
mov bl,multiplier
checkbit:
shr bl,1
jnc skip
add result,al

skip:
shl al,1
loop checkbit

al bl
CF multiplicand Multiplier CF result

2
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
2. Consider the following code and fill given registers and memory accordingly after each step?

;NOTE ;ADC is add through carry

ADC ax, bx ;AX=AX+BX+CF(carry flag)

.data
multiplicand dd WH ;Hexa of assigned word
multiplier dw 005AAH
result dd 0
.code
mov ax,@data
mov ds,ax
mov ax,0
mov cl,16 ;initialize bit count to 16
mov dx, multiplier ;initialize bit mask
checkbit:
shr dx,1
jnc noadd ;skip addition if no carry
mov ax, word ptr[multiplicand] ;mov LSW of multiplicand to ax
add word ptr[result],ax ;add LSW of multiplicand to result
mov bx, word ptr[multiplicand+2] ;mov MSW of multiplicand to bx
adc word ptr[result+2],bx ;add MSW of multiplicand to result
noadd:
shl word ptr[multiplicand],1 ;shift LSW multiplicand to left
rcl word ptr[multiplicand+2],1;rotate MSW of multiplicand to left
Loop checkbit ;jump to check bit in not zero
mov ah,04ch

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

3
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

bx ax
CF Multiplicand+2 CF Multiplicand

dx
multiplier CF Result+2 Result

4
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:

3. Modify and Rewrite the code in Question 2 for following data declaration?

.data
multiplicand DQ DH ;value of Assigned doubleword in hexa
multiplier DW WH ;Assigned word in hexa
result DQ 0 ;result of the multiplication

5
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
4. Perform unsigned binary multiplication using following given flow chart?
NOTE: Your computer width is 8-bit, Multiplicand is (B0B)2 of the assigned number and Multiplier is (B1B)2 of the
assigned number

C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)


Add
Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add
Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add
Shift

6
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add
Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add
Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add

Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add

Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add

Shift

C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)


Add

Shift
C A (ACCUMULATOR) Q (MULTIPLIER) M (MULTIPLICAND)
Add

Shift

7
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
5. Perform Multiplication using Booth’s algorithm?

NOTE: Your computer width is 10-bit, Multiplicand is 2’s complement of B1H assigned number (Means it’s a signed
and negative number), Multiplier is 0A5H

8
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:

A (ACCUMULATOR) Q (MULTIPLIER) Q-1 M (MULTIPLICAND)


Add 10
Shift

Add 9
Shift

Add 8
Shift

Add 7
Shift

Add 6
Shift

Add 5
Shift

Add 4
Shift

Add 3
Shift
Add 2
Shift

Add 1
Shift

9
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
6. Perform Unsigned binary division?
NOTE: Your computer width is 8-bit, where dividend B1H of assigned number, Divisor is 003H

10
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:

11
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
7. Write a program that Left shifts characters of your name three times. Treat it as an array and write final result in
HEX

nameSTRING db ‘C0’, ‘C1’, ‘C2’, ‘C3’, ‘C4’, ‘C5’, ‘C6’, ‘C7’, ‘C8’, ‘C9’
; C0 is first character of your name
; C9 is tenth character of your name

12
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
8. Represent assigned number using 32-bit floating point representation (B1.625)10
NOTE: B1 is assigned number

9. Represent assigned number using 64-bit floating point representation (W.384765625)10


NOTE: B1 is assigned number

13
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
10.

The 16-bit hypothetical machine has the following instructions:

0001 Load AC from memory


0010 Store AC to memory
0101 Add to AC from memory
0011 Load AC from I/O
0111 Store AC to I/O

The instruction has the following format:

4 bits 12 bits
OpCode Address

In these cases, the 12-bit address identifies a particular memory address or an I/O device.

The machine also has the following registers: AC, IR, PC, MAR, MBR, IOAR, IOBR.

Show the program execution for the following program:

1. Load AC from device A4.


2. Add contents of memory location 940.
3. Store AC to device A2.

Assume that the first instruction is at memory location A0 A1 A2. Also, assume that the next value retrieved
from device A4 is A4 and that location 940 contains a value of WH.

Fill in the below table, to trace the execution of the code.

Load AC from device 5 Add content of Store AC to device 6


mem940
Fetch Execute Fetch Execute Fetch Execute
PC
IR
AC
MAR
MBR
IOAR
IOBR

Device
A4
Device
A2

14

You might also like