Instructions Set of 8085: Computer Science (D9) XII - Paper - II
Instructions Set of 8085: Computer Science (D9) XII - Paper - II
Page 10
Computer Science ( D9) XII - Paper –II
1001 Two memory locations for two MVI A, 39H 3E 2 Load registers A with hex
no. 39
bytes
bytes
1002 instructions
39
STA 2000 Store the content of A
32
registers to Memory
1003 location 2000
1006
1007
DATA TRANSFER (COPY) OPERATIONS: The data transfer (copy) instructions copies
data from source into a destination without modifying the contents of the source. The
previous contents of the destination are replaced by the contents of the source. No flags are
affected in data transfer instructions.
Page 11
Computer Science ( D9) XII - Paper –II
Where Rd: Register destination may be any 8-bit registers (A, B, C, D, E, H and L)
Rs: Register source may be any 8-bit registers (A, B, C, D, E, H and L)
Description: Copies data from source register (Rs) into destination register (Rd).
Addressing Mode: Registers Addressing Mode (because data is transfer between Register to Register)
(Rd Rs)
A F A 23 F
Bytes: One Byte B 23 B 23
C C
Example: MOV A, B
D E D E
H L H L
Before After
Combinations: 49 instructions
MOV A, A MOV B, A MOV C, A MOV D, A MOV E, A MOV H, A MOV L, A
MOV A, B MOV B, B MOV C, B MOV D, B MOV E, B MOV H, B MOV L, B
MOV A, C MOV B, C MOV C, C MOV D, C MOV E, C MOV H, C MOV L, C
MOV A, D MOV B, D MOV C, D MOV D, D MOV E, D MOV H, D MOV L, D
MOV A, E MOV B, E MOV C, E MOV D, E MOV E, E MOV H, E MOV L, E
MOV A, H MOV B, H MOV C, H MOV D, H MOV E, H MOV H, H MOV L, H
MOV A, L MOV B, L MOV C, L MOV D, L MOV E, L MOV H, L MOV L, L
Combinations: 7 instructions
MOV A ,M ; MOV B ,M ; MOV C ,M ; MOV D ,M ; MOV E ,M ; MOV H ,M ; MOV L ,M
; Example : MOV M, A
Page 12
Computer Science ( D9) XII - Paper –II
Combinations: 7 instructions
MOV M ,A ; MOV M ,B ; MOV M ,C ; MOV M ,D ; MOV M ,E ; MOV M ,H ; MOV M ,L ;
Page 13
Computer Science ( D9) XII - Paper –II
Combinations: 4 Instructions
LXI B,16-bit; LXI D,16-bit; LXI H,16-bit; LXI SP,16-bit;
Page 14
Computer Science ( D9) XII - Paper –II
Binary Chart
23
2
2
2 1
20
Number
Octal / Decimal
8 4 2 1
/ Hexadecimal
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3 0-7 Octal Numbers
0 1 0 0 4
0 1 0 1 5 0-9 Decimal Numbers
0 1 1 0 6 0-F Hexadecimal Numbers
0 1 1 1 7
0 & 1 Binary Numbers
1 0 0 0 8
1 0 0 1 9
1 0 1 0 A 10
1 0 1 1 B 11
1 1 0 0 C 12
1 1 0 1 D 13
1 1 1 0 E 14
1 1 1 1 F 15
ADDITION: The 8085 performs addition with 8-bit binary number and stores the sum in the
accumulator. Addition can be performed either by adding the contents of a source register (A,
B, C, D, E, H and L or memory) to the content of the accumulator.
Where ADD: ADDition, this instruction has only one operand and other operand implicitly
considered source as Accumulator. R: may be any 8-bit registers (A, B, C, D, E, H and L).
M: Memory, whose address always present only in HL registers pairs
Description: The contents of the operand (register or memory) are added to the contents of
the accumulator and the result is stored in the accumulator. If the operand is a memory
location, that is indicated by the 16-bit address in the HL register.
Addressing Mode: Register for ADD R and Indirect for ADD M.
(A R / M)
A 99 F
B ED
Bytes: ONE Byte C
D E
Flags: All flags are modifying.
H L
Example: ADD B Before
Combinations: 8 Instructions
ADD A; ADD B; ADD C; ADD D; ADD E; ADD H; ADD L and ADD M.
Page 15
Computer Science ( D9) XII - Paper –II
Example:
FLAGS REGISTER:
1 0 1 0 1
H L
Example : ADI EDH
Before Addition
A 86 1 0 1 01 F
B C
D E
H L
After Addition
Combinations: One Instruction
Page 16
Computer Science ( D9) XII - Paper –II
Where SUB: SUBtraction, this instruction has only one operand and other operand implicitly
considered source as Accumulator. R: may be any 8-bit registers (A, B, C, D, E, H and L).
M: Memory, whose address always present only in HL registers pairs
Description: The contents of the operand (register or memory) are subtracted to the contents
of the accumulator and the result is stored in the accumulator. If the operand is a memory
location, that is indicated by the 16-bit address in the HL register.
H L
Example : SUB B
Before
Combinations: 8 Instructions
SUB A; SUB B; SUB C; SUB D; SUB E; SUB H; SUB L and SUB M.
Example: A :1 0 0 1 1 0 0 1
B :1 1 1 0 1 1 0 1
carry 0 1 0 1 0 1 1 0 0
Result AC
Sign
Page 17
Computer Science ( D9) XII - Paper –II
FLAGS REGISTER:
1 0 0 1 0
Example: SUB M
Where ADI: SUbtraction Immediate, this instruction has only one operand and other operand
implicitly considered source as Accumulator. 8-bit data: subtract any data immediate to
accumulator.
Description: The 8-bit data (in operand) are subtracted to the contents of the accumulator,
and the result in placed in the accumulator.
Addressing Mode: Immediate
(A 8-bit data)
D E
H L
A AC 1 0 010 F
B C
D E
H L
Page 18
Computer Science ( D9) XII - Paper –II
Description: The contents of the designated register or memory are incremented by 1 and the
results are stored in the same register or memory. If the operand is a memory location, that is
indicated by the 16-bit address in the HL register pair.
Addressing Mode: Register For INR R; Register Indirect For INR M
(R /M Inc by 1)
Flags: S, Z, P, AC are modified to reflect the result of the operation. CY is not modified.
Example : INR A
A: 1 0 0 1 1 0 0 0
1
1 0 0 1 1 0 0 1
A 98 F A 99 1 0 0 1 0 F
B C B C
D E D E
H L L
H
Before Addition After Addition
Example: INR M
12) Syntax: INX Rp
Where Rp: Registers Pairs may be any 16-bit registers pairs (BC, DE, HL and SP)
BC denotes by B, DE denotes by D, HL denotes by H and SP denotes by SP.
Description: The contents of the specified register pair are incremented by 1 and the results
are stored in the same register pair.
Addressing Mode: Register
(Rp Inc by 1)
Bytes: One Byte
Flags: S, Z, P , AC flags are affected but CY flag is not modified.
Example: INX D
Binary Numbers Hexa
A: 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2000
1 1
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 2001
Page 19
Computer Science ( D9) XII - Paper –II
Where DCR: Decrement; R: may be any 8-bit registers (A, B, C, D, E, H and L).
M: Memory, whose address always present only in HL registers pairs
Description: The contents of the designated register or memory are decremented by 1 and
the results are stored in the same registers or memory. If the operand is a memory location,
that is indicated by the 16-bit address in the HL register.
Addressing Mode: Register For DCR R; Register Indirect For DCR M
(R /M Dec by 1)
Bytes: One Byte
Flags: S,Z,P, AC are modified to reflect the result of the operation. CY is not modified.
Combinations: DCR A, DCR B, DCR C, DCR D, DCR E, DCR H, DCR L
Description: The contents of the specified register pair are decremented by 1 and the results
are stored in the same register pair.
Addressing Mode: Register
(Rp Dec by 1)
Bytes: One Byte
Flags: No flags are affected Combinations: DCX B, DCX D, DCX H, DCX SP
Solve: 1) Write a program to perform the following functions, and verify the output.
a) Load the number 8BH in register D. b) Load the number 6FH registers C.
c) Increment the content of registers C by one. d) Add the contents of registers C
and D and display the sum at memory location 1003H.
2) Write a program to perform the following: a) Load the number 30H in register B and
39H in Registers C. b) Subtract 39H from 30H. c) Display the sum at memory
location 1003H.
3) Write ALP to perform addition two Hexadecimal stores at the memory location
1000H and 1001H. Store the sum at the memory location 1003H.
4) Write ALP to perform Subtraction two Hexadecimal stores at the memory location
1000H and 1001H. Store the sum at the memory location 1003H.
Page 20
Computer Science ( D9) XII - Paper –II
LOGIC FUNCTIONS:
15) Syntax: ANA R or ANA M
Where ADD: ANded Accumulator, this instruction has only one operand and other operand
implicitly considered source as Accumulator. R: may be any 8-bit registers (A, B, C, D, E,
H and L). M: Memory, whose address always present only in HL registers pairs
Description: The contents of the operand (registers or memory) are ANDed to the contents
of the accumulator and the result is stored in the accumulator. If the operand is a memory
location, that is indicated by the 16-bit address in the HL register.
Addressing Mode: Register for ANA R and Register Indirect for ANA M
(A R / M) A 99 F
B ED
C
D E
H L
Bytes: ONE Byte Before
Example : ANA B A 89 1 0 0 0 0 F
B ED
C
D E
D7 D6 D5 D4 D3 D2 D1 D0
H L
A 1 0 0 1 1 0 0 1
B 1 1 1 0 1 1 0 1 After
carry 0 1 0 0 0 1 0 0 1
Result
Sign
Combinations: 8 Instructions
ANA A; ANA B; ANA C; ANA D; ANA E; ANA H; ANA L and ANA M.
Page 21
Computer Science ( D9) XII - Paper –II
A 89 1 0 000 F
B C
D E
H L
After Addition
17) Syntax
ORA E , ORA H, 0 0 0
0 1 1
ORA L
1 0 1
1 1 1
Reset the
CY , Z, P,
2 Indirect One
ORA M and S are
modify.
Reset the
CY , Z, P,
3 ORI 8-bit data Immediate Two
and S are
modify.
XRA A , XRA B , Reset the
4 Register One CY , Z, P,
Page 22
Computer Science ( D9) XII - Paper –II
XRA E , XRA H, 0 0 0
0 1 1
XRA L 1 0 1
1 1 0
Reset the
CY
5 Indirect One , Z, P, and
XRA M
S are
modify.
Reset the
CY , Z, P,
6 XRI 8-bit data Immediate Two
and S are
modify.
No flags Input A Output Y
are 0 1
affected 1 0
7 CMA Implied One
ROTATE OPERATIONS: This group has four instructions; two are for rotating left and
two are rotating right.
I. Assume implicitly that the accumulator is one of the operand (destination
register).
II. Modify the CY flag according the D7 and D0.
III. Place the result in the accumulator.
Where RLC: This instruction has only one operand considered as Accumulator.
Description: The contents of accumulator shifted each bit to the adjacent left position i.e. Bit
D7 goes to D0 and Carry Flag.
Page 23
Computer Science ( D9) XII - Paper –II
Accumulator (A) : B1
Where RAL: This instruction has only one operand considered as Accumulator.
Description: The contents of accumulator shifted each bit to the adjacent left position i.e.
Bit D7 goes to D0 and Carry Flag.
Page 24
Computer Science ( D9) XII - Paper –II
Accumulator (A) : D8
Accumulator (A) : B0
Page 25
Computer Science ( D9) XII - Paper –II
COMPARE OPERATIONS:
22) Syntax: CMP R or CMP M
Where CMP: CoMPare; R: may be any 8-bit registers (A, B, C, D, E, H and L).
M: Memory, whose address always present only in HL registers pairs
Description: The microprocessor compares a data byte (or Registers / Memory contents)
with the contents of the accumulator by subtracting the data byte from (A) and indicates
whether the data byte us >, < ,= with (A) by modifying the flags. However, the contents are
not modified. The 8085 instruction set has two types of Compare operations CMP and CPI.
CMP R/M : Compare (register / memory ) with Accumulator)
CPI 8-bit data : Compare 8-bit data immediate with content of the accumulator.
Addressing Mode: Immediate
Bytes: One Byte
Flags: Specially Carry and Zero flags are affected.
If (A) < (R/M/ 8-bit data) , The CY flag is Set and Zero flag is Reset.
If (A) = (R/M/ 8-bit data) , The Zero flag is Set and Carry flag is Reset.
If (A) > (R/M/ 8-bit data) , The CY flag and Zero flag are Reset.
BRANCHING OPERATIONS: The branch instructions are the most powerful instructions
because they allow the microprocessor to change the sequence of a program, either
conditionally or under certain conditions. The programming technique used to instruct the
microprocessor to repeat tasks is called Looping. Loops can be classified into two groups: a)
Continuous loop means repeat a task continuously unconditionally. b) Conditional loop
means repeats a task until certain data conditions are met i.e. conditionally.
The branch instructions are classified in four categories.
1) Jump Instructions.
2) Call instruction
3) Return instructions.
4) Restart instructions.
JUMP INSTRUCTION
1) Immediate Addressing Mode. 2) Three Bytes.
UNCONDITIONALLY JUMP CONDITIONALLY JUMP
Doesn’t depend on Flags Check the Flag and Make decision to jump or not to jump
register S Z P CY
Page 26
Computer Science ( D9) XII - Paper –II
RETURN INSTRUCTION
1) Implied Addressing Mode. 2) One Byte.
CONDITIONALLY RETURN
UNCONDITIONALLY RETURN Check the Flag and Make decision to return or not to return
Doesn’t depend on Flags S Z P CY
register
Page 27
Computer Science ( D9) XII - Paper –II
RESTART INSTRUCTION
1) Implied Addressing Mode. 2) One Byte.
RST instructions are one byte Call instruction that transfer the program execution to specific
location on page 00H. They are executed the same way as Call instruction.
RST 0 CALL 0000H
RST 1 CALL 0008H
RST 2 CALL 0010H
RST 3 CALL 0018H
RST 4 CALL 0020H
RST 5 CALL 0028H
RST 6 CALL 0030H
RST 7 CALL 0000H
MACHINE CONTROL OPERATIONS: The machine instructions are the most powerful
instructions because they allow the microprocessor to controls of machine such as stop
program, stop processing and wait etc.
The STACK in an 8085 microprocessor system can be described as a set of memory locations
in the R/W memory, specified by a programmer in a main program. These memory locations
are used to store binary information (bytes) temporarily during the execution of a program.
Page 28
Computer Science ( D9) XII - Paper –II
The interrupt process allows the microprocessor to respond to these external requests for
attention or service on demand basis and leaves the microprocessor free to perform other
tasks. The interrupt requests are classified in two categories a) Maskable interrupt and b)
Non-Maskable interrupt.
1) Two Decimal numbers are store at memory locations XX00H and XX01H. Write
ALP to perform the addition two numbers.
2) Sixteen bytes of data are stored in memory locations at XX50 to XX5FH. Write ALP
to transfer the entire the block of data to new memory locations starting at XX70H.
Data: 37, A2, F2, 82, 57, 5A, 7F, DA, E5, 8B, A7, C2, B8, 10, 19, 98.
3) Six bytes of data are stored in memory locations at XX50 to XX5AH. Write ALP to
transfer the data to the memory locations starting at XX80H to XX85H in the reverse
order. (e.g. the data 22H should be stored at XX85H and 37H at XX80H.
Data: 22, A5, B2, 99, 7F, 37
4) Write a program to add the following five data bytes stored in memory locations
starting at XX60H and display the sum. (The Sum does not generate a carry.) Use
register pair DE as a memory pointer to transfer a byte from memory into a register.
Data:1A, 32, 4F, 12, 27.
5) Six bytes of data are stored in memory locations starting at XX50H. Write ALP to add
all the data bytes. Use register B to save any carries generated while adding data
bytes. Store the sum at two consecutive memory locations XX70H and XX71H.
Data: A2, FA, DF, E5, 98, 8B.
6) A set of ten reading are stored in memory locations starting at XX50H. Write ALP to
check each reading, reject all negative readings and add all positive readings. Use
register B to save any carries generated while adding data bytes. Store the sum at two
consecutive memory locations XX70H and XX71H.
Data: 28, D8, C2, 21, 24, 30, 2F, 19, F2, 9F
7) A set of ten numbers are stored in memory locations starting at XX50H. Write ALP to
check each reading, reject all odd numbers and add all even numbers. Use register
B to save any carries generated while adding data bytes. Store the sum at two
consecutive memory locations XX70H and XX71H.
Data: 28, D8, C2, 21, 24, 30, 2F, 19, F2, 9F
8) A set of readings are stored in memory locations starting at XX50H. The end of the
data strings is indicated by the data bytes 00H. Write ALP to add the set of readings.
Use register B to save any carries generated while adding data bytes. Store the sum at
two consecutive memory locations XX70H and XX71H.
Data: 32, 52, F2, A5, 00
9) Two hexadecimal numbers are store at memory locations XX00H and XX01H. Write
ALP to find the greater of two numbers.
10) Two hexadecimal numbers are store at memory locations XX00H and XX01H. Write
ALP to multiplication of two numbers.
11) Two hexadecimal numbers are store at memory locations XX00H and XX01H. Write
ALP to find the division of two numbers.
12) A set of eight readings are stored in memory locations starting at XX50H. Write ALP
to search whether a byte 40H exists in the set. If it does, stop checking and display its
Page 29
Computer Science ( D9) XII - Paper –II
16) Write an ALP to generate the Fibbonacci series for first eight numbers. Store the
series in a memory block starting from C000H. ( 00 01 01 02 03 05 08 0D)
17) Write an ALP to separate two nibbles of an 8-bit number stored in memory locations
1500H. Add these two nibbles and store the sum in memory at BABAH.
18) Write an ALP to find the largest number in a series. The length of the series is stored
at 2500H and the numbers are stored from 2501H. Store the result at 2400H.
19) A hexadecimal number is stored at location C000H. Write an ALP to interchange its
digits. The new number is to be stored at C001H. Add original number with new
number and store the result at location C002H.
20) Write an ALP to separate two nibbles of an 8-bit number stored in memory locations
1500H. Multiply these two nibbles and store the result in memory.
A: 7E 0 1 1 1 1 1 1 0
Page 30
Computer Science ( D9) XII - Paper –II
S Z AC P CY
0 0 0 1 0
H L
Before Addition with carry
Example: ADC B A 87 1 0 1 1 1 F
B ED
D7 D6 D5 D4 D3 D2 D1 D0 C
Carry 1 1 1 1 1 D E
A:1 0 0 1 1 0 0 1
B :1 1 1 0 1 1 0 1 H L
Previous Carry : 0 0 0 0 0 0 0 1 After Addition with carry
carry 1 1 0 0 0 0 1 1 1
Result 87
Sign
FLAGS REGISTER:
1 0 1 1 1
Combinations:
ADC; ADC B; ADC C; ADC D; ADC E; ADC H; ADC L and ADC M.
2) Syntax: CMC
Description: The carry flag is complemented.
Group: Arithmetic
Page 31
Computer Science ( D9) XII - Paper –II
3) Syntax: STC
Description: The carry flag is Set.
Group: Arithmetic
Addressing Mode: Implied
Bytes: One Byte
Flags: The carry flag is modified. No other flags are affected.
D7 D6 D5 D4 D3 D2 D1 D0 A 97 1 0 1 01 F
Carry 1 1 B 98
C
A:1 0 0 1 1 0 0 1
B :1 0 0 1 1 0 0 0 D E
H L
carry 1 0 0 1 1 0 0 0 1
Result
(A)
After
S2(3) S1(1)
Sign
**According the third Condition: Add 66 to Final result and get Decimal Result.
1 1
Result 0 0 1 1 0 0 0 1 99
66 0 1 1 0 0 1 1 0 98
1 0 0 1 0 1 1 1 197
carry 1 S2(9) S1(7)
Page 32
Computer Science ( D9) XII - Paper –II
5) Syntax: DAD Rp
Where Rp: Registers Pairs may be any 16-bit registers pairs (BC, DE, HL and SP)
BC denotes by B, DE denotes by D, HL denotes by H and SP denotes by SP.
Description: The 16-bit contents of the specified register pair are added to the contents of the
HL register pair and the sum is saved in the HL registers pair. The content of the source
register pair are not altered. HL = HL + Rp
Group: Arithmetic A 1 0 1 01 F
Addressing Mode: Register B
Bytes: One Byte C
02 12
Flags: If the result is larger than 16-bit the D E
cy flag is set. H 02 42 L
A 1 0 1 01
1 1 F
B
0000 0010 0001 0010 C
0000 0010 0100 0010 D
02 12
E
0000 0100 0101 0100
H 04 54 L
Combinations: DAD B, DAD D, DAD H, DAD SP After
6) Syntax: DI
Description: The interrupt Enable Flip-flop is reset and all the interrupts except the TRAP
are disables.
Group: Machine Control
Addressing Mode: Implied
Bytes: One Byte
Flags: No flags are affected.
7) Syntax: EI
Description: The interrupt Enable Flip-flop is set and all the interrupts are Enable.
Group: Machine Control
Addressing Mode: Implied
Bytes: One Byte
Flags: No flags are affected.
Page 33
Computer Science ( D9) XII - Paper –II
A C3 F
B C Memory Address Data
2000 A1
D E 2001 C3
20 01
2002 F4
H L 2004 54
Example : LDAX D
Combination: LDAX B, LDAX D
H 50 00 H 50 00
L
Example: PCHL PC PC
2000 5000
Before After
15) Syntax: SPHL
Description: The contents of register H and L are copied into the Stack Pointer registers. The
contents of H are placed as a high order byte and of L as low order byte.
SP SP
1000 5000
Before After
Page 35
Computer Science ( D9) XII - Paper –II
Description: The contents of register H exchange with the contents of register D and the
content of register L are exchanged with content of register E.
Group: Data transfer (copy)
Addressing Mode: Implied
Bytes: One Byte A F A F
Flags: No flags are affected. B B C C
Example: XCHG D
40 20 E D
50 10 E
H 50 10 H 40 20
17) Syntax: XTHL L L
Before After
Description: The contents of register L exchange with the stack memory pointed out by the
contents of the stack pointer register. The contents of register H are exchanged with the next
stack pointer location (SP+1). However the contents of the stack pointer register are not
altered.
Group: Machine control
A
Addressing Mode: Implied F 4095
Bytes: One Byte B C
4096
Flags: No flags are affected. D E 4097 50
H 60 10
Example: XTHL L 4098
40
SP Stack Memory
4097
A F 4095
B 32 57 57
C
4096
D E 4097 32
H L xx
4098
SP Stack Memory
Page 36
4096 After
Computer Science ( D9) XII - Paper –II
Example : POP D SP
4096 Before
Stack Memory
A F 4095
B C
4096
32 57
D E 4097
H L xx
4098
SP Stack Memory
4098 After
Page 37
Computer Science ( D9) XII - Paper –II
Page 38