0% found this document useful (0 votes)
154 views40 pages

8085 Practice Examples

The document contains various assembly language programming exercises and solutions, including tasks such as adding, multiplying, and manipulating 8-bit and 16-bit numbers, as well as memory management operations. Each exercise is accompanied by labeled mnemonics and comments explaining the purpose of the code. The document serves as a resource for learning and practicing assembly language programming concepts.

Uploaded by

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

8085 Practice Examples

The document contains various assembly language programming exercises and solutions, including tasks such as adding, multiplying, and manipulating 8-bit and 16-bit numbers, as well as memory management operations. Each exercise is accompanied by labeled mnemonics and comments explaining the purpose of the code. The document serves as a resource for learning and practicing assembly language programming concepts.

Uploaded by

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

MATRIX SCIENCE ACADEMY

AUGAST – 2018 EXAM DATE: 04//08/2018 COMP SCI : 2 (D9-2)


1) 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 is stored at C032H andC033H.
Store result at memory location C034H and C035H. Store final carry at C036H.
Label Mnemonics+Operand Comment/Remark
MVI B.,00H ; Clear B.
LHLD C030H ; Load HL with two consecutive MLs C030H and C031H.
XCHG ; Exchange HL and DE.
LHLD C032H ; Load HL with two consecutive MLs C032H and C033H.
DAD D ; Add HL and DE and store result to HL.
JNC NEXT ; jump if cy=0 to label NEXT.
INR B ; increment B by 1 if cy=1
NEXT SHLD C034H ; store HL to two consecutive MLs C034H and C035H.
STA C036H ; Store A to C036H.
HLT ; Stop processing

2) Write the appropriate instructions for the following task:


i) Load accumulator from B register.
Ans LADX B OR MOV A, B.
ii) Complement the accumulator.
Ans. CMA
iii) Add 01H with the accumulator.
Ans. ADI 01H
iv) Store the content of accumulator at the memory location addressed
by the BC register pair.
Ans. STAX B
v) Clear the accumulator.
Ans. MVI A, 00H
3) A block of data is stored in memory location from 9101H to 91FFH. Write an Assembly
Language Program to transfer the block in reverse order to memory location 9200H and
onwards.
Label Mnemonics+Operand Comment/Remark
LXI H, 91FFH ; initialize HL.
LXI D, 9200H ; initialize DE.
MVI C, FFH ; Set count to C.
LOOP MOV A, M ; Copy HL to A.
STAX D ; Store A to DE register pair address.
DCX H ; Decrement HL by 1.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump to label LOOP if z = 0 i.e. C#0.
HLT ; Stop processing z=1 i.e. C = 0.
MATRIX SCIENCE ACADEMY
OR 1) Trace the following program and write the purpose of the program:
Label Instructions Comments
LXI H, 2500H ; Load HL by 2500H.
MVI B, 01H ; Load immediate register B by 01H.
MOV A, M ; Take data from memory to accumulator.
CMA ; complement the accumulator content.
ADD B ; Add 01H to accumulator.
INX H ; Increment HL by 1.
MOV M, A ; Transfer content of accumulator to memory.
HLT ; Stop.
Ans. The purpose of program is to find 2’s compliment of hex number is stored at memory
location 2500H. Store 2’s compliment result at memory location 2501H.
2) An ASCII code for hexadecimal digit is stored at memory location 2000H. Write an
assembly language program to convert it into hexadecimal number and store it at 3000H.
Label Mnemonics+Operand Comment/Remark
LDA 2000H ; Load accumulator direct.
SUI 40H ; Subtract data from accumulator and store to A.
JM NEXT ; Jump on minus to label NEXT.
ADI 09H ; Add A with data & store to A.
JMP STORE ; unconditional jump to label STORE.
NEXT ADI 0AH ; Add A with data & store to A.
STORE STA 3000H ; Store A to memory.
HLT ; Stop processing.

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.

Label Mnemonics+Operand Comment/Remark


LDA 3301H ; Load A
CMA ; Compliment accumulator.
ADI 01H ; Add data with A & store to A.
STA 3302H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write an Assembly Language Program to count the occurrence of the data byte ACH in a memory
block stored form 7401 to 7405H. Store the count at the memory location 7406H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
MVI C, 05H ; Move immediate data to C.
LXI H,7401H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI ACH ; Compare A with data.
JNZ NEXT ; Jump on no zero 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.
HLT ; stop processing.
2) Write a subroutine in assembly language to till the memory locations 7301H to 73FFH
with the hexadecimal numbers 01H to FFH respectively.

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.

July – 2016 EXAM DATE: 29/07/2016 COMP SCI : 2 (D9-2)


MATRIX SCIENCE ACADEMY
1) Write an Assembly Language Program to add the content of a block of memory comprising of 16 bytes,
starting from 2000H. The two byte sum is to be stored in memory location 2010H (LSB) and 2011H(MSB).
LabelMnemonics+Operand Comment/Remark
MVI C, 10H ; Move immediate data to C.
MVI A, 00H ; Move immediate data to A.
MVI B, 00H ; Move immediate data to B.
LXI H, 20000H ; Initialize HL.
LOOP ADD M ; Add A with HL & 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 zero to label LOOP.
STA 2010H ; Store A to memory.
MOV A, B ; Copy B to A.
STA 2011H ; Store A to memory.
HLT ; Stop processing.
2) A memory block starts from 2100H and end at 210EH. Write an Assembly Language Program to insert a
byte 2CH at memory location 2105H and rearrange the memory block accordingly.
LabelMnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
MVI B,05H ; Move immediate data to B.
BACK LXI H, 2100H ; Initialize HL.
INX H ; Increment HL by 1.
DCR B ; Decrement B by 1.
JNZ BACK ; Jump on no zero to label BACK.
LXI H 2105H ; Initialize HL.
LOOP MVI M, 2CH ; Move immediate data to HL.
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 find the absolute difference of the hex numbers stored at
C200H and C201H. Store the result at C202H.
LabelMnemonics+Operand Comment/Remark
LXI H, C200H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
SUB M ; Substract HL from A & store to A.
JNC NEXT ; Jump on no carry to label NEXT.
CMA ; Compliment A & store to A.
ADI 01H ; Add A with data & store to A.
NEXT INX H ; Increment HL by 1.
MOV M, A ; Copy A to HL.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
MATRIX SCIENCE ACADEMY
OR1) A memory block starts form C301H and its block length count is stored at C300H. Write an Assembly
Language Program to count the even numbers and odd numbers present in the block. Store the even number
count at C400H and odd number count at C401H.
Label Mnemonics+Operand Comment/Remark
LXI H, C300H ; Initialize HL.
MOV C, M ; Copy HL to C.
MVI E, 00H ; Move immediate data to E.
MVI D,00H ; Move immediate data to D.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right each bit and store to A.
JNC NEXT ; Jumps on no carry to label NEXT.
INR D ; Increment D by 1.
JMP GO ; Unconditional jump to label GO.
NEXT INR E ; Increment E by 1.
GO DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, E ; Copy E to A
STA C400H ; Store A to memory.
MOV A, D ; Copy D to A.
STA C401H ; Store A to memory.
HLT ; Stop processing.
2) Write an Assembly Language Program to separate the digits of a hex number stored at 2400H. Add these
digits and store the sum at 2401H.
Label Mnemonics+Operand Comment/Remark
LDA 2400H ; Load A.
ANI 0FH ; ANDing A with data & store to A.
MOV B,A ; Copy A to B.
LDA 2400H ; Load A.
ANI F0H ; ANDing A with data & store to A.
RRC ; Rotate A towards right each bit without carry 4 time then shifted
RRC ; 4 bit nibbles store to A;
RRC ;
RRC ;
ADD B ; Add A with B & store to A.
STA 2401H ; Store A to memory.
HLT ; Stop processing.
3) Write an Assembly Language Program to pickup the largest number from a memory block starting from
D000H containing twenty numbers. Store the largest number at D050H.
Label Mnemonics+Operand Comment/Remark
MVI C, 14H ; Move immediate data to C.
LXI H, D000H ; Initialize HL.
MOV A, M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA D050H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March – 2016 EXAM DATE: 14/03/2016 COMP SCI : 2 (D9-2)
1) Write an Assembly Language Program to multiply a number stored at location 1050H
with a number at location 1051H. Result is 2-byte. Store result at locations 1052H and 1053H.

Label Mnemonics+Operand Comment/Remark


LHLD 1050H ; Load HL direct with two consecutive memory location
contents such as 1050H and 1051H.
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 1052H ; if z=1 i.e. C = 0 then store HL direct to two consecutive
memory location such as 1052H and 1053H.
HLT ; stop processing.
2) Write an Assembly Language Program to transfer a block of memory starting from 1050H
to a new location starting from 1070H to 1079H.
Label Mnemonics+Operand Comment/Remark
LXI H, 1070H ; Initialize HL.
LXI D, 1050H ; Initialize DE.
MVI C, 0AH ; Move immediate 0AH count to C.
LOOP MOV A, M ; Copy HL to A.
STAX D ; Store A to DE register pair address.
INX H ; Increment HL by 1.
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 z =1 i.e. c = 0.
3) A two byte number is stored at location C000H and C001H. Write an ALP to rotate this
number to left side 3 places and store the rotated number in BC register pair.
Label Mnemonics+Operand Comment/Remark
LHLD C000H ; Load HL with two consecutive memory locations content
MVI C, 03H ; Move immediate data to register C.
LOOP DAD H ; Add HL with HL and store to HL.
JNC NEXT ; Jump on no carry to label NEXT.
INR L ; Increment L by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV B, H ; Copy H to B.
MOV C, L ; Copy L to C.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write an Assembly Language Program to add 2 decimal numbers stored at 1050H and
1051H. Store result at 1052H and 1053H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, 1050H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
ADD M ; Add A with HL and store to A.
DAA ; Decimal adjust accumulator and store to A.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
NEXT STA 1052H ; Store A to memory.
MOV A, B ; Copy B to A.
STA 1053H ; 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.

Label Mnemonics+Operand Comment/Remark


MVI C, 21H ; Move immediate data to C.
MVI E, 00H ; Move immediate data to E.
LXI H, 2300H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right each bit and store to A.
JNC NEXT ; Jump on no 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.
MATRIX SCIENCE ACADEMY
STA 2400H ; Store A to memory.
HLT ; Stop processing.
OR1) The two memory block starts from 3000H and 3100H each containing 16 bytes. Write an assembly language
program to exchange the content of these blocks.
Label Mnemonics+Operand Comment/Remark
MVI C, 10H ; Move immediate data to C.
LXI H, 3000H ; Initialize HL.
LXI D, 3100H ; Initialize DE.
LOOP LDAX D ; Load accumulator indirect with DE
addressed memory content.
MOV B,A ; Copy A to B.
MOV A, M ; Copy HL to A.
MOV M, B ; Copy B to HL.
STAX D ; Store DE to A.
INX D ; Increment DE 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) A memory block from 4000H containing 16 hexadecimal numbers. Write an assembly language program to count
the numbers which has identical nibbles. Stores the count in memory location 4010H.
Label Mnemonics+Operand Comment/Remark
MVI D, 00H ; Move immediate data to D.
MVI C, 10H ; Move immediate data to C.
LXI H, 4000H ; Initialize HL.
LOOP MOV A,M ; Copy HL to A.
ANI 0FH ; ANDing A with data and store to A.
MOV B,A ; Copy A to B.
MOV A, M ; Copy HL to A.
ANI F0H ; ANDing A with data and store to A.
RRC ; Rotate A towards right each bit without carry 4 time then shifted
RRC ; 4 bit nibbles store to A
RRC ;
RRC ;
CMP B ; Compare A with B.
JNZ NEXT ; Jump on no zero to label NEXT.
INR D ; Increment D 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, D ; Copy D to A.
STA 4010H ; Store A to memory.
HLT ; Stop processing.
3) Write an assembly language program to test whether the DCH is present in the memory block which starts from
2000H. If the data is present in block then HL pair should contain the address otherwise it should containFFFFH.(Test
for the first occurrence only).
Label Mnemonics+Operand Comment/Remark
MVI C, 10H ; Move immediate data to C.
LXI H, 2000H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI DCH ; 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, FFFFH ; Initialize HL.
STOP HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March – 2015 EXAM DATE: 14/03/2015 COMP SCI : 2 (D9-2)
1) Write an ALP to multiply number stored at 8085 by 09H and store result at 8086H and
8087H with lower byte at 8086H.
Label Mnemonics+Operand Comment/Remark
LXI H, 8085H ; Initialize HL.
MOV E, M ; Copy HL to E.
MVI D, 00H ; Move immediate 00H to D.
MVI C, 09H ; Move immediate 09H to C.
LXI H, 0000H ; Initialize HL and HL = 0000H.
LOOP DAD D ; Add HL with DE and store result to HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; jump to label LOOP if z = 0 i.e. C # 0.
SHLD 8086H ; Store HL to 8086H and 8087H.
HLT ; stop processing
2) Write an ALP to find 2’s compliment of a 16-bit number in DE pair. Store result in HL
pair.
Label Mnemonics+Operand Comment/Remark
MOV A, E ; copy E to A.
CMA ; Compliment A.
MOV E, A ; copy A to E.
MOV A, D ; copy D to A.
CMA ; compliment A.
MOV D, A ; copy A to D.
INX D ; increment D by 1.
XCHG ; exchange HL and DE.
HLT ; stop processing.
3) Locate smallest number in a block from 2050H to 2060H and store it in memory location
2061H.
Label Mnemonics+Operand Comment/Remark
LXI H,2050H ; Initialize HL.
MVI C,10H ; Move immediate data to C.
MOV A,M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JC NEXT ; Jump on carry to label NEXT.
MOV A,M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA 2061H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR
1) Write an ALP to store data BCH in 20 contiguous memory locations starting from 8081H.
Label Mnemonics+Operand Comment/Remark
LXI H, 8081H ; Initialize HL.
MVI C, 14H ; Move immediate data to C.
LOOP MVI M, BCH ; Move immediate data to HL.
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 ALP to divide number at 6068H by a non-zero number at 6067H. Store quotient
at 6069H and remainder at 606AH.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, 6067H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
LOOP CMP M ; Compare A with HL.
JC NEXT ; Jump on carry to label NEXT.
SUB M ; Substract HL from A and store to A.
INR B ; Increment B by 1.
JMP LOOP ; Jump unconditionally to label LOOP.
NEXT INX H ; Increment HL by 1.
MOV M,B ; Copy B to HL.
INX H ; Increment HL by 1.
MOV M,A ; Copy A to HL.
HLT ; Stop processing.
3) Write an ALP to clear register B if number at memory location 20F9H is Palindrome;
otherwise store FFH in register B. (Palindrome numbers such as FFH, 22H, AAH etc. )
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, 20F9H ; Initialize HL.
MOV A,M ; Copy HL to A.
RRC ; Rotate A towards right each bit without carry 4 time then shifted
RRC ; 4 bit nibbles store to A;
;
RRC ;
RRC
CMP M ; Compare A with HL.
JZ STOP ; Jump on zero to label STOP.
MVI B, FFH ; Move immediate data to B.
STOP HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct –2014 EXAM DATE: / /2014 COMP SCI : 2 (D9-2)
1) Write a program in assembly language to multiply two 8-bit data, where multiplier is stored at D000H and
multiplicand is stored at D001H memory locations. Store the 16 bit product from memory location D002H.
Label Mnemonics+Operand Comment/Remark
LHLD D000H ; Load HL direct with two consecutive memory location contents
such as D000H and D001H.
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 D002H ; if z=1 i.e. C = 0 then store HL direct to two consecutive memory
location such as D002H and D003H.
HLT ; stop processing.
2) Give proper comments to following program. Also write the purpose of Program.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ;
MOV A, C ;
RRC ;
MOV C, A ;
LXI H, D000H ;
LXI D, D00AH ;
L1 LDAX D ;
MOV B,M ;
XCHG ;
MOV M, B ;
STAX D ;
XCHG ;
INX H ;
DCX D ;
DCR C ;
JNZ L1 ;
HLT ;
3) There is a block of memory from 2501H to 250AH. Write a program to replace the odd numbers with
data ‘FFH’ in a given block.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
LXI H, 2501H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right without carry & store to A.
JNC NEXT ; Jump on no carry to label NEXT.
MVI M, FFH ; Move immediate data to HL.
NEXT 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
OR1) Write program in assembly language to exchange the nibbles of each memory location contents of a
block which begins from 2501H the length of block is at 2500H. Store the result at same memory locations.

Label Mnemonics+Operand Comment/Remark


LXI H, 2500H ; Initialize HL.
MOV C, M ; Copy HL to C.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
RRC ; Rotate A towards right each bit without carry 4 time then shifted ;
RRC 4 bit nibbles store to A;
RRC ;
RRC ;
MOV M, A ; Copy A to HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
2) Write a program to check whether 2 hex digits stored at D000H are same or not. If digits are same then
memory location D001H should contain 00H else FFH.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; Initialize HL.
MOV A ,M ; Copy HL to A.
ANI 0FH ; ANDing A with data & store to A.
MOV B,A ; Copy A to B.
MOV A, M ; Copy HL to A.
ANI F0H ; ANDing A with data & store to A.
RRC ; Rotate A towards right each bit without carry 4 time then shifted
RRC ; 4 bit nibbles store to A;
RRC ;
RRC ;
CMP B ; Compare A with B.
JNZ NEXT ; jump on no zero to label NEXT.
INX H ; Increment HL by 1.
MVI M, 00H ; Move immediate data to HL.
JMP STOP ; Unconditional jump to label STOP.
NEXT MVI M, FFH ; Move immediate data to HL.
STOP HLT ; Stop processing.
3) Write a program in assembly language to add 3 byte number stored from D000H with another 3 byte
number is stored from D100H memory address. Store the 3 byte result from memory location D200H
starting with lower Byte.
Label Mnemonics+Operand Comment/Remark
LHLD D000H ; Load HL direct with content of two consecutive memory
locations.
XCHG ; Exchange HL and DE.
LHLD D100H ; Load HL direct with content of two consecutive memory
locations.
DAD D ; Add HL with DE and store to HL.
SHLD D200H ; Store HL direct to two consecutive memory locations.
LDA D002H ; Load A with memory.
LXI H, D102H ; Initialize HL.
ADD M ; Add A with HL and store to A.
STA D202H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March –2014 EXAM DATE: 14 /03 /2014 COMP SCI : 2 (D9-2)
1) Write an ALP to store 00H in register B only if the content of memory location 201FH is
odd. Otherwise store EEH in register B.
Label Mnemonics+Operand Comment/Remark
LDA 201FH ; Load A with memory.
RRC ; Rotate accumulator towards right each bit & store to A.
JNC NEXT ; Jump on no carry to label NEXT.
MVI B, 00H ; Move immediate data to B.
JMP STOP ; Jump unconditionally to label STOP.
NEXT MVI B, EEH ; Move immediate data to B.
STOP HLT ; Stop processing.
2) Write ALP to find largest element in a memory block from D000H to D00FH. Stores
largest number at memory location C800H.
Label Mnemonics+Operand Comment/Remark
LXI H,D000H ; Initialize HL.
MVI C,10H ; Move immediate data to C.
MOV A,M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JNC NEXT ; jump on no carry to label NEXT.
MOV A,M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA C800H ; Store A to memory.
HLT ; Stop processing.
3) Write an ALP to add all the BCD numbers in a block from 2001H to 2009H. Store SUM
at memory location 200AH. (Assume SUM is 8 bit ).
Label Mnemonics+Operand Comment/Remark
LXI H, 2001H ; Initialize HL.
MVI C, 09H ; Move immediate data to C.
MVI A, 00H ; Move immediate data to A.
LOOP ADD M ; Add A with HL and store to A.
DAA ; Decimal adjust accumulator & store to A.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA 200AH ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR
1) Write an ALP to find SUM of a number and its reverse which is stored at memory
location 2080H. Store SUM at 2081H.
Label Mnemonics+Operand Comment/Remark
LDA 2080H ; Load A with memory.
MOV B, A ; Copy A to B.
RRC ; Rotate A towards right each bit without carry 4 time
RRC ; then shifted 4 bit nibbles store to A;
RRC ;
RRC ;
ADD B ; Add A with B & store to A.
STA 2081H ; Store A to memory.
HLT ; stop processing.
2) Write an ALP to count total number of occurrences of data 9CH in a memory block of
length 16 byte, starting from 1000H. Store count in register E.
Label Mnemonics+Operand Comment/Remark
MVI C, 10H ; Move immediate data to C.
MVI E, 00H ; Move immediate data to E.
LXI H, 1000H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI 9CH ; Compare A with data.
JNZ NEXT ; jump on no zero 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.
HLT ; stop processing.
3) Write an ALP to copy 10 consecutive bytes from memory 2025H to memory locations
BCBCH and onwards.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
LXI H, 2025H ; Initialize HL.
LXI D, BCBCH ; Initialize DE.
LOOP MOV A, M ; Copy HL to A.
STAX D ; Store A to DE address.
INX H ; Increment HL by 1.
INX D ; Increment DE by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct –2013 EXAM DATE: / /2013 COMP SCI : 2 (D9-2)
1) Write an Assembly Language Program to count the number of times data 7EH is found in a block of memory
location starting from 3000H. Length of block is stored in location 2FFFH. Store the result in location 2000h.
Label Mnemonics+Operand
LXI H, 2FFFH
MOV C, M
MVI E, 00H
LOOP INX H
MOV A, M
CPI 7EH
JNZ NEXT
INR E
NEXT DCR C
JNZ LOOP
MOV A,E
STA 2000H
HLT
2) Write a program in Assembly Language that multiply two 8-bit numbers stored in memory location D000H
and D001H. Store the two byte result in consecutive memory locations starting from D002H.
Label Mnemonics+Operand Comment/Remark
LHLD D000H ; Load HL direct with two consecutive memory location contents such
as D000H and D001H.
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.
LOOP 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 D002H ; if z=1 i.e. C = 0 then store HL direct to two consecutive memory
location such as D002H and D003H.
HLT ; stop processing.
3) Write a program in Assembly Language that converts a hexadecimal numbers stored at C030H to its BCD
equivalent. Store the BCD result in C031H onwards (AFH=0175 BCD).
Label Mnemonics+Operand Comment/Remark
LXI H, C030H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
MVI B, 64H ; Move immediate data to B.
MVI M, FFH ; Move immediate data to HL.
UP INR M ; Increment HL addressed content by 1.
SUB B ; Substract B from A and store to A.
JNC UP ; Jump on no carry to label UP.
ADD B ; Add A and B & store to A.
INX H ; Increment HL by 1.
MVI B, 0AH ; Move immediate data to B.
MVI M, FFH ; Move immediate data to HL addressed.
UP1 INR M ; Increment HL addressed content by 1.
SUB B ; Substract B from A and store to A.
JNC UP1 ; Jump on no carry to label UP1.
ADD B ; Add A and B & store to A.
INX H ; Increment HL by 1.
MOV M, A ; Copy A to HL.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write an Assembly Language program that divides two one byte hex numbers where dividend is
stored in memory location C000H and divisor is stored in memory location C001H. Store quotient and
remainder in memory location C002H and C003H respectively.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, C000H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
LOOP CMP M ; Compare A with HL.
JC NEXT ; Jump on carry to label NEXT.
SUB M ; Substract HL from A and store to A.
INR B ; Increment B by 1.
JMP LOOP ; Unconditional jump to label LOOP.
NEXT INX H ; Increment HL by 1.
MOV M,B ; Copy B to HL.
INX H ; Increment HL by 1.
MOV M,A ; Copy A to HL.
HLT ; Stop processing.
2) Write an ALP to calculate sum of series of number. The length of the series is in memory location C100H
and series itself begins in memory location C101H. Assume sum to be an 8-bit number. Store result in
C204H.
Label Mnemonics+Operand Comment/Remark
LXI H, C100H ; Initilaize 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 & B then store to A.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA C204H ; Store A to memory.
HLT ; Stop processing.
3) An Assembly Language Program to find 2’s complement of five numbers stored from memory location
C030H and onwards. Store the result from memory location D000H.
Label Mnemonics+Operand Comment/Remark
MVI C,05H ; Move immediate data to C.
LXI H, C030H ; Initialize HL.
LXI D, D000H ; Initialize DE.
LOOP MOV A, M ; Copy HL to A.
CMA ; compliment A and store to A.
ADI 01H ; Add A with data and store to A.
STAX D ; Store A to DE register pair address.
INX D ; Increment DE 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
March –2013 EXAM DATE: / /2013 COMP SCI : 2 (D9-2)
1) Write assembly language program to count number of even data bytes occurring in a block stored from
memory location C051H and onwards. The length of block is stored in location C050H. Store result in
location C060H.
LabelMnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, C050H ; Initialize HL.
MOV C, M ; Copy HL to C.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator right without carry 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 C060H ; Store A to memory.
HLT ; Stop processing
2) Write an assembly language program to perform multiplication of two 8bit numbers where multiplicand
is stored at the memory locations C051H and C052H and multiplier is stored at C053H. The result is to be
stored at memory location address C054H to C055H. (Note: 8-bit multiplicand is extend to 16-bit).
LabelMnemonics+Operand Comment/Remark
LHLD C051H ; Load HL with two consecutive memory contents.
XCHG ; Exchange HL with DE and vice versa.
LDA C053H ; Load A with memory.
LXI H, 0000H ; Initialize HL.
LOOP DAD D ; Add HL with DE and store to HL.
DCR A ; Decrement A by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
SHLD C054H ; Store HL to two consecutive memory locations.
HLT ; Stop processing.
3) A hex number is stored at location 3000H. Write an assembly language program to interchange its digits.
The new number is to be stored at 3001H. Add original number with new number and store result at location
3010H.
Label Mnemonics+Operand Comment/Remark
LDA 3000H ; Load A with memory.
MOV B, A ; Copy A to B.
RRC ; Rotate accumulator towards right 4 times then
RRC ; stores exchanged two 4 bit nibbles to A.
RRC ;
RRC ;
STA 3001H ; Store A to memory.
ADD B ; Add A with B and store to A.
STA 3010H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR 1) Write assembly language program to count occurrences of the data ABH in a memory block is
starting from 4000H to 400FH. Store count at memory location 4500H.
LabelMnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
MVI C, 10H ; Move immediate data to C.
LXI H, 4000H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI ABH ; Compare A with data.
JNZ NEXT ; Jump on no zero 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 4500H ; Store A to memory.
HLT ; Stop processing.
2) A block of data is stored in a memory location from 7500H to 75FFH. Write an assembly language
program to transfer block in reverse order to memory location 7600H and onward
LabelMnemonics+Operand Comment/Remark
LXI H, 75FFH ; initialize HL.
LXI D, 7600H ; initialize DE.
MVI C, FFH ; Set count to C.
LOOP MOV A, M ; Copy HL to A.
STAX D ; Store A to DE register pair address.
DCX H ; Decrement HL by 1.
INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump to label LOOP if z = 0 i.e. C#0.
HLT ; Stop processing z=1 i.e. C = 0.
3) Write an assembly language program to find largest element in a block of data. The length is in memory
location D000H and block begins in memory location D002H. Store maximum in D000H. Assume that all
number are 8 bit unsigned binary numbers.
LabelMnemonics+Operand Comment/Remark
LDA D000H ; Load A with memory.
MOV C, A ; Copy A to C.
LXI H, D002H ; Initialize HL
MOV A,M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA D000H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct –2012 1) Write an ALP to subtract the number stored in memory location 3601H from the number
stored in memory location 3600H. Store the positive result at location 3602H.
Label Mnemonics+Operand Comment/Remark
LXI H, 3600H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
SUB M ; Substract HL from A and store to A.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
DCX H ; Decrement HL by 1.
SUB M ; Substract HL from A and store to A.
NEXT STA 3602H ; Store A to memory.
HLT ; Stop processing.
2) Write an ALP to generate the Fibonacci series for first eight number. Store the series in a memory block
starting from C100H.[Note : The first eight numbers of series are : 00, 01, 01,02,03,05,08,0D]
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
MVI C, 01H ; Move immediate data to C.
MVI D,08H ; Move immediate data to D.
LXI H, C100H ; Initialize HL.
MOV M, B ; Copy B to HL.
INX H ; Increment HL by 1.
MOV M,C ; Copy C to HL.
DCR D ; Decrement D by 1.
LOOP INX H ; Increment HL by 1.
MOV A, B ; Copy B to A.
ADD C ; Add A with C and store to A.
MOV M, A ; Copy A to HL.
MOV B,C ; Copy C to B.
MOV C, A ; Copy A to C.
DCR D ; Decrement D by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
3) Write an Assembly Language Program to multiply the given BCD data at location C050H and C051H.
Store the result in C060H and C061H respectively.
Label Mnemonics+Operand Comment/Remark
LXI H, C050H ; Initialize HL.
MOV D, M ; Copy HL to D.
INX H ; Increment HL by 1.
MOV C, M ; Copy HL to C.
MVI B, 00H ; Move immediate data to B.
MVI A, 00H ; Move immediate data to A.
LOOP ADD D ; Add A with D and store to A.
DAA ; Decimal adjust accumulator 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 C060H ; Store A to memory.
MOV A, B ; Copy B to A.
STA C061H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write a program in assembly language that converts a BCD number stored at C030H to its hexadecimal
equivalent. Store the hexadecimal result in C031H.
Label Mnemonics+Operand Comment/Remark
LXI H, C000H ; Initialize HL.
MOV A, M ; Copy HL into A
ANI OFH ; ANDing A with 0FH & maskoff MSB
MOV B, A ; Copy A to B
MVI C, 0AH ; Move Immediate 0AH to C.
MOV A, M ; Copy HL to A.
ANI F0H ; ANDing A with F0H & maskoff LSB.
RRC ; Rotate right A without cy
RRC ; Rotate right A without cy
RRC ; Rotate right A without cy
RRC ; Rotate right A without cy
MOV D, A ; Copy A to D.
MVI A, 00H ; Move Immediate 00H to A & clear.
UP ADD D ; A = A + D.
DCR C ; Decrement C by 1.
JNZ UP ; Jump to label UP if z=0
ADD B ;A=A+B
STA C001H ; Store A into ML C001H.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
2) Write an ALP to count number of even data byte occurring in a block stored from memory location 3001H and
onwards the length of block is stored in location 3000H store the result in 3100H.

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.

Label Mnemonics+Operand Comment/Remark


LXI H, 3000H ; Initialize HL.
MOV C, M ; Copy HL to C.
MVI E, 00H ; Move immediate data to E.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right each bit and store to A.
JC NEXT ; Jump on carry to label NEXT.
INR E ; Increment E by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, E ; Copy E to A.
STA 3100H ; Store A to memory.
HLT ; Stop processing.

Label Mnemonics+Operand Comment/Remark


LXI H, C030H ; Initialize HL.
MOV A, M ; Copy HL to A.
ANI 0FH ; Mask off LSB of 4 bit nibble i.e. separate LSB & store to A.
MOV C, A ; Copy A to C.
MVI A, 00H ; Move immediate data to A.
LOOP ADD M ; Add A with HL and store to A.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA C031H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March –2012 EXAM DATE: / /2013 COMPSci(D92)
1) An 8-bit number is stored in memory location 4400H. Write an assembly language program to count
‘zero’ in the given number. Store count in memory location 4500H.
Label Mnemonics+Operand Comment/Remark
MVI C, 08H ; Move immediate data to C.
MVI D, 00H ; Move immediate data to D.
LDA 4400H ; Load A with memory.
LOOP RRC ; Rotate accumulator towards right without carry and store to A.
JC NEXT ; jump on carry to label NEXT.
INR D ; Increment D by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
MOV A, D ; Copy D to A.
STA 4500H ; Store A to memory.
HLT ; Stop processing.
2) A series of numbers are stored in memory locations from C001H to C008H. Write a program in assembly
language to find smallest number among these numbers. Store smallest number in memory location C009H.

Label Mnemonics+Operand Comment/Remark


MVI C, 08H ; Move immediate data to C.
LXI H, C001H ; Initialize HL.
MOV A,M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JC NEXT ; Jump on carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA C009H ; Store A to memory.
HLT ; Stop processing.
3) Write an assembly language program to count number of odd data bytes occurring in a block starting
from memory location A001H to A0FFH. Store result at memory location B000H.
Label Mnemonics+Operand Comment/Remark
MVI C, FFH ; Move immediate data to C.
MVI E, 00H ; Move immediate data to E.
LXI H, A001H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right each bit without carry & store to A.
JNC NEXT ; Jump on no 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 B000H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR 1) A hex number is stored at location AB00H. Write an assembly language program to
interchange its digit. The new number is to be stored at AB01H.Add original number with
new number and store result at location ABCDH.
Label Mnemonics+Operand Comment/Remark
LDA AB00H ; Load A with memory.
MOV B, A ; Copy A to B.
RRC ; Rotate accumulator towards right each bit 4 times
RRC ; without carry and exchanges two 4 bit nibbles each
RRC ; other and store interchanged two digits to A.
RRC
STA AB01H ; Store A to memory.
ADD B ; Add A with B and store to A.
STA ABCDH ; Store A to memory.
HLT ; Stop processing.
2) Write an assembly language program to add two BCD numbers stored at locations
AB00H and AB01H. Place BCD result in location AB02H and onwards starting with LSB.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, AB00H ; Initialize HL.
MOV A, M ; Copy HL to A.
INX H ; Increment HL by 1.
ADD M ; Add A with HL and store to A.
DAA ; Decimal adjust accumulator i.e. convert to decimal/BCD.
JNC NEXT ; Jump on no carry to label NEXT.
INR B ; Increment B by 1.
NEXT STA AB02H ; Store A to memory.
MOV A, B ; Copy B to A.
STA AB03H ; Store A to memory.
HLT ; Stop processing.
3) Write a program in assembly language to find 2’s compliment of 8bit number stored in
memory location C000H. Store result at memory location C001H.
Label Mnemonics+Operand Comment/Remark
LXI H, C000H ; Initialize HL.
MOV A, M ; Copy HL to A.
CMA ; Compliment A i.e. calculate 1’s compliment.
ADI 01H ; Add A with 1’s compliment i.e. calculate 2’s
compliment and stores to 2’s compliment to A.
STA C001H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct –2011 EXAM DATE: / /2011 COMP SCI : 2 (D9-2)
1) Write a program in assembly language to find the position of a data 05H in a block of
memory D001H to D005H. If data is found then store the position of data at memory location
D100H else store 00H at the same memory location.
( Note : It is assumed that data 05H may present only at once. )
Label Mnemonics+Operand Comment/Remark
MVI C, 05H ; Move immediate data to C and set count.
LXI H, D001H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
CPI 05H ; Compare A with data.
JZ STORE ; Jump on zero to label STORE.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, D100H ; Initialize HL.
MVI M, 00H ; Move immediate data to HL and clear HL .
JMP STOP ; Unconditional jump to label STOP.
STORE STA D100H ; Store A to memory.
STOP HLT ; Stop processing.
2) Write a program in assembly language to double the contents of block of memory from
D001H to D00AH. Store the doubled contents at same memory locations.(Note: It
is assumed that contents are not exceeding 0FH.)
Label Mnemonics+Operand Comment/Remark
XRA A ; XOR A with A and clear A and carry.
MVI C, 0AH ; Move immediate data to C.
LXI H, D001H ; Initialize HL.
LOOP MOV A, M ; Copy HL to A.
RLC ; Rotate accumulator towards left without carry and store to A.
CPI 0FH ; Compare A with data.
JNC NEXT ; Jump on no carry to label NEXT.
MOV M, A ; Copy A to HL.
INX H ; Increment HL by 1.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
3) Write a program to exchange the two nibbles stored at 2500H. Store the exchanged
number at 2501H.
Label Mnemonics+Operand Comment/Remark
LXI H, 2500H ; Initialize HL.
MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right 4 times and exchanges
RRC ; the two nibbles and store to A.
RRC ;
RRC ;
STA 2501H ; Store A to memory i.e. exchanged two nibbles are store.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write a assembly language program to copy the contents of a block of memory whichis
from 2501H to 2505H to another block begins from 3501H.
Label Mnemonics+Operand Comment/Remark
MVI C, 05H ; Move immediate data to C.
LXI D, 2501H ; Initialize DE.
LXI H, 3501H ; Initialize HL.
LOOP LDAX D ; Load A with DE register pair addressed content.
MOV M, A ; Copy A to HL
INX H ; Increment HL by 1.
INX D ; Increment DE by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
2) There are two blocks of memory one is from 2501H to 2505H. Another is from 3501H to
3505H. Write a program in assembly language to check whether contents of these two blocks
are exactly same or not. If contents are same then memory location D100H should contains
00H else FFH.
Label Mnemonics+Operand Comment/Remark
MVI C, 05H ; Move immediate data to C.
LXI H, 2501H ; Initialize HL.
LXI D, 3501H ; Initialize DE.
LOOP LDAX D ; Load accumulator with DE register pair addressed content.
CMP M ; Compare A with HL.
JNZ NEXT ; Jump on no zero to label NEXT.
INX H ; Increment HL by 1.
INX D ; Increment DE by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, D100H ; Initialize HL.
MVI M, 00H ; Move immediate data to HL & clear HL.
JMP STOP ; Unconditional jump to label STOP.
NEXT LXI H, D100H ; Initialize HL.
MVI M, FFH ; Move immediate data to HL.
STOP HLT ; Stop processing.
3) Write a program in assembly language to rotate the content of memory location D000H
towards left by one bit position and add original contents with rotated number and store the
result from D001H.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; Initialize HL.
MOV A, M ; Copy HL to A.
RLC ; Rotate accumulator towards left by 1bit position.
ADD M ; Add A with HL and store to A.
STA D001H ; Store A with memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March –2011 1) Write an Assembly Language Program to add all odd numbers stored in memory block of 10
locations starting from 2000H. Store two byte sum at memory location starting from 3000H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
MVI D, 00H ; Move immediate data to D.
MVI C, 0AH ; Move immediate data to C.
LXI H, 2000H ; Initialize HL.
LOOP MOV A,M ; Copy HL to A.
RRC ; Rotate accumulator towards right 1 bit position & store to A.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A,B ; Copy B to A.
ADD M ; Add A with HL and store to A.
MOV B,A ; Copy A to B.
JNC NEXT ; Jump on no carry to label NEXT.
INR D ; Increment D by 1.
NEXT INX H ; Increment HL by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, 3000H ; Initialize HL.
MOV M, B ; Copy B to HL.
INX H ; Increment HL by 1.
MOV M,D ; Copy D to HL.
HLT ; Stop processing.
2) Write an Assembly Language Program to separate nibbles of a number stored at memory location 2000H. Multiply
separated nibbles and store result.
Label Mnemonics+Operand Comment/Remark
LXI H, 2000H ; Initialize HL.
MOV A,M ; Copy HL to A.
ANI 0FH ; ANDing A with data & maskoff of LSB of 4 bit nibble & store to A.
MOV E,A ; Copy A to E.
MOV A, M ; Copy HL to A.
ANI F0H ; ANDing A with data & maskoff of MSB of 4 bit nibble & 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.
MVI D, 00H ; Move immediate data to D.
LXI H, 0000H ; Initialize HL.
LOOP DAD D ; Add HL and DE and store to HL.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
3) Write a program in Assembly Language Program to transfer a block of data from 1050H to 1059H to memory
location whose starting address is 1070H.
Label Mnemonics+Operand Comment/Remark
MVI C, 0AH ; Move immediate data to C.
LXI D, 1050H ; Initialize DE.
LXI H, 1070H ; Initialize HL.
LOOP LDAX D ; Load A with DE register pair addressed content.
MOV M, A ; Copy A with HL.
INX H ; Increment HL by 1.
INX D ; Increment D by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
OR1) Write an Assembly Language Program to count number of even data bytes occurring in a block starting from
memory location C030H to C039H.Store result at the memory location C040H.

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.

Label Mnemonics+Operand Comment/Remark


MVI B, 00H ; Move immediate data to B.
LHLD C030H ; Load HL with two consecutive memory locations.
XCHG ; Exchanges HL with DE and vice versa.
LHLD C032H ; Load HL with two consecutive memory locations.
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 SHLD C034H ; Store HL to two consecutive memory locations.
MOV A, B ; Copy B to A.
STA C036H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
Oct –2010 EXAM DATE: / /2010 COMP SCI : 2 (D9-2)
1) A series of numbers are stored in memory locations from C001H to C008H. Write a program in
assembly language to find largest number among these numbers. Store largest number in memory
location C009H.
Label Mnemonics+Operand Comment/Remark
MVI C, 08H ; Move immediate data to C.
LXI H, C001H ; Initialize HL.
MOV A, M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA C009H ; Store A to memory.
HLT ; Stop processing.
2) Write an assembly language program to count number of times the data A4H is found in a block
of memory location starting from 4000H. The length of block is stored in location 3FFFH. Store
result in location 5000H.
Label Mnemonics+Operand Comment/Remark
MVI B, 00H ; Move immediate data to B.
LXI H, 3FFFH ; Initialize HL.
MOV C, M ; Copy HL to C.
LOOP INX H ; Increment HL by 1.
CPI A4H ; Compare A with data.
JNZ NEXT ; Jump on no zero 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 5000H ; Store A to memory.
HLT ; Stop processing.
3) Write an assembly language program to fill memory locations 3000H to 30FFH with the
hexadecimal numbers 00H to FFH respectively.
Label Mnemonics+Operand Comment/Remark
MVI C, FFH ; Move immediate data to C.
MVI A, 00H ; Move immediate data to A.
MVI B, FFH ; Move immediate data to B.
LXI H, 3000H ; 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 copy a block of data having starting Address
7900H to the new location 9100H. The length of block is stored at memory location 78FFH.
Label Mnemonics+Operand Comment/Remark
LXI H, 78FFH ; Initialize HL.
MOV C, M ; Copy HL to C.
LXI D, 9100H ; Initialize DE.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
STAX D ; Store A to DE register pair address.
INX D ; Increment DE by 1.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
HLT ; Stop processing.
2) A block of data is stored in memory locations from D001H. The length of block is stored
in memory location D000H. Write a program in assembly language that searches for first
occurrence of data 11H in given block. Store address of this occurrence in HL pair. If the
number is not found then HL pair should contain 0000H.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; Initialize HL.
MOV C, M ; Copy HL to C.
LOOP INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
CPI 11H ; Compare A with immediate 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, 0000H ; Initialize HL.
STOP HLT ; Stop processing.
3) A hex number is stored at location C000H. Write an assembly language program to
interchange its digit. The new number is to be stored at C001H. Add original number with
new number and store result at location C010H.
Label Mnemonics+Operand Comment/Remark
LX H, C000H ; Initialize HL.
MOV A, M ; Copy HL to A.
RRC ; Rotate accumulator towards right 1 bit position each 4 times then
; exchanges two 4 bit nibbles to each other then store to A.
RRC ;
RRC ;
RRC
STA C001H ; Store A to memory.
ADD M ; Add A with HL and store to A.
STA C010H ; Store A to memory.
HLT ; Stop processing.
MATRIX SCIENCE ACADEMY
March –2010 EXAM DATE: / /2010 COMP SCI : 2 (D9-2)
1) Write a program in assembly language to find greatest number among a contents of block of
memory which starts from D001H. The length of block is stored at D000H. Store the greatest
number at the end of block.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; Initialize HL.
MOV C, M ; Copy HL to C.
INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
DCR C ; Decrement C by 1.
LOOP INX H ; Increment HL by 1.
CMP M ; Compare A with HL.
JNC NEXT ; Jump on no carry to label NEXT.
MOV A, M ; Copy HL to A.
NEXT DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero label LOOP.
INX H ; Increment HL by 1.
MOV M, A ; Copy A to HL.
HLT ; Stop processing.
2) Write a program in assembly language to sum the series stored from D001H. The length
of series is at D000H. Store result from D100H.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; 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.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
STA D100H ; Store A to memory.
HLT ; Stop processing.
3) Write a program in assembly language to subtract contents of memory location D001H
from the contents of memory location D000H. Store absolute difference at D002H.
Label Mnemonics+Operand Comment/Remark

LXI H, D000H Initialize HL


MOV A , M ; Copy HL content to A.
INX H ; Increment HL address by 1.
SUB M ; A= A – HL
JNC NEXT ; Jump to Label NEXT if CY=0
CMA ;1’s compliment is calculates.
INR A ; Increment A by one.
NEXT INX H ; Increment HL address by 1.
MOV M ,A ; Copy content of A to HL
HLT ; Stop processing
MATRIX SCIENCE ACADEMY
OR1) Give appropriate comments/remarks to the following program:
Label Mnemonics Comments/Remark
STC ;
CMC ;
MVI A, 08H ;
LXI H, D001H ;
LOOP MOV M, A ;
INX H ;
DCR C ;
JNZ LOOP ;
HLT ;
2) There is block of memory stored from D001H. The length of block is stored at memory location D000H.
Write a program in assembly language to check whether content of these blocks are in sequence(consecutive)
or not. If contents of blocks are in sequence(consecutive) then memory location D100H should be contains
00H else FFH.
Label Mnemonics+Operand Comment/Remark
LXI H, D000H ; Initialize HL.
MOV C, M ; Copy HL to C.
INX H ; Increment HL by 1.
MOV A, M ; Copy HL to A.
DCR C ;Decrement C by 1.
LOOP INX H ; Increment HL by 1.
INR A ; Increment A by 1.
CMP M ; Compare A with HL.
JNZ NEXT ; Jump on no zero to label NEXT.
DCR C ; Decrement C by 1.
JNZ LOOP ; Jump on no zero to label LOOP.
LXI H, D100H ; Initialize HL.
MVI M, 00H ; Move immediate data to HL.
JMP STOP ; Jump unconditional to label STOP.
NEXT LXI H, D100H ; Initialize HL.
MVI M, FFH ; Move immediate data to HL.
STOP HLT ; Stop processing
3) Trace the following program and show contents of the following by filling blanks:
Label Mnemonics
MVI A, 05H
LXI H, D001H
MVI C, 05H
LOOP: MOV M, A
DCR A INX
H DCR C
JNZ LOOP
HLT
i) [D005H] = 01H ii) [A] = 00H iii) [C] = 00H iv) Regi H = D0H v) Regi L= 06H

You might also like