MPIS Assignment
MPIS Assignment
Valand Program :
BTech CSE
Semester : IV
Division : 2
Subject : MPIS
23BT04D200 - UNNATI
VALAND
Q1. Write a program to find the factorial of a number stored at
memory address 2100H. Store the result at 2200H.
ANSWER:
Factorial program
Data section
MOV AX, [2100H] ; Load the dividend from memory address 2100H
23BT04D200 - UNNATI
VALAND
into AX MOV BX, [2200H] ; Load the divisor from memory address
2200H into BX
23BT04D200 - UNNATI
VALAND
DIV BX ; Divide AX by BX
DW 42 ; Dividend (example
ORG 2300H
DW 0 ; Quotient (initialized to
0) ORG 2301H
DW 0 ; Remainder (initialized to 0)
Q3. Write a program to add two BCD numbers, assume that the
numbers are stored at memory locations 2100H and 2101H. Store
the result, a BCD number at memory location 2101H.
ANSWER:
Load the first BCD number from memory location 2100H into
H MOV H, A;
23BT04D200 - UNNATI
VALAND
Load the second BCD number from memory location 2101H into
accumulator ADD H;
of program
ANSWER:
the binary number MOV AL, [AX] ; Load the binary number
into AL register
AND AL, 0FH ; Clear the upper 4 bits (keep only the lower
23BT04D200 - UNNATI
VALAND
4 bits) MOV BL, 10; Set BL to 10 (for division)
DIV BL ; Divide AL by 10
23BT04D200 - UNNATI
VALAND
MOV DL, AL ; Remainder (DL) contains the BCD digit for
MOV [AX], DL
23BT04D200 - UNNATI
VALAND
Q 5 Write a program using two 16 bit binary numbers. Make
suitable assumptions.
ANSWER:
ORG 2000H ; Assume the binary numbers are at memory locations 2050H and
MOV B, A ; B ← A
LDA 2052 ; A ←
2052 ADD B ;
A←A+B
MOV B, A ; B ← A
LDA 2053 ; A ←
2053
ADC B ; A ← A + B + CY
23BT04D200 - UNNATI
VALAND