Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

FARYAL AWAIS

SP22-BCS-065-B

LAB No 2
Program Exercise 1 (solution):
Using only MOV, ADD, SUB, INC and DEC:

AX = BX – AX
MOV AX, 0050: Moves the value 0050 into AX
MOV BX, 0020: Moves the value 0020 into BX
SUB BX, AX: Subtracting the value of AX from BX and
stores in BX
MOV AX, BX: moves the value of BX to AX
AX = AX + 1
Incrementing the value of AX by 1.

CX = AX + BX
ADD AX, BX: Adds the value of BX into AX.
MOV CX, AX: Moves the value of AX into CX.

BX = BX-1d + 10d
DEC BX: Decrementing the value of BX by 1.
ADD BX, A: Add A to the value of BX.

AX = 5h – AX
MOV AX, 5: Move the value 5 into AX
SUB DX, AX: Subtracting the value of AX from DX.
MOV AX, DX: moves the value of DX to AX.

AX = 01001100b + 00011011b
FARYAL AWAIS
SP22-BCS-065-B

MOV AX,4C: Move the binary value 01001100 into AX which


is 4C in hexadecimal.
ADD AX,1B: Add the binary value 00011011 to AX which is
1B in hexadecimal.

BX = 10d + 23d + 32h


10(decimal) = A (Hexadecimal)
23(decimal) =17(Hexadecimal)
MOV BX, A: Moving the value A (hexadecimal) into BX
ADD BX, 17: Adding the value 17(hexadecimal) to BX
ADD BX, 32: Adding the hexadecimal value 32 to BX
FARYAL AWAIS
SP22-BCS-065-B

Program Exercise 2(Solution):


Take two values at two different memory locations, perform following operation on numbers
AND, OR, Increment (INC) first number by 4, second number by 2, Decrement (DEC) first
number by 3, second number by 1.
Show all the individual results at 6 consecutive memory locations.
FARYAL AWAIS
SP22-BCS-065-B

Post-Lab Assignment:
Question 1: Write code to achieve the following:

Initialize two registers AX, BX with 20h and 30h. Swap the contents of AX with BX
registers.
Display the contents of the registers.
FARYAL AWAIS
SP22-BCS-065-B

Write codes to evaluate the arithmetic expression “15h+(6d-0000000000111010b)”, by:


 Using one register only
Mov ax.6
Sub ax,3A
Add ax,15

 Using two registers only


Mov ax,6
Mov bx,3A
Sub ax,bx
Mov bx,15

 Using three registers


Mov ax,6
Mov bx,3A
Mov cx,15
Sub ax,bx
Add ax,cx

You might also like