Instruction Set 1 Compressed 2 1
Instruction Set 1 Compressed 2 1
Programming of 8085
I Probable marks : 43
I
Scope of the syllabus :-
• Addressing modes in 8085
.. fi:?gramming model of 8085
• Instruction Set and
• Programming of 8085
• Study of instruction set :
instructions.
• Data transfer, Arithmetic, Logic,' Branching, Stack, 1/0 and machin e control
• Assembly language program ming based on instructions.
addressing
Q. 1 What do you mean by addressing modes of a microprocessor ? Enlist the
modes in 8085.
Ans.:
ying one operands
(1) · Addressing mode of a IlllLa.1processor is the variou s forma ts of specif
r or it can
(direc_tly, indirectly etc). The operan d can be data (8 or 16 bit), addres s, registe
be implicit.
uses one
(2) Every microproces-'lr has its own set of instruc tions. Each of these instruc tions
of the addres sing modes. ·
:
(3) The microprocessor 8085 has five addres sing mode_s, which are given below
i) Direct addres sing
ii) · Register addres sing
iii) Immed iate addres sing
iv) Register indirect addres sing
v) Implie d addres sing
D.ata cr1ie.1:nory - - - - - -
405\l ...,0_ 0 _0_0_0_0_0_1_ ~ 1°1 1 1~1 1 1-1 1 1-11 1
S Z AC P CY
~ L Fla gs
-->;btt>r f
--- ~-'(.)_ __}_ _SO _
H Lpl'(.li r
&-fort!' O JX' I atmn After operation
ln th t> ,;t,·en t'X<lmpl~, the H L register pai r points to mem ory loca tion 4050 H . T he data in
th .i s Jo canon (t(X)U OOOl )i 11, Hum .tddt>d to tne n mt~nts o f the accumulator (l l 11 111 l )i.
Tile su1n IS Sh.l r ~ in a<.'Cu.mulato r and appropria t.e flags are also set dnd reset based on
the .re51uJt.
U) J.m:med i~te addrt>i~h1g mod~ ; tl\l.11l"h :!OOI.))
1) Jn 1mrn00Ja f~ addres.~uig tlw d a ta a pp~ars immediately aft.er opcode of ins tnicti(,n i.n
p rograui rnl"mtJr}'
2) ·n11."lt' clfC >;.:-nH,l ll r 2 or ) r yt<: iH'-lrucfoms.
Accumulator ~
·~ O O 1o
I OO ~ ---~~ / ~ L_o_o_Q_!__0_l_Q_O_...I Accumulato r
CADI08=:>
Opcode
Program
m emory C6H ~ 1°1°1 -11 1-111-1°1
4050 0000 1000 S Z AC P CY
data Flags
Before operation After operation
In the example, MPU fetches the opcode (C6) from program memory and after decoding
it. MPU finds the immediate data (0000 lOOO)z in the next consecutive program memory
location. This data is added to the contents of the accumulator and result is placed in the
accumulator.
Q. 4 What do you understand by register indirect and implicit addressing modes ?
Explain with suitable example. List the names of any four instructions which make
accumulator content clear. . «•IIJunijj
Ans. : Register indirect addressing : Please refer to Q. 3 (I).
Implicit addressing: Please refer to Q. 3 (II).
Following four instructions make accumulator content clear :
(1) ANI OOH (2) XRA A · (3) SUB A (4) MVI A, OOH
Q. 6 What are the groups in which instructions in 8085 are classified? i•S•M
Ans. : The instructions in 8085 can be classified into following five groups, depending upon
their function :
1) Data transfer group 2) Arithmetic group
3) Logical group 4) Branching group
5) Machine control group
1) Data Transfer Group :
This group of instruction copies data from a location called source to another location
called a destination without modifying the content of source. These instructions move
data between registers or between memory locations and regjs ters. For eg. MOV,
MVletc.
2) Arithmetic Group :
The instruction of this group performs arithmetic operations such as ad dition,
subtraction, increment or decrement etc. on d ata in registers or memory . For eg. ADD,
SUU, fNR, OCR etc.
3) Logical Group :
The logical group instructions perform logical operations such as AND, OR, XOR,
complement etc. generally with the accumulator.
4) Branching Group :
The branching group instructions allow programmer to change the sequence of
execution of program either conditionally or unconditionally.
For e.g. JMP, JC, JZ etc.
5) Machine Control Group : · .
These instructions control machine operations such as Halt, Interrupt
For e.g. NOP, HLT.
Q. 9 Explain PCHL Instruction of micro-processor 8085 and justify the stateme nt that
it is
equival ent to 3 byte uncond itional jump instruct ion. !•tJl@j t)j
Ans. : For only Explanation of PHCL Please refer Q. B(b), Pg. No. 2-6.
In PCHL progra~ _counter is loas{eq \,\{i U1 _memol'y ad_dress stored in HL _pair,.. ln JMP
a1dr_ess y r~gram _c~unter is loaded_ with memory address specified in instruction.
Workin g of both instruct ion is same i.e. load PC ,-vith 1nemory -address hence PCI IL
is
equival ent to uncondi tiona l jump
A dd re~itn~
G n,u p ttr,1nchln~ r:r, 111p
Hytr9 ,'\ by h'S
Fla1,; No-tw
-1 r1
tm l l:i tr,m ~fo rt't·d 1nH .'\1.ndJthm ally to llw 1rw111urv l~ 1,·MliH1 1 whor
Co mm ent : Th,• ~)n
,n.
add r~,s 111o sptx-lfit'd in tht- imi tructh
(4} ConcHtio na l It.imp : v If ,tw
..t:.t.!J}dl th 111 l.1 tru, 1. l'lit:•
ctk ,n~ . thr• /m np 1~ tak N, nnl
1n com:Utinnal jum p in~tru
dlth,n~ fU't 1 ltk Hlvt•n lwlow .
ron d1tl,,n ,d jum p in~tructlon~ nnd con
i) JN Z n('fdr Jum p on not i t•ro (Z ~ 0)
1i) JZ "'dctr Jump cil\ ~,•ft,
(Z 1) i;;
Q. 13 Exp lain the use of stac k and stac k pain ter regi
ster in Inte l 8085 . 49 ii
Ans .:
is used for tem pora ry stor age of En..:a:-:-
1) The stac k is a part of Read / Writ e mem ory that
.
inior ma tion duri ng the exec utio n of a prog ram
te resu lts and the retu rn add.i..'""ESS fr: 2-..'-c'
2) The b inar y info rmat ion is basi cally the imm edia
o f subr outi ne prog ram s:
micr opro cess or.
3) The stac k is shar ed by the prog ram mer and the
ents of a regi steI pair by usin g F~.'~-:'.-:
4) The prog ram mer can stor e and retri eve the cont
and POP instr uctio ns.
es the cont ents of the pn~ ram C\.)t:f i:-£
5} Simi larly, the micr opro cess or auto mati cally stor
whe n subr outi ne is calle d.
ial mem o.rv poin ter ~ ca.He--.1 :.:~
6J The stac k is imp leme nted with the help of spec ·
0
j(' f \ } - n ::; H
Q. 15 Accumulator contains data E3H. What will be the content of accumulator after
stepwise execution of each of following instructions ?
•&•0M*
t1
(i) ANI 58 H (ii) RRC (iii) CMA
Ans. : (i) ANI 58 H : Logically ANDed 58 H with [A]
Before execution: [A] = E3H '
Instruction : ANI 58 H
E3 H = 11100011
AND 58 H = 01011000
01000000 =40H
After execution [A] = 40 H
(ii) RRC : Rotate accumulator right by one bit.
Before execution : [A]= 40 H = 010000000
Instruction : RRC
After execution [A]= 0 0 100 0 0 0 = 20 H
and [Cy ] = 0 H
[A] = 20 H
(iii) CMA : Complement the contents of accumula tor
Before execution : (A J = 20 H :::: 0 0 1 00 0 0 0
In struction : CMA
After execution : (AJ = 1 1 0 1 1 11 1 :;:; DFH ' A] :::: DFH
1
Q. 16 The accumulator in 8085 contains the data BSH and register B contains dat.i 40 H.
What will be the content of accum u lator after execution of each of tht! following
instructions independe ntl y ? (l\1,ufh 1002)
(a) RLC (b) ORI 2'J H (d AN A B
Ans.:
(a) RLC: Rotate accum ulator left throug h carry.
Before execu tion: (A] = B8H = 10111000
Instru ction : RLC
After execu tion: (A]= 0 1 1 1 0 0 0 1 = 71 H
:. [Al= 71 Hand [Cy]= 1 H
(b) ORI 29 H: Logica lly ORed 29 H with [A]
Before execu tion: [A)= B8H = 10111000
Instru ction ORI 29 H
B8H = 1 0 1 1 1 0 0 0
OR 29 H = 0 0 1 0 1 0 0 1
1 0 1 1 1 0 0 1 = B9H
After execut ion : [A] = B9H
(c) ANA B: Logically AND [Reg. B] with [A]
Before execut ion: [A]= B8H = 1011 100 0
[Reg. B] = 40 H = 0 1 0 0 0 0 0 0
Instruc tion : ANA B
1011 1000
AND 0100 0000
0000 0000 =00H
After execut ion:
[A] = 00 H
execution of
Q. 17 The accumulator contains the data A4H. What will be its conten ts after
follow ing instructions indepe ndentl y. iiiBNiS!
i) XRI 08H ii) CMA iii) SUB A
Ans.:
Accumulator = A4 H
= 1010 0100
0 XRI 08 H:
Logically Ex-ORed 08H with conten ts of accum ulator.
Before execut ion: [A)= A4 H
Instru ction: XRI 08 H
A4 H = 10100100
XOR OB H = 0 0 0 010 0 O
1010 1100
= ACH
After execu tion: lAJ = ACH
ii) CMA :
Complement the accumulator
Before execution : [A] = A4 H
=10100100 '
Instruction : CMA
After execution :
[A] = 01011011
= SBH
i.e. [A] = SB H
iii} SUB A:
Subtract accumulator from itseU.
Before execution : [A] = A4 H
Instruction : SUB A
[A] : A4 H =10100100
2's complement of A4 = 0 1 0 111 0 0
+ [A] : A4 = 1 0 1 0 0 1 0 0
IT] 00000000
complement carry .J..
0 00000000
Result [A] = 00 H
Q. 18 The accumulator of 8085 contains data 43H. What will be its co.n tents after the
execution of follo~g instructions independently ?
0 0 1 1 1 1 1 0 = 3E H
So after execu tion of instru ction I
{A) = 3E H
(ii) ADI C5H :
This instru ction adds the data CSH to th e con tent of accu mula tor i.e. 45H.
(AJ ; 451-f = 0 1 00 0 1 O 1
+CSH == ll...OOO 1 O 1
~
0 0 0 0 1 O 1 o = OA H
After execut-ion, fA] ::; Oooo 1 o 1 0
= OAH
Q. 20 Accumulator of 8085 contains data 56 H. What will be the contents after the
execution of following instruction independently. ('.\larch 200'.i)
(iii) INR A : This instruction increments the c<;mtents of accumulatqr by one and result
stored in the accumulator itself.
Before execution :
[A] = 56 H = 0 10101 1 0
[A] = 56 H = 0 101011 0
+ 01H = 0 0 0 0 0 0 U1
0 1 0 1 0 l 1 l = 57 H
After execution : IA] = 57 H
Q. 21 If ACC contains data BCH, register C contains ADH. What will be the content of
accumulator after execution of each of the following iruJtructions independently?
(i) SUB C (ii) CMA (iii) XRA C -
Ans. : Accumulator = BCH = 1 O1111 0 O
(i) SUB C : Subtract contents of register C from accumulator.
Before execution :
[A] = BCH = 1 0 111 1 0 0 .
[C] = ADH = 1 0 1 0 1 1 0 1
Instruction : SUB C
[A]= BCH = 1 0 11 1 1 0 0
Q. 22 The accumulator of 8085 proces..!lor et>nt•ins delta tUU-.t and regll ter fl c-uf\l'flin- iJ~ ft ,
What will be the content of a{-eumulator after e~~rution nf e4tr h of the f'ollowh1 0
instruction indepe.ndentJy ? l~l.111 h J tll ll
(i) ORI FOH (ii) ANA B um XtU O.FH
Ans.:
Accu:mulator A= B 8 H =10111000
(i) ORI F0 H - logically OR ed FO H with [A]
B8 H = 10 11 1000
ORI F0 H = 11 11 0000
11 11 1000 = F 8 H
After execution [A]= F 8 H
(ii) ANA B - Logically AND (Reg B) with [A]
B8 H = 10 11 1000
AND B-44 H = 0100 0100
00 00 0000 = 00 H
After execution [A]= 00 H
(iii) XRI OF H - Logically Ex-ored OF H with [A]
BBH = 10111000
XRI OF H = 00001111
10 11 0111 = B 7 H
After execution [A] = B7 H
Q. 23 If Accumulator -Contains the Data 23H and B Register Contains 35H. What will bt
the contents of Accumulator. After execution of each of the following instruction
independently : . fMMiJljj
(i) XRA (ii) ANI FOH (iii) CPI OAH
Ans.:
A = 23 H = ·0010 0011
B = 35 H = 0011 0101
(i) XRA B - Ex.ored reg. B with contents of A.
23 H = 0010 0011
XOR with 35 H = 0011 0101
= 00010110
---
1 6
A = 16H
2 0
A= 20 H
A reg.
(ill ) CP IOA H - Co mp are OA H wit h
A = 23 Hf - Bef ore exe cut ion
ain s
Wh ile com pai rin g Ac rum ula tor rem
Un cha nge d hen ce A = _2 3 H
G9 H. Wh at are the
and Re gis ter B con ten ts are
Accumulator contents are B81{
Q. 24
tor an aF iag reg iste r aft er exe cut ion of ins ~c tio ns AN A B . .... ,
contents of Accumula t
. (;\l arc h 20] . I)
SU B B independenUy. '
Ans.:
(A) = BBH = 10111000
(B) = C9 H = 11001001
ula tor
'1) ANAB : Logically AN D wit h Ac cum
10. ll 1000
110 010 01
~q~q1lOO0
A 88H '=
Fla gs ➔ S =1, Z =0, AC = 0, P ~
i,
CY = O
cum ula tor
(2) SUB B : Sub tra ct B Reg. fro m Ac
B = llOO 1001
l's com ple me nt of B = 0011 011
0
+ 1 + 1
2's com ple me nt of B 0011 0111
Ad d A wit h 2's com ple me nt of B
001 101 11
+ 1011 1000
@) 111 011 11
Res ult ➔ A = EF H
Fla gs - , S = 1, Z = 0, AC == o, p = 0,
CY = 1
Q. 25 For the following instructions, write the addressing mode, instruction group and
the length of,the rnstruction (in terms of bytes). (if)a•fijj
(i) LHLD ABCDH (ii) LDAX B
Q . 26 The following instructions are intended to clear ten (10) memory locations starting
from th-e memory address 0009H. Explain why a large memory bl-0ek will be erased
or cleared and the program will stay in an infinite loop. Nfli•@l
LXI H, 0009H
LoopMVI M,OOH
DCXH
JNZLoop
HLT
Ans.:
(1) In given loop, large memory block will be erased or cleared and the program will stay in
an infinite loop.
(2) In the given loop, the sequence is repeated by the instruction JNZ Gump on No zero)
until the count becomes zero. However, the instruction DCX does not set the zero flag.
Therefore, the instruction JNZ would be unable to recognize when the count has
reached zero and the program would remain in a continuous loop.
Q. 28 What ue different addressing modes ? Which type of addressin_g mode is used for
following instructions ? MIQ@jj
(i) XCHG (ii) XRI (iii) SUB M (iv) CMC
Am. : Ref-erQ.l and appendix.
Q. 29 ldecntify the addressing modes of the following instructions and justify your
.mswer. W LOA 2000 H (ii) LDAX B (iii) STC (iv) ADC 0
Ant. : Ri:~e~~ ~ . 0 : to_~nd addressing mode and re.fer Q 2_to justif221nsw!::r·
Q. 30 Describe fo llowing instTuctfons of 8085 microprocessor. ~ 4ii111iiiiii@
iiiiiw!i,
ti} XCHG (ii) RA R (i ii) ADC R
Ans. : Ple~ refer appendix.
After execution :
[A] = 45 H = 0 1 0 0 0 1 0 1
[E] = 45 H = 0 1 0 0 0 1 0 1
[A] = 45H
Q. 35 The accumulator contains 05H and register B contains 08H. What will be the effect of
'SUB B' instruction on flags ? Explain it with diagram. (March 2010)
Ans-: ACC = 05 H = 0000 0101
B = 08 H = 0000 1000
After execution of SUB B _
Accumulator contains 2's compliment of magnitude of result
i.e. ACC = 11111101 = FDH
Mentioning the status of carry flag
Q. 36 Differentiate DAD and ADD Instruction of 8085 Micro-Processor
lt•&►·Mill
Ans.:
DAD ADD
1. In this lll!3truction contents of register In this instruction register r or content of
pair rp are added to the contents of memory location whose address is stored in
HL pair & result is placed in register H-L pair is added with content of
Hand L. accumulator and result is placed in
accumulator.
2. Only carry flags in affected. All flags are affected.
3. Register pairs BC, DE are used. Only register A, B, C, D, H, E, Lare used.
4. Used for 16 bit addition Used for 8 bit addition
Q. 37
.
Differentiate between PUSH and POP. CllNP111 NI
Ans.:
PUSH . POP
1. The contents of the higher order register The contents of the memory location
of register pair rp are moved to memory whose address is specified by the stack
location whose address is one less than pointer are moved to low order register
the content of stack pointer. of register pair rp.
2. The contents of the low order register of The contents of the memory location,
register pair rp are moved to the whose address is one more than the
memory location whose address is two content of stack pointer are moved to
less than the content of stack pointer. high order register of register pair rp.
3. In this instruction, stack pointer is In this instruction, stack pointer is
decremented by two. incremented by two.
4. Let [SP] = D01 5, [BJ = 25 H and Let [SP] = 2001 H
(CJ= 55 H (2001] = 10 H, [2002] =20 H
After execution of PUSH B After execu tion of POP H
ID014J = 25 H [H] ;:: 20H, [L] = lOH
[D013] = SSH and [SP] = 0013 H [SPJ =2003 H
An_s. :
Acc umula tor = B7H
= 10 1 1 0 11 1
(i ) O RI 58 H
Log jcal ly OR ed 58H " i th [A)
0 11 l
Be fore Exe cuti on [A] = B7H =10 11
B7H = 1 0 1 1 0 1 1 l
OR SSH = 0 10 1 100 0
l l l l l l l l =FF H
Q. 40 The accumulator in 8085 Micro-processor contains th~ data 78H and register D
contains data 33H. What will be the content of accumulator after execution of each
of the following instructions independently. lt•HIDOd)
(i) SUB D · (ii) AND D (iii) CMA
Ans,:
Accumulator = A =78 H = 0111 1111
D = 33H = 0011 0011
(ii) SUB D (Subtract D from Accumulator)
is complement of D = 1100 1100
' + 1 + 1
= (] 01001100
Q.41 The accumulator in 8085 microprocfssor contains data 71H register E contains data
39H. What will be the contents of accumulator in Hexadecimal after execution of the
( l\ t.1rd1 2tl I :"I
following instructions independently ?
(i) ADD E (ii) ORA E (iii) RRC
Ans.: (i) AAH, (ii) 79H, (iii) B8H
the conten
Q. 42 Accumulator contai ns data A4H and Register E contains data 69H write
ing instructt ts
of Accum ulator in hex digits after execution of each of the follow
indep enden tly :
Ans.:
(i) ANA E = 20 H ·(ii) CMP E = A4H (iii) ORA = EDH
will be the
Q. 43 The· registers A and c of 8085 contains the cJata E2H and 47H. What
the following
conten ts of Accumulator in Hex digits after execution of each of
instru ctions indep enden tly?
IMfil@lfM!)
(i) SUB C (ii) XRA C (iii) ADD C
Ans.:
(i) SUB C = 9BH
(ii) XRA C = ASH
(iii) . ADD C = 29 H Cy = 1
will be the
Q. 44 Accumulator contain data 45H and register B contain data 82H. What
y.
result in Accumulator after execution of each instruction indepe ndentl
m XRA B <m ADI 54H (iii) NI sm aw"d
Ans.:
(i) XRA B Accumulator = 45H
regB = 82H
Ace = 45H = 0100 0101
B = 82H = 1000 001,0
1100 0111
B 7
XRAB = B7H
(ii) ADI 54H Ace= 45H = 0100 0101
54H = 54H = 0101 0100
-1001 1001
9 9
ADI54H = 99H
(iii) ANI 57H Ace = 45H = 0100 0101
57H = 57H = 0lDl 0111
0100 0101
4 5
ANI57H = 45H
(!\larch 2019)
Q. 46 Give any two instructions of followin g address ing modes :
(i) Immedi ate (ii) Register Indirect (iii) Registe r
Ans.:
(i) Immediate - ADI 05H I MVI B, 04H
(ii) Register Indirect - ADD M / MOV M, D
(iii) Register - MOV A, B / ADD C
(i) CMPC It's CMP means subtraction of A-C. But after subtrac tion Accumu lator content
remains unchang ed. Means after CMPC.
A= AAH
(ii) ANAC
A = AAH = 1010 1010
C = SSH = 0101 0101
logical AND operation = 0000 0000
.. ANAC = OOH Accumu lator Content