Instruction Set & Programming of 8085
Instruction Set & Programming of 8085
2) * Instruction : LXI
* LXI : Load immediate 8-bit data from memory location to register pair
* Size : Three byte instruction.
* X : Register Pair
* Syntax : LXI Reg pair , Memory location [ Reg Pair Memory Location ]
* Examples : (i) LXI H , C050H [ HL C050H ]
Meaning : The content of C050H is loaded in HL register pair
(ii) LXI B , D090H [ BC D090H ]
(iii) LXI D , C050H [ DE F070H ]
2) * Instruction : STA
* STA : Store 8-bit data in memory location from accumulator.
* Size : Three byte instruction.
* Syntax : STA Memory location [ A → Memory Location ]
* Examples : (i) STA C030H [ A → C030H ]
Meaning : Store 8-bit data in C030H from accumulator.
(ii) STA D090H [ A → D090H ]
3) * Instruction : LHLD
* LHLD : Load registers L and H with 16-bit data from memory locations respectively.
* Size : Three byte instruction.
* Syntax : LHLD Memory location [ L Memory Location ]
[ H Memory Location + 1 ]
* Examples : (i) LHLD C075H [ L C075H ]
[ H C076H ]
Meaning : Load registers L and H with 16 bit data from C075H & C076H
respectively.
(ii) LHLD C090H [ L C090H ]
[ H C091H ]
4) * Instruction : SHLD
* SHLD : Store 16-bit data in memory locations from registers L and H respectively.
* Size : Three byte instruction.
* Syntax : SHLD Memory location [ L → Memory Location ]
[ H → Memory Location + 1 ]
* Examples : (i) SHLD C040H [ L → C040H ]
[ H → C041H ]
Meaning : Store 16-bit data in C040H and C041H from registers L & H respectively.
(ii) SHLD C035H [ L → C035H ]
[ H → C036H ]
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
2) * Instruction : MVI
* MVI : Move immediate 8-bit data into register.
* Size : Two byte instruction.
* Syntax : MVI Reg , 8-bit data [ Reg 8-bit data ]
* M = HL register pair
* Examples : (i) MVI M , 29H [ HL 29H ] (i.e. HL = 29H)
Meaning : An 8-bit data 29H is loaded in register pair HL.
(ii) MVI M , F3H [ HL F3H ] (i.e. HL = F3H)
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
1) Data transfer group : (i) In this group, instructions are used to transfer data between ,
Register to Register , Register to memory location & Memory location to
register
(ii) Examples : MOV A , B , LXI H , C050H
STA C040H , XCHG etc….
2) Arithmetic group : (i) In this group, instructions are used to perform arithmetic operations such as,
Addition, Subtraction, Increment and Decrement.
(ii) Examples : ADD B , SUB C , INX H , DCR C etc…
3) Logical group : (i) In this group, Instructions are used to perform logical operations such as,
AND, OR, EX-OR, complement, compare & rotation
(ii) Examples : ANA B , ORI D , XRA M , CMA ,
CMP E , RRC etc…
4) Branching group : (i) In this group, Instructions are used to provide conditional statements and it is
also used to create loop system in 8085 program.
(ii) Examples : JC C005H , JNZ C037H
JPO D009H , JMP F003H etc…
5) Machine control group : (i) In this group, Instructions are used to provide control and maintenance
on execution of program such as , read / write stack, input/output ports
and interrupts etc.
(ii) Examples : PUSH , POP PSW , NOP , RIM
SIM , HLT , RST 1 etc…
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
MOV A , B A B
MOV C , A C A
Examples MOV D , E D E
MOV M , A HL A
MOV A , M A HL
L Memory location
8. Syntax LHLD Memory location
H Memory location +1
L C095H
LHLD C095H
H C096H
Examples
L C050H
LHLD C050H
H C051H
L → C060H
SHLD C060H
H → C061H
Examples
L → C020H
SHLD C020H
H → C021H
Exchange data
10. Syntax XCHG
between HL & DE pair
Example XCHG
HL → DE
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Arithmetic group :
ADDITION
ADD B A + B = A
Examples ADD E A + E = A
ADD M A + HL = A
3. ADC Reg
Syntax A + Reg + carry = A
ADC E A + E + carry = A
Examples
ADC M A + HL + carry = A
SUBTRACTION
SUB C A - C = A
Examples SUB A A - A = A
SUB M A - HL = A
3. SBB Reg
Syntax A + Reg + carry = A
SBB D A - D - borrow = A
Examples
SBB M A - HL + borrow = A
INCREMENT
INR A A = A + 1
Examples INR D D = D + 1
INR M HL = HL + 1
INX H HL = HL + 1
Examples INX B BC = BC + 1
INX D DE = DE + 1
DECREMENT
DCR A A = A - 1
Examples DCR C C = C - 1
DCR M HL = HL - 1
DCX H HL = HL - 1
Examples DCX B BC = BC - 1
DCX D DE = DE - 1
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Output:
A+B=A
Before execution:
Reg B = 02H
Reg B = 02H Store result from A to E
After Execution:
Reg B = 02H Stop
Program :
Mnemonics ; Comments
Output:
A+B=A
Before Execution:
C030H = 03H
C040H = 06H Store result from A to C050H
After Execution:
C050H = 09H Stop
Program :
Mnemonics ; Comments
RST 1 ; Reset
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Ans : Logic :
Extra Information :
HL C045H
A HL LXI H , C045H [ HL C045H ]
Increment HL pair i.e. HL = C045H
C HL if → Increment HL pair
A+C=A HL = HL + 1
A → C050H HL = C045H + 1
Stop then → HL = C046H
Program :
Mnemonics ; Comments
RST 1 ; Reset
Output:
Before Execution:
C045H = 03H
C046H = 04H
After Execution:
C050H = 07H
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Q.] Write a program to perform subtraction between two memory locations starting
from C070H. Store the result in memory location C090H .
(Note : make logic , flowchart , program and output )
Q.] Explain one byte, two byte and three byte instruction formats with suitable
examples.
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Output:
Before Execution: After Execution:
C035H = 03H C050H = 07H
C036H = 04H
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Branching Group :
If
Yes
Carry = 1
No
2) * Instruction : JNC
* JNC : Jump if no carry
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JNC Memory Location
* Examples : JNC C006H , JNC C009H etc…
* Flowchart symbol :
If
No
Carry = 1
Yes
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
3) * Instruction : JZ
* JZ : Jump if zero
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JZ Memory Location
* Examples : JZ C004H , JZ C007H etc…
* Flowchart symbol :
If
Yes
result = 0
No
4) * Instruction : JNZ
* JNZ : Jump if no zero
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JNZ Memory Location
* Examples : JNZ C003H , JNZ C004H etc…
* Flowchart symbol :
No
If
result = 0
Yes
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
5) * Instruction : JP
* JP : Jump if plus (positive)
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JP Memory Location
* Examples : JP C004H , JP C009H etc…
* Flowchart symbol :
Yes
If
result = +ve
No
5) * Instruction : JM
* JM : Jump if minus (negative)
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JM Memory Location
* Examples : JM C003H , JM C002H etc…
* Flowchart symbol :
Yes
If
result = -ve
No
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
5) * Instruction : JPE
* JPE : Jump if even parity
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JPE Memory Location
* Examples : JPE C006H , JPE C004H etc…
* Flowchart symbol :
Yes
If
Even parity
No
5) * Instruction : JPO
* JPO : Jump if odd parity
* Size : Three byte instruction
* Addressing mode : Direct addressing mode
* Syntax : JPO Memory Location
* Examples : JPO C005H , JPO C004H etc…
* Flowchart symbol :
Yes
If
Odd parity
No
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
A D C00F C0
C010 MOV A,D 7A ; Move data from reg D to A
A → C071H
C011 STA C070H 32 ; Store result from A to C071
Stop C012 70
C013 C0
C014 RST 1 CF ; Restart
Output :
Before execution After Execution
C050H = 05H C070H = 07H
C050H = 02H C071H = 00H
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Example: A = 45H
ANI 24 H [ A ^ 24H = A]
A = 45H = 0 1 0 0 0 1 0 1
8-bit data = 24H = 0 0 1 0 0 1 0 0
-----------------------------------------------------
A = 04H = 0 0 0 1 0 1 0 0
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Example: A = 45H
ORI A7 H [ A v A7H = A]
A = 45H = 0 1 0 0 0 1 0 1
8-bit data = A7H = 1 0 1 0 0 1 1 1
-----------------------------------------------------
A = E7H = 1 1 1 0 0 1 1 1
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
Example: A = 45H
XRI 57 H [ A ¥ 57H = A]
A = 45H = 0 1 0 0 0 1 0 1
8-bit data = 57H = 0 1 0 1 0 1 1 1
-----------------------------------------------------
A = 12H = 0 0 0 1 0 0 1 0
RAVI GROUP TUITION
Subject : computer science
Std : 12th
Section : Paper – II (Hardware) :- Theory(50M)
5) Compare :
RRC
A = A2H = 1 0 1 0 0 0 1 0
------------------------------------------------------------------------------------------------------------------------------------
(ii) RLC
A = 45H = 0 1 0 0 0 1 0 1
RLC
A = 8AH = 1 0 0 0 1 0 1 0
------------------------------------------------------------------------------------------------------------------------------------
(iii) RAR
A = 45H = 0 0 1 0 0 0 1 0 1
RAR
RAR