Microprocessor and Assembly Language Course Code: 343 ALL
Microprocessor and Assembly Language Course Code: 343 ALL
CHAPTER 2
Instruction Set of 8085
Lecture Notes
.
ﺟﺎء ﻣﺻطﻠﺢ ﻋﻠﯾﮫ ﻓﻲ اﻻﺧﺗﺑﺎر
MOV Rd, Rs
Rd destination register
Rs source register
This is a one byte instruction.
Example: MOV B , A
Before instruction execution, the contents of registers B and A are
Rd = B= XAH
Rs = A = 0FH
After the execution of instruction.
Rd = B = 0FH
Rs = A = 0FH
b. Move Immediate Instruction.
Example:
MVI B , F1H
Before the execution of instruction.
Rdr = B = XAH
After the execution of instruction, the 8 bit data F1H is loaded into the register
B.
Rdr = B = F1H
c. Move between Register and Memory.
2050H 99H
After execution
The content of the accumulator 56H is loaded into the memory location 2050H.
Memory Data
Address
2050H 56H
Problem
Write a sequence of instructions that will load FFH in C register and transfer
the byte to a memory location whose address is 2051H.
MVI H,20H
MVI L,51H
MVI C,0FFH
MOV M,C
HLT
This is a three byte instruction. A 16-bit data is loaded into register pair.
LXI H , 2050H
Before execution
H L
After execution
the 16 bit data or memory address ,2050H, is loaded into the HL pair.
H L
20H 50H
accumulator to data in address memory
STA addr
addr
memory address
STA 2550H
Before execution
A Mem.address Data
47H 2550H
After execution
The contents of the accumulator which is 47H is copied to the memory address,2550H.
A Mem.address Data
47H 2550H 47H
data in memory address to a accumulator
LDA addr
addr
memory address
Loads the accumulator with a byte from the memory location whose address
is specified in the instruction itself.
LDA 2450H
Before execution
Mem.address Data
A
2450H 67H
After execution
The contents of the memory location whose address is 2450H is copied to the
accumulator.
Mem.address Data
A
67H 2450H 67H
Problem:
Without using LXI command how you will transfer
one byte from memory location whose address is
2450H to another memory location whose address
is 2550H.
Solution:
https://electricalvoice.com/8085-microprocessor-mcqs/4/
It is used to add the contents of a specified register or memory to the contents of the
accumulator. (A) (A) + r.
Example: 1 ﯾﺣﻣﻊ اﻟﺑﻲ ﻋﻠﻰ اﻟﻘﯾﻣﮫ اﻟﻲ ﻓﯾﺎﻻﻛﻣﯾوﻟﯾﺗر وﯾﺧزن ﻗﯾﻣﺗﮭﺎ ﻓﻲ اﻻﻛﻣﯾﻠوﯾﺗر
ADD B
If A= E2H and B= 03H then after the execution of the above instruction the content of A
will be E5H.
Example: 2
ADD M ﯾﺟﻣﻊ اﻟﻘﯾﻣﮫ اﻟﻲ ﻓﻲ اﻟﻣﯾﻣوري ﻋﻠﻰ اﻟﻘﯾﻣﮫ اﻟﻲ ﻓﻲ اﻻﻛﻣﯾوﻟﯾﺗر وﯾﺧزن اﻟﻧﺎﺗﺞ ﻓﻲ اﻻﻛﻣﯾوﻟﯾﺗر
Before execution
A H L Mem.address Data
05H 20H 50H
2050H 07H
After execution
The data in the memory location 2050H i.e 07H is added to value in accumulator A
and result is stored in A.
A H L Mem.address Data
0CH 20H 50H
2050H 07H
ﺟﺎت ﻣﺳﺎﻟﮫ ﻋﻠﯾﮫ
b. ADD immediate.
ADI 8 bit data اﺿﯾف ﻗﯾﻣﮫ وﻟﯾﺳت ﻣﺳﺟل اﺟﻣﻊ اﻟﻘﯾﻣﮫ ﻣﻊ اﻟﻘﯾﻣﮫ اﻟﺗﻲ ﻓﻲ اﻻﻛﻣﯾوﻟﯾﺗر واﺧزن ﻓﻲ اﻻﻛﻣﯾوﻟﯾﺗر
It is used to add 8 bit data to the contents of the accumulator. (A) (A) + 8-bit data.
Example: 1
ADI 37H
If the value of A = 05H then after the execution of the above instruction the 8 bit data 37H
is added with the content of accumulator and the result 3CH is stored in the accumulator.
. 37h+05h=3ch
c. ADD with carry
It is used to add the contents of a specified register or memory along with the carry
flag to the contents of the accumulator.
If A= E2H and B= 03H and Carry flag = 1, then after the execution of the above
instruction the content of A will be E6H.
Example 2:
ADC M
Before the execution of instruction , if Carry flag = 1
A H L Memory Data
Address
05H 20H 50H 2050H 07H
After the execution of instruction, the data in the memory location 2050H i.e 07H
is added to value in accumulator A and carry 1 and result is stored in A.
05H + 07H + 1
A H L Memory Data
Address
0DH 20H 50H 2050H 07H
ﻋﻣﻠﯾﮫ اﻟطرح
It is used to subtract the contents of a specified register or memory from the contents of
the accumulator. (A) (A) - r.
A - REGISTER OR MEMORY
The result is stored in the accumulator.
Example: 1
SUB B
If A= 0CH and B= 03H , then after the execution of the above instruction the content of A
will be 09H.
Example: 2
SUB M
Before execution ,
A H L Mem.address Data
07H 20H 50H
2050H 03H
After execution
The data in the memory location 2050H i.e 07H and carry are subtracted from value
in accumulator A and result is stored in A.
A H L Mem.address Data
04H 20H 50H
2050H 03H
e. SUB immediate.
It is used to subtract 8 bit data from the contents of the accumulator. (A) (A) - 8-bit
data.
Example: 1
SUI 03H
If the value of A = 05H then after the execution of the above instruction the 8 bit data 03H
is subtracted from the content of accumulator and the result 02H is stored in the
accumulator.
.
اطرح واﺣد زﯾﺎده ﻣن اﻟﻘﯾم اﻟﻲ اﺑﻲ اطرﺣﮭﺎ
It is used to subtract 8 bit data from the contents of the accumulator. (A) (A) - 8-bit
data - carry.
If the value of A = 05H and carry =1, then after the execution of the above instruction the
8 bit data 03H is subtracted from the content of accumulator and the carry flag and the
result 01H is stored in the accumulator.
.
اﺟﻣﻊ ﻗﯾﻣﮫ ﻣوﺟوده ﺟوا رﺟﺳﺗرﯾن ﻣﻊ ﺑﻌض
It is used to add the contents of HL pair with the contents of register pair mentioned in
the instruction. (HL) (HL) + (register pair).
اﻟﺗﺧزﯾن ﻓﻲ الHL
Example: 1
DAD B
Adds the content of the HL register with the content of the BC register pair stores the
result in the HL register pair
HL HL+BC
Before execution After execution
H L B C H L B C
41H 01H 06H 02H 47H 03H 06H 02H
INCREMENT/ DECREMENT INSTRUCTIONS
h. Increment Register or Memory
INR r or INR M 1 ﯾﻌﻧﻲ ﻟو ﺳوﯾت اﻧﻛرﯾﻣﯾﻧت ﻋﻠﻰ اﻟرﯾﺟﺳﺗر راح ازﯾد ﻋﻠﯾﮫ
1 وﻟو ﺳوﯾت اﻧﻛرﯾﻣﯾﻧت ﻋﻠﻰ اﻟﻣﯾﻣوري راح ازﯾد ﻋﻠﯾﮫ
This instruction increments the contents of the specified register or memory location, M
by 1.
اﺧزن اﻟﻘﯾﻣﮫ ﻋﻠﻰ ﻧﻔس اﻟرﯾﺟﺳﺗر اﻟﻲ اﻧﺎ ﺳوﯾت ﻋﻠﯾﮫ اﻟﻌﻣﻠﯾﮫ
The result is stored in the specified register itself.
Example: 1
INR C اﻧﺎ ھﻧﺎ ﺳوﯾت اﻧﻛرﯾﻣﻧت ﻋﻠﻰ اﻟرﯾﺟﺳﺗر ﺳﻲ ﻋﺷﺎن ﻛذا زدت ﻋﻠﯾﮫ واﺣد وﺧزﻧت اﻟﻧﺗﯾﺟﮫ ﻓﻲ ﺳﻲ
Increments the content of C register by 1 and the new value is stored in C register.
Example: 2
INR M اﻧﺎ ھﻧﺎ ﺳوﯾت اﻧﻛرﯾﻣﻧت ﻟﻠﻣﯾﻣوري ﻋﺷﺎن ﻛذا اﻧﺎ زودت واﺣد ﻋﻠﻰ اﻟﻣﯾﻣوري واﻟﻘﯾﻣﮫ ﺧزﻧﺗﮭﺎ ﻓﻲ اﻟﻣﯾﻣوري
Increments the content of memory location specified by HL register by 1 and the value is
stored in that memory location itself.
اﻧﺎ ھﻧﺎ اطرح ﻣن اﻟرﯾﺟﺳﺗر او اﻟﻣﯾﻣوري واﺧزن اﻟﻘﯾﻣﮫ ﻓﻲ ﻧﻔس اﻟﺷﻲ اﻟﻲ اﻧﺎ ﺳوﯾت ﻋﻠﯾﮫ اﻟﻌﻣﻠﯾﮫ
ﻧﻔس اﻻﻧﻛرﯾﻣﻧت ﺑس اﻟﻔرق ﺑﯾﻧﮭم ان ھذا طرح وھذاك ﺟﻣﻊ
DCR r or DCR M
This instruction decrements the contents of the specified register or memory location, M
by 1.
Example: 1
DCR C
Decrements the content of C register by 1 and the new value is stored in C register.
Example: 2
DCR M
Decrements the content of memory location specified by HL register by 1 and the value is
stored in that memory location itself.
ازﯾد واﺣد ﻋﻠﻰ اﻟﻣﺳﺟﻼت اﻟزوﺟﯾﮫ واﺧزن اﻟﻘﯾﻣﮫ ﻓﻲ ﻧﻔس اﻟﻣﺳﺟﻼت
INX rp
The register pair used are BC, DE, HL and the 16-bit Stack Pointer.
Example: 1
INX H
If the initial value in HL register pair is 14FFH, then the instruction INX H increments the
16 bit value in HL register pair by 1 and the new value 1500H is stored in HL.
HL = 14FFH + 1 = 1500H
HL= 1500H
K. Decrement Register pair
DCX rp
The register pair used are BC, DE, HL and the 16-bit Stack Pointer.
Example: 1
DCX D
If the initial value in DE register pair is 1500H, then the instruction DCX D decrements 16
bit value in DE register pair by 1 and the new value is stored in DE.
ﻣن اﻟﻣﺳﺟﻼت1 اطرح
3. LOGIC INSTRUCTIONS.
ANA r
This instruction performs logical AND operation between the specified register, r and the
accumulator.
The result is stored in the accumulator. ﯾﺷوف اﻟﻘﯾﻣﮫ اﻟﻲ ﻓﻲ اﻻﻛﻣﯾوﻟﯾﺗر وﯾﺳوي ﻟﮭﺎ اﻧدﯾﻧﻖ ﻣﻊ اﻟﺑﻲ
This instruction performs logical AND operation between the accumulator and the 8 bit
data given in the instruction itself.
Example: 1
ANI 0FH
ORA r
This instruction performs logical OR operation between the accumulator and the register
content given in the instruction itself .
Example: 1
ORA B
ﻋﺳل او ﺳم
If A = 97H = 1001 0111
And if B = C5H = 1100 0101
This instruction performs logical OR operation between the accumulator and the 8-bit
data given in the instruction itself .
Example: 1
ORI 0FH
If A = 97H = 1001 0111
And if 8 bit data = 0FH = 0000 1111
.
0 ,, ﻟو اﻻﺛﻧﯾن ﻣﺗﺷﺎﺑﮭﯾن ﯾﻛون
c. EX-OR Instruction 1,, ﻟوو اﻻﺛﻧﯾن ﻣﺧﺗﻠﻔﯾن ﯾطﻠﻊ
XRA r
This instruction performs EX-OR operation between the contents of the accumulator and
the specified register on a bit by bit basis.
The XRA clears the accumulator. With this single instruction, we can clear accumulator,
Carry flag and Auxiliary Carry flag.
Example: 1
XRA B
If A = 97H = 1001 0111 and if B = C5H = 1100 0101
Example 2:
XRA A
If A = 97H = 1001 0111 and again A = 97H = 1001 0111
This instruction performs logical EX-OR operation between the accumulator and the 8-bit
data given in the instruction itself .
Example: 1
XRI 0FH
If A = 97H = 1001 0111
and if 8 bit data = 0FH = 0000 1111
.
ﺟﺎت ﻣﺳﺎﻟﮫ ﻋﻠﯾﮫ ﻓﻲ اﻻﺧﺗﺑﺎر
ﻣﻛﻣل
d. Complement Instruction
واﻟﻌﻛس0 ﯾﺧﻠﯾﮭﺎ1 ﺗﺑدﯾل ﻟو اﻟﻘﯾﻣﮫ ب
CMA
Example: 1
CMA ﺣول ﻛل واﺣد ﻟﺿده
If A = 97H = 1001 0111
CMC none اﻧﺎ اﺑﻲ اﺳوي ﻋﻣﻠﯾﮫ اﻟﺗﺣوﯾل ﻟﻠﻛﺎري اﻟﻲ ﺟوا اﻟﻔﻼق
ﻣﺛﺎل الCARRY=1
This instruction complements the content of carry flag. اﻟﺣل
CARRY = 0
STC none
This instruction sets carry flag to 1.
ﺟﺎء ﻣﺻطﻠﺢ
ﻓﻲ اﻻﺧﺗﺑﺎر
ﻣﻘﺎراﻧﮫ
e. Compare Instruction
CMP register
This instruction compares the content of the accumulator with the value in register given in
instruction.
Example
CMP B
SET 1
If (B) > (A) , then Carry flag is set اذا ﻛﺎن اﻟﺑﻲ اﻛﺑر ﻣن ال اﻻي اذا اﻟﻛﺎري ﻓﻼق ﺑواﺣد
If (B) = (A) , then Zero flag is set 0 = اذا اﻟﺑﻲ واﻻي ﻣﺗﺳﺎوﯾن اذا اﻟﻛﺎري ﻓﻼق RESET 0
If (A) > (B) , then No flag is set اذا ﻛﺎن اﻻي اﻛﺑر ﻣن اﻟﺑﻲ اذا اﻟﻛﺎري ﻓﻼق ﻣﺎراح ﯾﺻﯾر ﻟﮫ اي ﺷﻲ
f. Rotate Instruction
RRC اﻟﻘﯾﻣﮫ
Each binary bit of the accumulator is rotated right by one position. Bit D0 is placed in the
position of D7 as well as in the Carry flag. CY is modified according to bit D0. S, Z, P,
AC are not affected.
RLC
Each binary bit of the accumulator is rotated left by one position. Bit D7 is placed in the
position of D0 as well as in the Carry flag. CY is modified according to bit D7. S, Z, P,
AC are not affected.
f. Rotate Instruction
RAL
Each binary bit of the accumulator is rotated left by one position through the Carry
flag. Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least
significant position D0. CY is modified according to bit D7. S, Z, P, AC are not
affected.
RAR
Each binary bit of the accumulator is rotated right by one position through the
Carry flag. Bit D0 is placed in the Carry flag, and the Carry flag is placed in the
most significant position D7. CY is modified according to bit D0. S, Z, P, AC
are not affected.
اﺑﻲ اروح ﻣن ﻣﻛﺎن ﻣﻌﯾن ﻓﻲ اﻟذاﻛره ﻟﻣﻛﺎن ﺛﺎﻧﻲ
3. BRANCH INSTRUCTIONS.
Branch Instructions are used to transfer the sequence of instructions from one
memory location to another.
a. Jump unconditionally
b. Jump conditionally
BRANCH INSTRUCTIONS
Jump unconditionally
JMP 16-bit address
The program sequence is transferred to the memory location specified by the 16-bit
address given in the operand.
Example: JMP 2034H.
NB: In 8085 JMP unconditionally ins. is used to do the function of GOTO
The program sequence is transferred to the memory location specified by the 16-bit
address given in the operand based on the specified flag of the PSW as described below.
Opcode Description Flag Status
JC ﺟس Jump on Carry CY = 1
JNC اﻟﺟﻧس Jump on no Carry CY = 0
JP ﺟب Jump on positive S=0
JM اﻟﺟم Jump on minus S=1
JZ ﺟز Jump on zero Z=1
JNZ اﻟﺟﻧز Jump on no zero Z=0
JPE ﺟﯾﺑﻲ Jump on parity even P=1
JPO ﺟﯾﺑو Jump on parity odd P=0
Example 1: Write a program to add two bytes and store the result in memory
location 2050H. Also store the carry as 1 if there is a carry, in the next memory
location. If there is no carry, store a 0 in the next location.
Answer
• MVI C,00
• MVI A,05
• MVI B,04
• ADD B
• JNC AHEAD
• INR C
• AHEAD: STA 2050
• MOV A,C
• STA 2051
• HLT
Machine control instructions
• HLT
• Stop executing the program.
• NOP
• No operation
• Exactly as it says, do nothing.
• Usually used for delay or to replace instructions during debugging
ﺟﺎء ﻓﺎﻻﺧﺗﺑﺎر ﻋﻠﻰ ﺷﻛل اذﻛري ﻧوع ھذي اﻻﻧﺳﺗرﻛﺷن وﻋطﺗﻧﺎ اﻧﺳﺗرﻛﺷن وﻗﺎﻟت اذﻛري ﻧوﻋﮭﺎ
Addressing Modes
Immediate Addressing
Direct Addressing
Register Addressing
Register Indirect Addressing
Implied Addressing
Immediate Addressing:
In immediate addressing mode, the data is specified in the instruction itself. The data
will be a part of the program instruction.
EXAMPLE:
MVI B, 3EH - Move the data 3EH given in the instruction to B register;
Direct Addressing:
In direct addressing mode, the address of the data is specified in the instruction. The
data will be in memory. In this addressing mode, the program instructions and data
can be stored in different memory.
EXAMPLE.
LDA 1050H - Load the data available in memory location 1050H in to accumulator;
Register Addressing:
In register addressing mode, the instruction specifies the name of the register in which
the data is available.
EXAMPLE.
MOV A, B - Move the content of B register to A register;
EXAMPLE.
MOV A, M - The memory data addressed by H L pair is moved to A register.
Implied Addressing:
In implied addressing mode, the instruction itself specifies the data to be operated.
EXAMPLE.
CMA - Complement the content of accumulator