0% found this document useful (0 votes)
9 views8 pages

MPIS Assignment

The document contains a series of assembly language programs for various tasks including calculating factorial, division with remainder, BCD addition, binary to BCD conversion, and addition of two 16-bit binary numbers. Each program includes specific memory addresses for input and output, as well as detailed instructions on how to execute the operations. The document is structured with questions followed by corresponding answers in assembly code format.

Uploaded by

Misa Amane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

MPIS Assignment

The document contains a series of assembly language programs for various tasks including calculating factorial, division with remainder, BCD addition, binary to BCD conversion, and addition of two 16-bit binary numbers. Each program includes specific memory addresses for input and output, as well as detailed instructions on how to execute the operations. The document is structured with questions followed by corresponding answers in assembly code format.

Uploaded by

Misa Amane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Name : Unnati

Valand Program :

BTech CSE

Semester : IV

Division : 2

Subject : MPIS

Enrollment no. : 23BT04D200

Topic :MPIS Assignment

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

Input: Number at memory address 2100H

Output: Factorial result at memory address

2200H ORG 2100H ; Set origin to dataset

LXI H, 2100H ; Load the address of the number in H-L

register pair MOV B, M ; Move the content of memory to

B-register (B <- M) MVI A, 01H ; Initialize accumulator with

1 (factorial starts from 1) LOOP:

MUL B ; Multiply accumulator with B-

register DCR B ; Decrement B-register

JNZ LOOP ; Jump to LOOP if B is not zero

STA 2200H ; Store the factorial result at memory location

2200H HLT ; Stop processing

Data section

DB 05H ; Initialize memory with the number (e.g., 5)

Q2. Write a program to find the quotient and remainder when a


number stored at memory address 2100H is divided by another
number stored at 2200H. Store the quotient at 2300H and the
remainder at 2301 H.
ANSWER:

ORG 1000H ; Start address (you can adjust this as needed)

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

The quotient will be in AX, and the remainder will be in DX

MOV [2300H], AX ; Store the quotient at memory address

2300H MOV [2301H], DX ; Store the remainder at memory

address 2301H HLT ; Halt the program

Data section (you can adjust the initial values as

needed) ORG 2100H

DW 42 ; Dividend (example

value) ORG 2200H

DW 7 ; Divisor (example value)

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:

8085 Assembly Language Program to Add Two 8-bit BCD

Numbers ORG 2000H ; Starting address

Load the first BCD number from memory location 2100H into

accumulator LDA 2100H;

Move the content of accumulator to register

H MOV H, A;

23BT04D200 - UNNATI
VALAND
Load the second BCD number from memory location 2101H into

accumulator LDA 2101H;

Add the content of register H and

accumulator ADD H;

Check if the sum is greater than 9 (i.e., if the result needs

adjustment) DAA ; Decimal Adjust Accumulator

Store the result (content of accumulator) back into memory location

2101H STA 2101H;

HLT ; Halt the

program END ; End

of program

Q 4. Write to implement binary to BCD conversion, assume


the given binary number at memory

location 2000H is less than or equal to 99 decimal.

ANSWER:

ORG 1000H ; Assume the binary number is at memory

location 2000H MOV AX, 2000H ; Load the memory address of

the binary number MOV AL, [AX] ; Load the binary number

into AL register

Convert binary to decimal

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

units place Convert the second digit

MOV AL, AH ; Load the quotient (tens place) back

into AL DIV BL ; Divide AL by 10

MOV DH, AL ; Remainder (DH) contains the BCD digit for

tens place Combine the BCD digits

SHL DH, 4 ; Shift the tens place digit to the left

by 4 bits OR DL, DH ; Combine the tens

and units place digits

Store the BCD result at memory location 2100H (for

example) MOV AX, 2100H

MOV [AX], DL

HLT ; Halt the program

Data section (binary number at memory location

2000H) ORG 2000H

DB 30 ; Example binary number (30 in

decimal) BCD result storage (memory

location 2100H) ORG 2100H

DB 0 ; Reserve space for the BCD result

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

2052H LDA 2050 ; A ← 2050

MOV B, A ; B ← A

LDA 2052 ; A ←

2052 ADD B ;

A←A+B

STA 3050 ; Store the result at memory location

3050 LDA 2051 ; A ← 2051

MOV B, A ; B ← A

LDA 2053 ; A ←

2053

ADC B ; A ← A + B + CY

STA 3051 ; Store the result at memory location

3051 HLT ; Stop execution

23BT04D200 - UNNATI
VALAND

You might also like