We have been working very hard since 2009 to facilitate in your learning Read More. We can't keep up without your support. Donate Now.

# www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# CS401 - Computer Architecture and Assembly Language Programming Assignment # 02

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

Views: 8039

### Replies to This Discussion

[org 0x0100]

jmp start

number: db 02
multiplicand: db 0
multiplier: db 0
multiResult: dw 0
squareResult: dd 0

square: mov [multiplicand], ax
mov [multiplier], ax
call multi
mov ax, [multiResult]
mov [squareResult], ax
ret

multi: mov cl, 8
mov bx, [multiplicand]
mov dx, [multiplier]

carryCheck: shr bx, 1
jnc skip

skip: shl bx, 1
dec cl
jnz carryCheck
ret

start: mov ax, [number]
call square
mov dx, [squareResult]
sub byte[number], 1
mov ax,[number]
mov[multiplicand], ax
mov byte[multiplier], 2

call multi

shr dx, 1 ;diviion by 2

mov ax, 0x4c00
int 0x21

naam thoray change kr k send krna mojain krro

How we can install nasm on Windows 64-Bit

What naam we can change

[Org 0x0100]
Jmp start
Number: db 02
Multiplicand: db 0
Multiplier: db 0
Multiresult: dw 1
Squraresult: dd 0

Square: mov [multiplicand], ax
Mov [multiplier], ax
Call multi
Mov [square result], ax
ret
Multi: movcl, 8
Mov bx, [multiplicand]
Mov dx, [multiplier]
Carry check: shr bx, 1
Jnc skip
Skip: shl bx, 1
Dec cl
Jnz carry check
Ret
Start: mov ax, [number]
Call square
Mov dx, [square result]
Sub byte [number], 1
Mov ax, [number]
Mov [multiplicand], ax
Mov byte [multiplier], 2

Call multi
Shr dx, 1; division by 2
Mov ax, 0x4c00
Int0x21

vvv thankss

SOLUTION:

[org 0x0100]

jmp start

number:      db02

multiplicand:db0

multiplier:    db0

multiResult:   dw0

squareResult:dd0

square:    mov[multiplicand], AX

mov[multiplier], AXcallmulti

movAX,[multiResult]mov[squareResult], AX

ret

multi:        movCL,8

movBX,[multiplicand]movDX,[multiplier]

carryCheck:    shr BX, 1jncskip

skip:      shl BX, 1

decCL

jnzcarryCheckret

start:        movAX,[number]

call  square

movDX,[squareResult]

subbyte[number],

2movAX,

[number]mov[multiplicand],

AXmovbyte[multiplier],

2call  multi

shr DX,1    ; divisionby2

movAX,0x4c00             ;ending programint0x21

Q 1: Write a complete assembly language code for the following pseudo code:
Initialize a variable named “NUM1” with “04 as a Hexadecimal Number”
Initialize a variable named “NUM2” with “08 as a Hexadecimal Number”
Initialize a variable named “NUM3” with “12 as a Hexadecimal Number”
Initialize a variable named “NUM4” with “00 as a Hexadecimal Number”
Initialize AX with zero “0”
Initialize BX with zero “0”
Move NUM1 into AX
Move NUM2 into BX
Move NUM3 into BX
Store AX into NUM4

Solution :
[org 0x0100]
mov bx, 0
mov ax ,[num1]
mov bx ,[num2]
mov bx, [num3]
mov [num4], ax
mov ax, 0x4c00
Int 0x21
num1: dw 4
num2: dw 8
num 3: dw 12
num 4: dw 00

Questions No 02 10 marks
Suppose, we have the following register values:

AX 0150
BX AB5D
CX FF0A
DX 1234
DS CC20
CS EF10
ES 225F
SS E25F
SI 1212
SP CD0F
BP 95F8
DI BDEF

You are required to calculate the physical address generated by each of the following instructions.

MOV DX, [SP+1652H]

Note: Each provided instruction is independent.
Solution:
Effective Address EA= Base +Index +Offset
=0x AB5D +0x BDEF +0x0000
=0x 1694c
= 0x000*0x10+0x0110
=0x120
Effective Address EA = Base + Index + Offset
=0x AB5D + 0x000 +0x1652
=0xC1AF
= 0x0000 * 0x10 + 0xc1AF
=0xC1BF

This solution is for assignment 1.. and we are having assignment 2 now

Check another Idea

Attachments:

ye bilkul thek solution hy kiya...???

## HELP SUPPORT

This is a member-supported website. Your contribution is greatly appreciated!

.