Assignment 02
Assignment 02
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.
Assigned WORD
Short for Assigned WORD W
WORD in DECIMAL(W) 7823
Convert WORD to HEX (WH)
.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?
.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
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
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:
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
13
ID:__________ ASSIGNMENT # 3 [EE-213] Assigned Number:
10.
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.
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.
Device
A4
Device
A2
14