MPMC EXAM

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

(1.

a) Write an 8085 ALP to find 1’s and 2’s complement of an 8-bit


number.

LDA 2000H
CMA
STA 2006H
INR A
STA 2007H ; Store 2's complement Result
HLT

(1.b) Write an 8085 ALP to find 1’s and 2’s complement of 16-bit number
stored in Memory.

LHLD 2000H
MOV A,L
CMA
MOV L,A
MOV A,H
CMA
MOV H,A
SHLD 2006H
INX H
SHLD 2008H
HLT

(2.a) To write an 8085 ALP to add two 8-bit number that results in an8-
bit number.

LXI H,2000H
MOV A,M
INX H
ADD M
STA 2006H
HLT

(2.b) To write an 8085 ALP to add two 8-bit number that may results in a
16-bit number.

LXI H,2000H
LXI D,2006H
MVI B,00H
MOV A,M
INX H
ADD M
JNC SKIP
INR B
SKIP: STAX D
INX D
MOV A,B
STAX D
HLT

(3.a) To write an 8085 ALP to add two 16-bit number using DAD
instruction.

XRA A
LHLD 2002H
XCHG
LHLD 2000H
DAD D
JNC NXT
INR B
NXT: SHLD 2006H
STA 2008H
HLT

(3.b) To write an 8085 ALP to add two 16 bit number without using DAD
instruction.

LXI H, 2000H
MVI B, 0
MOV A,M
INX H
INX H
ADD M
STA 2006H
DCX H
MOV A,M
INX H
INX H
ADC M
JNC NXT
INR B
NXT: STA 2007H
MOV A,B
STA 2008H
HLT

(4.a) Write an ALP to subtract two 8-bit numbers using “SUB Instruction”

LXI H,2000H
MOV A,M
INX H
SUB M
STA 2006H
HLT

(4.b) Write an ALP to subtract two 8-bit numbers without using “SUB”
instruction

LXI H,2000H
MOV A,M
INX H
MOV C,M
LOOP: DCR A
DCR C
JNZ LOOP
STA 2006H
HLT

(5) To write an 8085 ALP to add two 16 bit decimal numbers.

LXI H, 2000H
MVI B, 00H
MOV A, M
INX H
INX H
ADD M
DAA
STA 2006H
DCX H
MOV A, M
INX H
INX H
ADC M
DAA
JNC NEXT
INR B
STA 2007H
MOV A, B
STA 2008H
HLT

(6) To write an 8085 ALP to move a Block of Data from one section of
memory to another section of memory.

LXI H, 2000H
LXI D, 3000H
MOV C, M
MOV A, C
STAX D
INX H
INX D
MOV A, M
STAX D
DCR C
JNZ Loop
HLT

(7.a) Multiplication oftwo8-bit numbers.(Bit rotation or Shift and add


method)

LXI H, 2000H
MOV E, M
MVI D, 00H
INX H
MOV A, M
MVI C, 08H
LXI H, 00H
LOOP: DAD H
RAL
JNC NXT
DAD D
NXT: DCR C
JNZ LOOP
SHLD 2006H
HLT

(7.b) Division of an8-bit number with an 8-bit number. (Repeated


subtraction method)

LXI H, 2000H
MOV A, M
INX H
MOV B, M
MVI C, 00H
RPT: CMP B
JC RSLT
SUB B
INR C
JMP RPT
RSLT: STA 2007H
MOV A, C
STA 2006H
HLT

(8.a) Write an 80850 ALP .to find the largest number in an array.

LXI H, 2000H
MOV C, M
INX H
MOV A, M
DCR C
loop: INX H
CMP M
JNC nxt
MOV A, M
nxt: DCR C
JNZ loop
STA 2100H
HLT

(8.b) Write an 80850 ALP .to find the smallest number in an array.

LXI H, 2000H
MOV C, M
INX H
MOV A, M
DCR C
loop: INX H
CMP M
JC nxt
MOV A, M
nxt: DCR C
JNZ loop
STA 2100H
HLT

(9.a) Write an 8085 ALP .to sort an array in ascending order.

LXI SP, 8000H


LXI H, 2000H
LXI D, 2100H
MOV A, M
MOV B, A
STAX D
start: PUSH H
CALL SM_NO
POP H
INX D
STAX D
PUSH H
CALL REPL
POP H
DCR B
JNZ start
HLT

SM_NO: MOV C, M
INX H
MOV A, M
DCR C
loop: INX H
CMP M
JC ahd
MOV A, M
ahd: DCR C
JNZ loop
RET

REPL:
MOV C, M
loop1: INX H
CMP M
JZ next
DCR C
JNZ loop1
next: MVI M, 0FFH
RET

(9.b) Write an 8085 ALP .to sort an array in descending order.

LXI SP, 8000H


LXI H, 2000H
MOV A, M
MOV B, A
STAX D
start: PUSH H
CALL LR_NO
POP H
INX D
STAX D
PUSH H
CALL REPL
POP H
DCR B
JNZ start
HLT

LR_NO: MOV C, M
INX H
MOV A, M
DCR C
loop: INX H
CMP M
JNC ahd
MOV A, M
ahd: DCR C
JNZ loop
RET

(10) Write assembly language programs for addition, subtraction,


division, multiplicationin micro-controller.

;Addition of two 8-bit number stored in internal RAM


MOV 0X71, #0X00
MOV A,0X60
ADD A,0X61
JNC nxt
NC 0X71
nxt: MOV 0X70,A
;Subtraction of two 8-bit number stored in internal RAM
CLR C
MOV 0X73, #0X00
MOV A,0X60
SUBB A,0X61
JNC skip
INC 0X73
skip: MOV 0X72,A
;Multiplication of two 8-bit number stored in RAM
MOV A,0X60
MOV B,0X61
MUL AB
MOV 0X74, A
MOV 0X75, B
;Division of two 8-bit number stored in RAM
MOV A,0X60
MOV B,0X61
DIV AB
MOV 0X76, A
MOV 0X77, B

You might also like