Académique Documents
Professionnel Documents
Culture Documents
Problem – Write an assembly language program in 8085 microprocessor to subtract two 16 bit numbers.
Assumption –
Example –
INPUT:
(2050H) = 19H
(2051H) = 6AH
(2052H) = 15H
(2053H) = 5CH
OUTPUT:
(2054H) = 04H
(2055H) = OEH
RESULT:
Algorithm –
Again Get the LSB in L register and MSB in H register of 16 Bit number.
Subtract the content of H register from the content of D register and borrow from previous step.
Program –
Explanation –
STA 2054: store the result from accumulator to memory address 2054.
SBB H: subtract the content of A with the content of register H with borrow.
STA 2055: store the result from accumulator to memory address 2055.
HLT: stops executing the program and halts any further execution.
Problem – Write a program to find the sum of a series where series starts from 3001 memory address
and count of series is at 3000 memory address where starting address of the given program is 2000 store
result into 4000 memory address.
Example –
Algorithm –
Decrease C by 1
Decrease register C by 1
Stop
Program –
LXI is used to load register pair immediately using 16-bit address (3 Byte instruction)
MOV is used to transfer the data from accumulator to register(any) or register(any) to accumulator (1
Byte)
STA is used to store data from accumulator into memory direct using 16-bit address (3 Byte instruction)
JNC is used to jump to the given step if their is no carry (3 Byte instruction)
JNZ is used to jump to the given step if their is not zero (3 Byte instruction)
ADD is used to add value of accumulator with the given value (1 Byte instruction)
Mnemonics:
LXI H, 8E00H
LXI D, 8F01H
MOV C, M
INX H
LOOP:
LDAX D
ADD M
MOV M, A
DCR C
INX H
INX D
JNZ LOOP
HLT
Observation table:
Memory Address
Content Before
Content After
8E00
03H
03H
8E01
12
23
8E02
10
25
8E03
09
20
8F01
11
11
8F02
15
15
8F03
11
11