8085 Practice Examples
8085 Practice Examples
3) Write the appropriate comment for the following program as well as its purpose. Note that
square decimal number from 0 to 9 are stored in memory location from 1500H to 1509H
respectively. The above range (0 to 9 ) decimal is stored at 1234H.
Label Instructions Comments
LDA 1234H ;
MOV L,A ;
MVI H,15H ;
MOV A,M ;
STA 1235H ;
HLT ;
Ans. The purpose of ALP is find square of entered number at 1234H from square table is
stored from memory location 1500H and onward. Store result at 1235H.
Label Instructions Comments
LDA 1234H ; Load A with 1234H content.
MOV L,A ; Copy A to L.
MVI H,15H ; Move immediate 15H to H.
MOV A,M ; Copy HL to A.
STA 1235H ; Store A to memory location 1235H.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
MARCH – 2018 EXAM DATE: 17/03/2018 COMP SCI : 2 (D9-2)
1) Write an Assembly Language Program to multiply an 8-bit number stored at 4301H by
another 8-bit number stored at 4302H. Store the result at the location 4303H and 4304H
beginning with LOB(Lower Order Byte).
Label Mnemonics+Operand Comment/Remark
LHLD 4301H ; Load HL direct with two consecutive memory location
contents such as 4301H and 4302H.
XCHG ; Exchange HL and DE.
MOV C, D ; Copy D to C.
MVI D, 00H ; Move immediate data 00H to D.
LXI H, 0000H ; Move immediate data 0000H to HL i.e. HL= 0000H.
DAD D ; Add HL with DE and store result at HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; jump to label loop until if z = 0 i.e. C # 0.
SHLD 4303H ; if z=1 i.e. C = 0 then store HL direct to two consecutive
memory location such as 4303H and 4304H.
HLT ; stop processing.
2) Write an Assembly Language Program to fill in the memory locations starting from
6900H and onward with the decimal numbers 0 to 99.
LabelMnemonics+Operand Comment/Remark
LXI H, 6900H ; Initialize HL.
MVI C, 64H ; Move immediate data to C.
SUB A ; Substract A from A & store to A.
LOOP MOV M, A ; Copy A to HL.
ADI 01H ; Add data to A & store to A.
DAA ; Decimal adjust accumulator.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
3) Write an Assembly Language Program to take the 2’s compliment of an 8-bit number
stored at 3301H. Store the result at the memory location 3302H.
3) Write an Assembly Language Program to count the total number of even data bytes occurring in a block
of data stored from 9201H to 920AH. Store the result (count) at the memory location 9500H.
LabelMnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
MVI E, 00H ; Move immediate data to E.
LXI H, 9201H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RRC ; Rotate A towards right.
JC NEXT ; Jump on carry to label NEXT.
INR E ; Increment E by 1.
NEXT INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, E ; Copy E to A.
STA 9500H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
July – 2017 EXAM DATE: 28/07/2017 1) Write an Assembly Language Program to fill the
memory block stored from 7601H to 760FH with the data 00H and FFH alternatively.
Label Mnemonics+Operand Comment/Remark
MVI C, 0FH ; Move immediate data to C.
MVI A, 00H ; Move immediate data to A.
MVI B, FFH ; Move immediate data to B.
LXI H, 7601H ; Initialize HL.
LOOP MOV M, A ; Copy A to HL.
INX H ; Increment HL by 1.
MOV M, B ; Copy B o HL.
DCR C ; Decrement C by 1.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
2) Write an Assembly Language Program to search the data byte A4H in a memory block
stored from 9901H to 990AH. If the search is successful, then HL register pair should contain
the address of the location where the specified data byte is found; else the HL pair should
contain 0000H.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
LXI H, 9901H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI A4H ; Compare A with data.
JZ STOP ; Jump on zero to label STOP.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, 0000H ; Initialize HL.
STOP HLT ; Stop processing.
3) Write an Assembly Language Program to separate the two nibbles of an 8-bit number
stored at 7501H. Store the low-order nibble and high-order nibble respectively at thelocations
7502H and 7503H.
Label Mnemonics+Operand Comment/Remark
LDA 7501H ; Load A.
ANI 0FH ; ANDing A with data.
STA 7502H ; Store A to memory.
LDA 7501 ; Load A.
ANI F0H ; ANDing A with data.
RRC ; Exchange two nibbles and store to A.
RRC ;
RRC ;
RRC ;
STA 7503H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write an Assembly Language Program to take the sum of the 8-bit contents of a memory block stored from 2201H
to 220AH. Store the 2-byte result at the locations 220BH and 220CH starting with LOB(Lower-Order byte)
LabelMnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
MVI B, 00H ; Move immediate data to B.
LXI H, 2201H ; Initialize HL.
MVI A, 00H ; Move immediate data to A.
LOOP ADD M ; Add A with HL and store to A.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
NEXT INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV M, A ; Copy A to HL.
INX H ; Increment HL by 1.
MOV M, B ; Copy B to HL.
HLT ; Stop processing.
2) Write an Assembly Language Program to count the total number of 0(LOW) bits in an 8-bit number
stored at the location 4301H. Store the result(count) at the memory location 4302H.
LabelMnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
MVI C, 08H ; Move immediate data to C.
LDA 4301H ; Load A.
LOOP RRC ; Rotate A towards right each bit and
store to A.
JC NEXT ; Jump on carry to label NEXT.
INR B ; Increment B by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, B ; Copy B to A.
STA 4302H ; Store A to memory.
HLT ; Stop processing.
3) Write an Assembly Language Program to find the greatest number in a memory block stored from 6201H
to 620AH. Store the result at the location 620BH.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
LXI H, 6201H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
LOOP CMP M ; Compare A with HL.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA 620BH ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March – 2017 EXAM DATE: 22/03/2017 COMP SCI : 2 (D9-2)
1) Write a Assembly Language Program to copy a block of data having starting address 4500H to new
location starting from 4600H. The length of block is stored at memory location 44FFH.
Label Mnemonics+Operand Comment/Remark
LXI H, 44FFH ; initialize HL.
MOV C, M ; copy HL to C.
LXI D, 4600H ; initialize DE.
LOOP INX H ; Increment HL by 1.
MOV A, M ; copy HL to A.
STAX D ; store A to DE address.
INX D ; Increment DE by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; jump to label LOOP if z=0 i.e. C # 0.
HLT ; stop processing if C = 0 i.e. z = 1.
2) Write an Assembly Language Program to add two 8-bit BCD numbers stored at memory
location 4500H and 4501H. Stores the two byte BCD result from memory location 4502Hand
onwards.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, 4500H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
ADD M ; Add A with HL & store to A.
DAA ; Decimal adjust accumulator.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
STA 4502H ; Store A to memory.
MOV A, B ; Copy B to A.
STA 4503H ; Store A to memory.
HLT ; Stop processing.
3) Write an Assembly Language Program to fill the memory locations 4500H to 4504H with
hexadecimal numbers 09H to 0DH respectively.
Label Mnemonics+Operand Comment/Remark
MVI C, 05H ; Move immediate data to C.
MVI A, 09H ; Move immediate data to A.
MVI B, 0DH ; Move immediate data to B.
LXI H, 4500H ; Initialize HL.
LOOP MOV M, A ; Copy A to HL.
INX H ; Increment HL by 1.
MOV M, B ; Copy B to HL.
DCR C ; Decrement C by 1.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR 1) Write an Assembly Language Program to exchange the nibbles of 8-bit number stored
in memory location 4500H. Stores the result at memory location 4501H.
Label Mnemonics+Operand Comment/Remark
LDA 4500H ; Load accumulator.
RRC ; Rotate A towards right each bit without carry exchange
RRC ;two nibbles store to A
RRC ;
RRC ;
STA 4501H ; Store A to memory.
HLT ; Stop processing.
2) A block of data is stored in memory location 4500H. The length of block is stored in
memory location 44FFH. Write an Assembly Language Program that searches for the first
occurrences of data D9H in given block. Store the address of this occurrence in HL pair. If the
number is not found the HL pair should contain 5000H.
Label Mnemonics+Operand Comment/Remark
LXI H, 44FFH ; Initialize HL.
MOV C, M ; Copy HL to C.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
CPI D9H ; Compare A with data.
JZ STOP ; Jump on zero to label STOP.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, 5000H ; Initialize HL.
STOP HLT ; Stop processing.
3) A block of data is stored from memory location 4501H and onwards. The length of the
block is stored at memory location 4500H. Write an Assembly Language Program to find the
sum of block of data. Store the two byte result From memory location 4600H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H 4500H ; Initialize HL.
MOV C, M ; Copy HL to C.
MVI A, 00H ; Move immediate data to A.
LOOP INX H ; Increment HL by 1.
ADD M ; Add A with HL and store to A.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA 4600H ; Store A to memory.
MOV A, B ; Copy B to A.
STA 4601H ; Store A to memory.
HLT ; Stop processing.
2) Accumulator contents of 8085 are B7H and register B contents are A5H.What will be the
effect of following instructions on the contents of Accumulator when executed following
instructions independently?
i) ADI 05H ii) CMP B iii) CMA
iv) XRA B v) ORA B
3) Write an Assembly Language Program to increment the contents of alternate memory
locations each by two from 1051H to 1060H.
Label Mnemonics+Operand Comment/Remark
MVI C, 10H ; Move immediate data to C.
LXI H, 1050H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
ADI 02H ; Add A with data and store to A.
MOV M, A ; Copy A to HL.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct–2015 EXAM DATE: / /2015 COMP SCI:2 (D92)
1) Write an assembly language program to multiply the content of 2000H by the content of 2001H. Store the
16-bit result in the memory location 2010H and 2011H.
2) Write an assembly language program to add the four byte number starting from C000H with another four
byte number starting from C100H. Store the four byte result starting from C200H and carry at C204H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to C.
LHLD C000H ; Load HL direct with two consecutive memory locations contents.
XCHG ; Exchanges HL with DE.
LHLD C100H ; Load HL direct with two consecutive memory locations contents.
DAD D ; Add HL with DE and store to HL.
SHLD C200H ; Store HL direct to two consecutive memory locations contents.
LHLD C002H ; Load HL direct with two consecutive memory locations contents.
XCHG ; Exchanges HL with DE.
LHLD C102H ; Load HL direct with two consecutive memory locations contents.
DAD D ; Add HL with DE and store to HL.
SHLD C202H ; Store HL direct to two consecutive memory locations contents.
LHLD C200H ; Load HL direct with two consecutive memory locations contents.
XCHG ; Exchanges HL with DE.
LHLD C202H ; Load HL direct with two consecutive memory locations contents.
DAD D ; Add HL with DE and store to HL.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
NEXT MOV A, B ; Copy B to A.
STA C204H ; Store A to memory.
HLT ; Stop processing.
3) Write an assembly language program to count the odd numbers block starting from 2300H to 2320H. Store he
count at memory location 2400H.
MATRIX SCIENCE ACADEMY
Label Mnemonics+Operand Comment/Remark
LHLD 2000H ; Load HL direct with two consecutive memory location contents
such as 2000H and 2001H.
XCHG ; Exchange HL and DE.
MOV C, D ; Copy D to C.
MVI D, 00H ; Move immediate data 00H to D.
LXI H, 0000H ; Move immediate data 0000H to HL i.e. HL= 0000H.
DAD D ; Add HL with DE and store result at HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; jump to label loop until if z = 0 i.e. C # 0.
SHLD 2010H ; if z=1 i.e. C = 0 then store HL direct to two consecutive memory
location such as 2010H and 2011H.
HLT ; stop processing.
3) Write an Assembly Language Program that multiplies the original number. Stored at C030H with its lower
nibble.Store the result starting from C031H and onwards.
2) Write an Assembly Language Program to exchange position of digit of number stored at C040H. Multiply original
number with the exchanged number the result to be stored at memory location starting from C041H and onwards.
Label Mnemonics+Operand Comment/Remark
LXI H, C040H ; Initialize HL.
MOV A, M ; Copy HL to A.
ANI 0FH ; ANDing A with data maskoff LSB & store to A.
MOV E, A ; Copy A to E.
MVI D, 00H ; Move immediate data to D.
MOV A, M ; Copy HL to A.
ANI F0H ; ANDing A with data maskoff MSB & store to A.
RRC ; Rotate accumulator towards right 1 bit position each 4 times then
RRC ; exchanges two 4 bit nibbles to each other then store to A.
RRC ;
;
RRC
MOV C, A ; Copy A to C.
LXI H, 0000H ; Initialize HL.
LOOP DAD D ; Add HL with DE & store to HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
SHLD C041H ; Store HL to two consecutive memory locations.
HLT ; Stop processing.
3) Write an Assembly Language Program to add two 16 bit numbers. The numbers are stored at memory
location C030H and C031H and the second number stored at C032H and C033H. Store result at memory
location C034H and C035H. Store final carry at C036H.
MATRIX SCIENCE ACADEMY
Label Mnemonics+Operand Comment/Remark
MVI E, 00H ; Move immediate data to E.
MVI C, 0AH ; Move immediate data to C.
LXI H, C030H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right 1 bit position & store to A.
JC NEXT ; Jump on carry to label NEXT.
INR E ; Increment E by 1.
NEXT INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, E ; Copy E to A.
STA C040H ; Store A memory.
HLT ; Stop processing.