SlideShare a Scribd company logo
1 of 65
Download to read offline
Presented by:
Engr Zeeshan Ahmed Lodro
Lecturer-Department of Electronics Engineering Technology
BBS University of Technology and Skill Development Khairpur Mirs
1
Lecture-03
2
❑Instructions to perform addition
▪ Instruction type ADD R
▪ Flag register
▪ Instruction type ADI d8
▪ Instruction type INR R
▪ Instruction type ADC R
▪ Instruction type ACI d8
3
❑Instructions to perform subtraction
▪ Instruction type SUB R
▪ Instruction type SUI d8
▪ Instruction type DCR R
▪ Instruction type SBB R
▪ Instruction type SBI d8
▪ Instruction type INX rp
▪ Instruction type DCX rp
▪ Instruction type DAD rp
4
❑Decimal addition in 8085
▪ BCD Numbers
▪ DAA Instruction
5
❑8085 imposes the restriction that one of the
operands must be in the accumulator.The
other operand can be one of the following
▪ Contents of an 8-bit register.
▪ Contents of memory location pointed by HL
register pair.
▪ Eight bit immediate data.
6
❑ADD is a mnemonic that stands for Add
contents of R to accumulator. In this case R
stands for any of the following register pairs.
Or memory location M pointed by HL pair.
❑R= A,B,C,D,E,H,L or M
❑This instruction is used to add contents of R
and accumulator .
❑The result of addition is stored in
accumulator.
7
❑As R can have any of eight values, there are
eight opcodes for this type of instruction. It
occupies only 1-byte in memory.
❑ADD E is an example instruction of this type.
It is 1-byte instruction.
8
❑The result of execution is shown below.
Summary:
ADD R( 1-byte;ADD E; 8 opcode)
9
Register Before After
E F3H
A 45H 38H
 In the previous example, the result of
addition of 45 H and F3H turns out to be 38H,
which is less than the original value of 45 H
present in the accumulator.
 It is very clear that user will not be happy with
this because the correct answer is 38H with
carry of 1.
 This carry information is stored in special 8-
bit register called the flag register.
10
 The flag register can be represented by 1 bit
of information.
 There are 5 types of flag registers.
 Carry flag(CY)
 Auxiliary carry flag(AC)
 Sign flag(S)
 Parity flag(P)
 Zero flag(Z)
11
 Their position in flag register is shown below.
The positions marked with x are don’t care
bits.
 These individual flags are either set to 1 or
reset to 0 depending on the result of
execution of an arithmetic or logical
instructions.
12
 Notice that in the addition of any two 8-bit
numbers, the carry generated can be either 1
or 0.Thus to store the carry information 1-bit
storage is enough.
 The Cy bit is stored in the LS bit position in
the flag register.
13
14
 In the addition of any two 8-bit numbers, a
carry may be generated when we add the LS
hex digits of the two numbers. Such carry is
called intermediate carry, half carry or
auxiliary carry.
 Intel prefers to call it AC. In example 1 AC in
not generated however in example 2AC is
generated.
15
 As this is intermediated carry we are not
interested in storing the information. But
8085 still stores this AC information in bit
position 4 of the flag register.
16
 The S flag is set to 1, if the result of an
arithmetic operation is negative. Indicated by
MS bit of 8 bit result being 1.
 The S flag is set to 0, if the result of an
arithmetic operation is positive. Indicated by
MS bit of 8 bit result being 0.
 Thus the value of S flag is essentially the
value of the MS bit of the 8-bit result.
17
 The P flag is set to 1, if the 8–bit result of an
arithmetic operation has an even number of
1s in it.
 The P flag is set to 0, if the 8–bit result of an
arithmetic operation has an odd number of 1s
in it.
 In Example 1.The number of 1s are odd so the
parity flag is set to 0.
 In Example 2.The number of 1s are even so
the parity flag is set 1.
18
 The Z flag is set to 1, if the 8–bit result of an
arithmetic operation is 00H.
 The Z flag is set to 0, if the 8–bit result of an
arithmetic operation is not equal to 00H.
 In Example 1.The 8-bit result is 38H and is
non zero so the Z flag is reset to zero.
 What about Example 2?
19
 ADI is a mnemonic , which stands for ADd
Immediate to Accumulator and d8 stands for
any 8-bit data.
 This instruction is used to add 8-bit
immediate data to the accumulator.
 The result of addition will be store in
accumulator.
 The flags are affected based on the results.
20
 ADI F3H.
▪ The result of execution is shown below
Summary:
ADI d8( 2-bytes; ADI F3H; 1 opcode)
21
Register Before After
A 45H 38H
F Any values CY=1, AC=0 S=0,
P=0 Z=0
 INR is a mnemonic that stands for INcRement
and R stands for any of the following registers or
memory location M pointed by HL pair.
 R=A,B,C,D,E,H,L or M
 This instruction is used to add 1 to the contents
of R.
 The result of increment will be stored in R.
 All flags, except CY, flag are affected depending
on the results.
22
 INR M.
▪ The result of execution is shown below
Summary:
INR R( 1-byte; INR M; 8 opcodes)
23
Register Before After
HL F850H
F850H 45H 46H
F Any values Cy= no change,
AC=0, S=0,P=0,Z=0
 There are times when a user is required to
add tow numbers each of which is several
bytes in size.
 For example , we are adding 16 bit numbers.
 In this example the addition of 56H and F2H
results in a sum of 48H with carry of 1.
24
 Next we have to add 34H andA2H along with
this carry value of 1.
 To facilitate such operations 8085 provides
instructions to add two numbers along with
carry.
 ADC is mnemonic that stands for Add with
carry and R stands for any of the following
registers or memory location M pointed by
HL pair.
25
 R=A,B,C,D,E,H,L, or M
 This instruction is used to add contents of R
and accumulator along with the carry value.
 The result of addition will be store in the
accumulator.
26
 ADC E
▪ The result of execution is shown below
Summary:
ADC R( 1-byte; ADC E; 8 opcodes)
27
Register Before After
E 45H
A 33H 79H
F Cy=1
Others= any values
Cy= 0AC=0,
S=0,P=0,Z=0
 ACI is a mnemonic that stands for Add with
Carry Immediate to accumulator and d8
stands for any 8-bit dat.
 This instruction is used to add 8 bit
immediate data to the accumulator along
with the carry value.
 The result of addition will be stored in the
accumulator.
28
 ACI F3H
▪ The result of execution is shown below
Summary:
ACI d8( 2-bytes; ACI F3H; 1 opcode)
29
Register Before After
A 45H 38H
F Cy=0
Others= any values
Cy= 1, AC=0,
S=0,P=0,Z=0
 In the subtraction of two numbers 8085
imposes the restriction that accumulator will
have one operand from which the other
operand specified by one of the following will
be subtracted.
▪ Contents of 8-bit register
▪ Contents of memory location pointed by HL pair.
▪ 8-bit immediate data.
30
 SUB is a mnemonic that stands for SUBtract
contents of R from Accumulator.
 R=A,B,C,D,E,H,L, or M
 The result of the subtraction will be stored in
theAccumulator.
31
 SUB E
▪ The result of execution is shown below
Summary:
Sub R( 1-byte; SUB E; 8 opcodes)
▪ Why S=1? Check next slide
32
Register Before After
A F3H AEH
E 45H
F any values Cy= 0AC=0,
S=1,P=0,Z=0
Why S=1?
Because the number is negative.
How ?
We check in two ways if result is in hex or binary. Look
at the left digit and deduce the result as given.
▪ 0-7 <-> 0000-0111 <-> pos
8-F <-> 1000-1111 <-> neg
▪ In previous example result is AE so left digit is A which
is >7 hence number comes in range of 8-F the result is
negative. Similarly convert whole number AE into
binary and check the MSB(Left most digit) if it is 1
number is negative and if it is 0 number positive.
33
 Internally , 8085 performs this subtraction by
adding the 2’s complement of 45 H to F3H.
 Carry generated in this addition will be
complemented.Thus the Cy flag after the
subtraction is zero.
34
45
0100 0101
1011 1010
+1
1011 1011
8+2+1 8+2+1
11 11
B B
B=11
11+3=14=E
F=15
B=11
Total = 26
Subtract
16 that becomes 10=A
16 means carry
 SUB E
▪ The result of execution is shown below
Summary:
Sub R( 1-byte; SUB E; 8 opcodes)
35
Register Before After
A 30H 10H
E 20H
F any values Cy= 0AC=1,
S=1,P=0,Z=0
 How 8085 will perform this operation
internally?
36
 SUI stands for Subtract Immediate from
Accumulator and d8 stands for any 8-bot
data.
 This instruction is used to subtract 8-bit
immediate data from the accumulator.
 The result of the subtraction will be stored in
the accumulator.
 The flags are affected based on the results.
37
 SUI F3H
▪ The result of execution is shown below
Summary:
SUI d8( 2-bytes; SUI F3H; 1 opcode) 38
Register Before After
A 45H 52H
F any values Cy= 1, AC=1,
S=0,P=0,Z=0
F3
1111 0011
0000 1100
+1
0000 1101
0 D
D=13
13+5=18-16=2
4+1=5 Subtraction
of 16 from 18 means
addition of carry to next hex value
 DCR is a mnemonic that stands for
DeCRement and R stands for following
registers or memory location pointed b HL
pair.
 This instruction is used to subtract 1 from the
contents of R.The result of the increment will
be stored in R. All flags, except Cy flag are
affected depending on the result.
39
 DCR M
▪ The result of execution is shown below
Summary:
DCR R( 1-byte; DCR M; 8 opcodes)
40
Register Before After
HL F850H
F850 45H 44H
F any values Cy= no change
 There are times when user is required to
subtract two numbers each of which is
several bytes in size.
 For example, let us say it is needed to
perform the following subtraction.
41
 In this example the subtraction of 56H and
F2H results in 64H with a borrow of 1.
 Next we have to subtract 34H and 12H along
with this borrow.
 To facilitate such an operation, 8085 provides
instruction to subtract two numbers along
with borrow value.
42
 SBB is mnemonic that stands for SuBtract
with Borrow and R stands for any of the
following registers or memory location M
pointed by HL pair.
 This instruction is used to subtract contents
of R from accumulator along with carry value.
 The result of subtraction will be stored in
accumulator.
43
 SBB E
▪ The result of execution is shown below
Summary:
SBB R( 1-byte; SBB E; 8 opcodes)
44
Register Before After
E 45H
A 33H 44H
F Cy=1
Other=any values
Cy=1, AC=0, Z=0,
P=1, S=1
Borrow 1 from 3 that is equal
to=16+3=19-5=14, 1 is
Auxiliary carry=16+2=18-
4=14=4 1 is carry
3-1=2+16=18 3
4 5
4 4
 SBI is a mnemonic that stands for ‘Subtract
with Borrow Immediate from Accumulator’
and d8 stands for any 8-bit data.
 This instruction is used to subtract 8-bit
immediate data from the accumulator along
with the carry value.
 The result of subtraction will be stored in
accumulator.
45
 SBI F3H
▪ The result of execution is shown below
Summary:
SBI R( 2-bytes; SBI F3H; 1 opcode)
WHY C,P,S=1? 46
Register Before After
A 45H 52H
F Cy=0
Other=any values
Cy=1, AC=0, Z=0,
P=1, S=1
45
F3
-----
52
 INX is a mnemonic that stands for Increment
eXtended register and rp stands for any of
the following register pair
 rp=BC, DE, or HL
 This instruction is used to add 1 to the
contents of rp.The result of increment will be
stored in rp.
 A register pair is generally used to store a
memory address.
47
 INX B
▪ The result of execution is shown below
Flags are not affected in this instruction by default
because it causes problems in many cases.
Summary:
INX rp( 1-byte; INX B; 3 opcode)
48
Register Before After
BC F850H F851H
 DCX is a mnemonic that stands for
DeCrement eXtended register and rp stands
for any of following register pair.
 rp= BC, DE or HL
 This instruction is used to subtract 1 from the
contents of rp.The result of decrement will
be stored in rp.
 Flags are not affected in this type of
instruction.
49
 DCX B
▪ The result of execution is shown below
It may appear that DCX B is same as DCR C, But if content
of BC was F900H, it becomes F8FFH after execution, thus
DCX decrements 16-bit quantity while DCR decrements
8-bit quantity.
Summary:
DCX rp( 1-byte; DCX B; 3 opcode)
50
Register Before After
BC F850H F84FH
 Intel 8085 is basically an 8-bit
microprocessor. But the designers have
provided instructions to perform 16-bit
additions also.
 As the internal architecture is only 8 bit.This
instruction easily takes double the time
needed to add two 8-bit numbers.
 Dad is a mnemonic which stands for Double
Add and rp stands for any of the following
register pair.
51
 Rp= BC, DE, or HL
 This instruction is used to add contents of rp
to HL.
 The result of addition will be stored in HL.
 Thus in this instruction , HL is used as a 16-bit
accumulator.
 Only Cy flag is affected depending on the
result.
52
 DAD B
▪ The result of execution is shown below
Summary:
DAD rp( 1-byte; DAD B; 3 opcodes)
53
Register Before After
HL 1234H 0A84H
BC F850H
F any values Cy=1, no change in
other flags
 In digital computer every thing is represented
by 0s and 1s.
 For example an instruction will have a code
using only 0s and 1s. Data is also represented
using 0s and 1s.
 Data can be of different types like unsigned
numbers, signed numbers, floating point
numbers, binary coded decimal(BCD)
numbers.
54
 Many time we are required to represent
decimal numbers in a computer to perform
arithmetic of these numbers.
 For example we may be required to total
marks a student has obtained in five different
subjects where obviously the marks are
awarded in decimal notation.
 For this purpose BCD code is extensively
used.
55
 In BCD notation 4 bits are used to code a digit
and so two digits of information is stored in a
byte.
 For example decimal 39 is represented in BCD
so two digit of information is stored in a byte.
 Decimal 39 is represented in BCD as
0011, 1001
Codes 1010,1011,1100,1101,1110 and 1111 are
illegal in BCD notation.
56
 Similarly decimal 1024 is represented in BCD
as 0001 0000 0010 0100
 Same decimal is represented in binary in
binary as 0000 o100 0000 0000
57
 Suppose we want to add two decimal
numbers 38 and 45.They will be represented
in BCD as 0011 1000 and 0100 0101.The
addition will be 0111 1101. if we interpret this
result as BCD number the answer is incorrect
as well as illegal.
 This is where DAA instruction proves its
usefulness.
58
 The working of DAA instruction depends on
AL register, Cy and AC flags.
 In effect , it adds 00H, 06H, 60H or 66H to
accumulator as to get the correct BCD
answer in the accumulator with given
conditions.
 Condition #1
 If the LS hex digit in A is <=9 andAC flag is 0,
the LS hex digit value will not be altered.
59
 Condition#2
 If the LS hex digit is >9 or ifAC flag is set to 1,
it adds 6 to the LS hex digit of A. Further it
increments the MS hex digit if this addition
resulted in carry to the MS digit position.
 In this process, the Cy flag will be set to 1 if
the MS hex digit was incremented from F to
0.
60
 Condition#3
 If the MS hex digit is <=9 and Cy flag is 0.The
MS hex digit will not be altered.And CY flag
will be reset to 0.
 Condition#4
 If the MS hex digit is>9 or if Cy flag is set to 1,
it adds 6 to the MS hex digit of A and sets Cy
flag to 1.
 Note: DAA instruction can not be used for
decimal subtraction.
61
 Add 45 BCD and 38 BCD and store the result
7DH inA.
 In this case, Cy flag=0 and AC flag=0, But a D
is an invalid BCD code,The DAA instruction
adds 06 to A.Thus we get 83H in A which will
now be interpreted as 83 BCD.
62
 Add 63 BCD and 88 BCD and store the result
EBH in A.
 Add 53 BCD and 36 BCD and store the result
89H in A.
 Add 99 BCD and 88BCD and store the result
21H in A.
 Add 63 BCD and 42 BCD and store the result
A5H in A.
63
 Solution can be found in recommended book
64
65

More Related Content

What's hot

Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Swati Watve-Phadke
 
Instruction set-of-8085
Instruction set-of-8085Instruction set-of-8085
Instruction set-of-8085saleForce
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310DHEERAJ DHAKAR
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORRamaPrabha24
 
Microprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal numberMicroprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal numberSukanta Dutta
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
Instruction set 8085
Instruction set 8085Instruction set 8085
Instruction set 8085varun sukheja
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorvishalgohel12195
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Basil John
 
Chapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional InstructionsChapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional Instructionscmkandemir
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction setSaumitra Rukmangad
 
Timing Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 MicroprocessorTiming Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 MicroprocessorDhrumil Panchal
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 

What's hot (19)

8085 micro processor
8085 micro processor8085 micro processor
8085 micro processor
 
8085 alp programs
8085 alp programs8085 alp programs
8085 alp programs
 
Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02
 
Instruction set-of-8085
Instruction set-of-8085Instruction set-of-8085
Instruction set-of-8085
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
 
Microprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal numberMicroprocessor 8085 addition of two decimal number
Microprocessor 8085 addition of two decimal number
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
Instruction set 8085
Instruction set 8085Instruction set 8085
Instruction set 8085
 
Some advanced instructions of the 8085 microprocessors
Some advanced instructions of the 8085 microprocessorsSome advanced instructions of the 8085 microprocessors
Some advanced instructions of the 8085 microprocessors
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processor
 
Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)Introduction to 8085 & it's description(includes basic lab experiments)
Introduction to 8085 & it's description(includes basic lab experiments)
 
Micro task1
Micro task1Micro task1
Micro task1
 
Chapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional InstructionsChapter 7 - Programming Techniques with Additional Instructions
Chapter 7 - Programming Techniques with Additional Instructions
 
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
8085 Paper Presentation slides,ppt,microprocessor 8085 ,guide, instruction set
 
Abc2
Abc2Abc2
Abc2
 
Timing Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 MicroprocessorTiming Diagram of MVI Instruction of 8085 Microprocessor
Timing Diagram of MVI Instruction of 8085 Microprocessor
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 

Similar to 8085 Microprocessor Addition and Subtraction Instructions

Lecture 04 Logical Group of Instructions
Lecture 04 Logical Group of InstructionsLecture 04 Logical Group of Instructions
Lecture 04 Logical Group of InstructionsZeeshan Ahmed
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSSwapnil Mishra
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Shubham Singh
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :PJathin Kanumuri
 
microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2Jathin Kanumuri
 
180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-dochomeworkping10
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085Shifali Sharma
 
12 chapter06 math_instructions_fa14
12 chapter06 math_instructions_fa1412 chapter06 math_instructions_fa14
12 chapter06 math_instructions_fa14John Todora
 
instruction-set-of-8085 (1).ppt
instruction-set-of-8085 (1).pptinstruction-set-of-8085 (1).ppt
instruction-set-of-8085 (1).pptssuserb448e2
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!PRABHAHARAN429
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers finalSARITHA REDDY
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2RLJIT
 
Math cl ccw_siemens_rev01_fa16
Math cl ccw_siemens_rev01_fa16Math cl ccw_siemens_rev01_fa16
Math cl ccw_siemens_rev01_fa16John Todora
 

Similar to 8085 Microprocessor Addition and Subtraction Instructions (20)

Lecture 04 Logical Group of Instructions
Lecture 04 Logical Group of InstructionsLecture 04 Logical Group of Instructions
Lecture 04 Logical Group of Instructions
 
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONSINTEL 8085 DATA FORMAT AND INSTRUCTIONS
INTEL 8085 DATA FORMAT AND INSTRUCTIONS
 
Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085Chapter 3 instruction set-of-8085
Chapter 3 instruction set-of-8085
 
microp-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :Pmicrop-8085 74 instructions for mct-A :P
microp-8085 74 instructions for mct-A :P
 
microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2microp-8085 74 instructions for mct-A :P-2
microp-8085 74 instructions for mct-A :P-2
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc180410227 ae2406-lab-manual-doc
180410227 ae2406-lab-manual-doc
 
Blockdiagramof8085.ppt
Blockdiagramof8085.pptBlockdiagramof8085.ppt
Blockdiagramof8085.ppt
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085
 
8085 Instructions.pdf
8085 Instructions.pdf8085 Instructions.pdf
8085 Instructions.pdf
 
12 chapter06 math_instructions_fa14
12 chapter06 math_instructions_fa1412 chapter06 math_instructions_fa14
12 chapter06 math_instructions_fa14
 
Class4
Class4Class4
Class4
 
8085-paper-presentation.ppt
8085-paper-presentation.ppt8085-paper-presentation.ppt
8085-paper-presentation.ppt
 
Architecture of 8085
Architecture of  8085Architecture of  8085
Architecture of 8085
 
Introduction to 8085 by adi ppt
Introduction to 8085 by adi pptIntroduction to 8085 by adi ppt
Introduction to 8085 by adi ppt
 
instruction-set-of-8085 (1).ppt
instruction-set-of-8085 (1).pptinstruction-set-of-8085 (1).ppt
instruction-set-of-8085 (1).ppt
 
Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!Microprocessor and Microcontroller Lab Manual!
Microprocessor and Microcontroller Lab Manual!
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
 
Math cl ccw_siemens_rev01_fa16
Math cl ccw_siemens_rev01_fa16Math cl ccw_siemens_rev01_fa16
Math cl ccw_siemens_rev01_fa16
 

More from Zeeshan Ahmed

Lecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsLecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsZeeshan Ahmed
 
Lecture1 The 8085 Microprocessor
Lecture1 The 8085 MicroprocessorLecture1 The 8085 Microprocessor
Lecture1 The 8085 MicroprocessorZeeshan Ahmed
 
Lecture 0 History of Microprocessors and Microcontrollers
Lecture 0 History of Microprocessors and Microcontrollers Lecture 0 History of Microprocessors and Microcontrollers
Lecture 0 History of Microprocessors and Microcontrollers Zeeshan Ahmed
 
Digital Signal Processing Lab Manual
Digital Signal Processing Lab ManualDigital Signal Processing Lab Manual
Digital Signal Processing Lab ManualZeeshan Ahmed
 
Power Electronics Lab Manual Spring 2017
Power Electronics Lab Manual Spring 2017Power Electronics Lab Manual Spring 2017
Power Electronics Lab Manual Spring 2017Zeeshan Ahmed
 
Tera Hertz Electromagnetic Waves
Tera Hertz Electromagnetic WavesTera Hertz Electromagnetic Waves
Tera Hertz Electromagnetic WavesZeeshan Ahmed
 
Industrial Electronics Lab Manual
Industrial Electronics Lab Manual Industrial Electronics Lab Manual
Industrial Electronics Lab Manual Zeeshan Ahmed
 
Signed numbers in 8051
Signed numbers in 8051Signed numbers in 8051
Signed numbers in 8051Zeeshan Ahmed
 

More from Zeeshan Ahmed (13)

Lecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsLecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of Instructions
 
Lecture1 The 8085 Microprocessor
Lecture1 The 8085 MicroprocessorLecture1 The 8085 Microprocessor
Lecture1 The 8085 Microprocessor
 
Lecture 0 History of Microprocessors and Microcontrollers
Lecture 0 History of Microprocessors and Microcontrollers Lecture 0 History of Microprocessors and Microcontrollers
Lecture 0 History of Microprocessors and Microcontrollers
 
Digital Signal Processing Lab Manual
Digital Signal Processing Lab ManualDigital Signal Processing Lab Manual
Digital Signal Processing Lab Manual
 
Power Electronics Lab Manual Spring 2017
Power Electronics Lab Manual Spring 2017Power Electronics Lab Manual Spring 2017
Power Electronics Lab Manual Spring 2017
 
Tera Hertz Electromagnetic Waves
Tera Hertz Electromagnetic WavesTera Hertz Electromagnetic Waves
Tera Hertz Electromagnetic Waves
 
Industrial Electronics Lab Manual
Industrial Electronics Lab Manual Industrial Electronics Lab Manual
Industrial Electronics Lab Manual
 
48 Laws of Power
48 Laws of Power 48 Laws of Power
48 Laws of Power
 
Synchronous Motor
Synchronous MotorSynchronous Motor
Synchronous Motor
 
networking topology
networking topologynetworking topology
networking topology
 
Audio amplifier
Audio amplifier Audio amplifier
Audio amplifier
 
Signed numbers in 8051
Signed numbers in 8051Signed numbers in 8051
Signed numbers in 8051
 
Bio—chip ] sensor
Bio—chip ] sensorBio—chip ] sensor
Bio—chip ] sensor
 

Recently uploaded

microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

8085 Microprocessor Addition and Subtraction Instructions

  • 1. Presented by: Engr Zeeshan Ahmed Lodro Lecturer-Department of Electronics Engineering Technology BBS University of Technology and Skill Development Khairpur Mirs 1 Lecture-03
  • 2. 2
  • 3. ❑Instructions to perform addition ▪ Instruction type ADD R ▪ Flag register ▪ Instruction type ADI d8 ▪ Instruction type INR R ▪ Instruction type ADC R ▪ Instruction type ACI d8 3
  • 4. ❑Instructions to perform subtraction ▪ Instruction type SUB R ▪ Instruction type SUI d8 ▪ Instruction type DCR R ▪ Instruction type SBB R ▪ Instruction type SBI d8 ▪ Instruction type INX rp ▪ Instruction type DCX rp ▪ Instruction type DAD rp 4
  • 5. ❑Decimal addition in 8085 ▪ BCD Numbers ▪ DAA Instruction 5
  • 6. ❑8085 imposes the restriction that one of the operands must be in the accumulator.The other operand can be one of the following ▪ Contents of an 8-bit register. ▪ Contents of memory location pointed by HL register pair. ▪ Eight bit immediate data. 6
  • 7. ❑ADD is a mnemonic that stands for Add contents of R to accumulator. In this case R stands for any of the following register pairs. Or memory location M pointed by HL pair. ❑R= A,B,C,D,E,H,L or M ❑This instruction is used to add contents of R and accumulator . ❑The result of addition is stored in accumulator. 7
  • 8. ❑As R can have any of eight values, there are eight opcodes for this type of instruction. It occupies only 1-byte in memory. ❑ADD E is an example instruction of this type. It is 1-byte instruction. 8
  • 9. ❑The result of execution is shown below. Summary: ADD R( 1-byte;ADD E; 8 opcode) 9 Register Before After E F3H A 45H 38H
  • 10.  In the previous example, the result of addition of 45 H and F3H turns out to be 38H, which is less than the original value of 45 H present in the accumulator.  It is very clear that user will not be happy with this because the correct answer is 38H with carry of 1.  This carry information is stored in special 8- bit register called the flag register. 10
  • 11.  The flag register can be represented by 1 bit of information.  There are 5 types of flag registers.  Carry flag(CY)  Auxiliary carry flag(AC)  Sign flag(S)  Parity flag(P)  Zero flag(Z) 11
  • 12.  Their position in flag register is shown below. The positions marked with x are don’t care bits.  These individual flags are either set to 1 or reset to 0 depending on the result of execution of an arithmetic or logical instructions. 12
  • 13.  Notice that in the addition of any two 8-bit numbers, the carry generated can be either 1 or 0.Thus to store the carry information 1-bit storage is enough.  The Cy bit is stored in the LS bit position in the flag register. 13
  • 14. 14
  • 15.  In the addition of any two 8-bit numbers, a carry may be generated when we add the LS hex digits of the two numbers. Such carry is called intermediate carry, half carry or auxiliary carry.  Intel prefers to call it AC. In example 1 AC in not generated however in example 2AC is generated. 15
  • 16.  As this is intermediated carry we are not interested in storing the information. But 8085 still stores this AC information in bit position 4 of the flag register. 16
  • 17.  The S flag is set to 1, if the result of an arithmetic operation is negative. Indicated by MS bit of 8 bit result being 1.  The S flag is set to 0, if the result of an arithmetic operation is positive. Indicated by MS bit of 8 bit result being 0.  Thus the value of S flag is essentially the value of the MS bit of the 8-bit result. 17
  • 18.  The P flag is set to 1, if the 8–bit result of an arithmetic operation has an even number of 1s in it.  The P flag is set to 0, if the 8–bit result of an arithmetic operation has an odd number of 1s in it.  In Example 1.The number of 1s are odd so the parity flag is set to 0.  In Example 2.The number of 1s are even so the parity flag is set 1. 18
  • 19.  The Z flag is set to 1, if the 8–bit result of an arithmetic operation is 00H.  The Z flag is set to 0, if the 8–bit result of an arithmetic operation is not equal to 00H.  In Example 1.The 8-bit result is 38H and is non zero so the Z flag is reset to zero.  What about Example 2? 19
  • 20.  ADI is a mnemonic , which stands for ADd Immediate to Accumulator and d8 stands for any 8-bit data.  This instruction is used to add 8-bit immediate data to the accumulator.  The result of addition will be store in accumulator.  The flags are affected based on the results. 20
  • 21.  ADI F3H. ▪ The result of execution is shown below Summary: ADI d8( 2-bytes; ADI F3H; 1 opcode) 21 Register Before After A 45H 38H F Any values CY=1, AC=0 S=0, P=0 Z=0
  • 22.  INR is a mnemonic that stands for INcRement and R stands for any of the following registers or memory location M pointed by HL pair.  R=A,B,C,D,E,H,L or M  This instruction is used to add 1 to the contents of R.  The result of increment will be stored in R.  All flags, except CY, flag are affected depending on the results. 22
  • 23.  INR M. ▪ The result of execution is shown below Summary: INR R( 1-byte; INR M; 8 opcodes) 23 Register Before After HL F850H F850H 45H 46H F Any values Cy= no change, AC=0, S=0,P=0,Z=0
  • 24.  There are times when a user is required to add tow numbers each of which is several bytes in size.  For example , we are adding 16 bit numbers.  In this example the addition of 56H and F2H results in a sum of 48H with carry of 1. 24
  • 25.  Next we have to add 34H andA2H along with this carry value of 1.  To facilitate such operations 8085 provides instructions to add two numbers along with carry.  ADC is mnemonic that stands for Add with carry and R stands for any of the following registers or memory location M pointed by HL pair. 25
  • 26.  R=A,B,C,D,E,H,L, or M  This instruction is used to add contents of R and accumulator along with the carry value.  The result of addition will be store in the accumulator. 26
  • 27.  ADC E ▪ The result of execution is shown below Summary: ADC R( 1-byte; ADC E; 8 opcodes) 27 Register Before After E 45H A 33H 79H F Cy=1 Others= any values Cy= 0AC=0, S=0,P=0,Z=0
  • 28.  ACI is a mnemonic that stands for Add with Carry Immediate to accumulator and d8 stands for any 8-bit dat.  This instruction is used to add 8 bit immediate data to the accumulator along with the carry value.  The result of addition will be stored in the accumulator. 28
  • 29.  ACI F3H ▪ The result of execution is shown below Summary: ACI d8( 2-bytes; ACI F3H; 1 opcode) 29 Register Before After A 45H 38H F Cy=0 Others= any values Cy= 1, AC=0, S=0,P=0,Z=0
  • 30.  In the subtraction of two numbers 8085 imposes the restriction that accumulator will have one operand from which the other operand specified by one of the following will be subtracted. ▪ Contents of 8-bit register ▪ Contents of memory location pointed by HL pair. ▪ 8-bit immediate data. 30
  • 31.  SUB is a mnemonic that stands for SUBtract contents of R from Accumulator.  R=A,B,C,D,E,H,L, or M  The result of the subtraction will be stored in theAccumulator. 31
  • 32.  SUB E ▪ The result of execution is shown below Summary: Sub R( 1-byte; SUB E; 8 opcodes) ▪ Why S=1? Check next slide 32 Register Before After A F3H AEH E 45H F any values Cy= 0AC=0, S=1,P=0,Z=0
  • 33. Why S=1? Because the number is negative. How ? We check in two ways if result is in hex or binary. Look at the left digit and deduce the result as given. ▪ 0-7 <-> 0000-0111 <-> pos 8-F <-> 1000-1111 <-> neg ▪ In previous example result is AE so left digit is A which is >7 hence number comes in range of 8-F the result is negative. Similarly convert whole number AE into binary and check the MSB(Left most digit) if it is 1 number is negative and if it is 0 number positive. 33
  • 34.  Internally , 8085 performs this subtraction by adding the 2’s complement of 45 H to F3H.  Carry generated in this addition will be complemented.Thus the Cy flag after the subtraction is zero. 34 45 0100 0101 1011 1010 +1 1011 1011 8+2+1 8+2+1 11 11 B B B=11 11+3=14=E F=15 B=11 Total = 26 Subtract 16 that becomes 10=A 16 means carry
  • 35.  SUB E ▪ The result of execution is shown below Summary: Sub R( 1-byte; SUB E; 8 opcodes) 35 Register Before After A 30H 10H E 20H F any values Cy= 0AC=1, S=1,P=0,Z=0
  • 36.  How 8085 will perform this operation internally? 36
  • 37.  SUI stands for Subtract Immediate from Accumulator and d8 stands for any 8-bot data.  This instruction is used to subtract 8-bit immediate data from the accumulator.  The result of the subtraction will be stored in the accumulator.  The flags are affected based on the results. 37
  • 38.  SUI F3H ▪ The result of execution is shown below Summary: SUI d8( 2-bytes; SUI F3H; 1 opcode) 38 Register Before After A 45H 52H F any values Cy= 1, AC=1, S=0,P=0,Z=0 F3 1111 0011 0000 1100 +1 0000 1101 0 D D=13 13+5=18-16=2 4+1=5 Subtraction of 16 from 18 means addition of carry to next hex value
  • 39.  DCR is a mnemonic that stands for DeCRement and R stands for following registers or memory location pointed b HL pair.  This instruction is used to subtract 1 from the contents of R.The result of the increment will be stored in R. All flags, except Cy flag are affected depending on the result. 39
  • 40.  DCR M ▪ The result of execution is shown below Summary: DCR R( 1-byte; DCR M; 8 opcodes) 40 Register Before After HL F850H F850 45H 44H F any values Cy= no change
  • 41.  There are times when user is required to subtract two numbers each of which is several bytes in size.  For example, let us say it is needed to perform the following subtraction. 41
  • 42.  In this example the subtraction of 56H and F2H results in 64H with a borrow of 1.  Next we have to subtract 34H and 12H along with this borrow.  To facilitate such an operation, 8085 provides instruction to subtract two numbers along with borrow value. 42
  • 43.  SBB is mnemonic that stands for SuBtract with Borrow and R stands for any of the following registers or memory location M pointed by HL pair.  This instruction is used to subtract contents of R from accumulator along with carry value.  The result of subtraction will be stored in accumulator. 43
  • 44.  SBB E ▪ The result of execution is shown below Summary: SBB R( 1-byte; SBB E; 8 opcodes) 44 Register Before After E 45H A 33H 44H F Cy=1 Other=any values Cy=1, AC=0, Z=0, P=1, S=1 Borrow 1 from 3 that is equal to=16+3=19-5=14, 1 is Auxiliary carry=16+2=18- 4=14=4 1 is carry 3-1=2+16=18 3 4 5 4 4
  • 45.  SBI is a mnemonic that stands for ‘Subtract with Borrow Immediate from Accumulator’ and d8 stands for any 8-bit data.  This instruction is used to subtract 8-bit immediate data from the accumulator along with the carry value.  The result of subtraction will be stored in accumulator. 45
  • 46.  SBI F3H ▪ The result of execution is shown below Summary: SBI R( 2-bytes; SBI F3H; 1 opcode) WHY C,P,S=1? 46 Register Before After A 45H 52H F Cy=0 Other=any values Cy=1, AC=0, Z=0, P=1, S=1 45 F3 ----- 52
  • 47.  INX is a mnemonic that stands for Increment eXtended register and rp stands for any of the following register pair  rp=BC, DE, or HL  This instruction is used to add 1 to the contents of rp.The result of increment will be stored in rp.  A register pair is generally used to store a memory address. 47
  • 48.  INX B ▪ The result of execution is shown below Flags are not affected in this instruction by default because it causes problems in many cases. Summary: INX rp( 1-byte; INX B; 3 opcode) 48 Register Before After BC F850H F851H
  • 49.  DCX is a mnemonic that stands for DeCrement eXtended register and rp stands for any of following register pair.  rp= BC, DE or HL  This instruction is used to subtract 1 from the contents of rp.The result of decrement will be stored in rp.  Flags are not affected in this type of instruction. 49
  • 50.  DCX B ▪ The result of execution is shown below It may appear that DCX B is same as DCR C, But if content of BC was F900H, it becomes F8FFH after execution, thus DCX decrements 16-bit quantity while DCR decrements 8-bit quantity. Summary: DCX rp( 1-byte; DCX B; 3 opcode) 50 Register Before After BC F850H F84FH
  • 51.  Intel 8085 is basically an 8-bit microprocessor. But the designers have provided instructions to perform 16-bit additions also.  As the internal architecture is only 8 bit.This instruction easily takes double the time needed to add two 8-bit numbers.  Dad is a mnemonic which stands for Double Add and rp stands for any of the following register pair. 51
  • 52.  Rp= BC, DE, or HL  This instruction is used to add contents of rp to HL.  The result of addition will be stored in HL.  Thus in this instruction , HL is used as a 16-bit accumulator.  Only Cy flag is affected depending on the result. 52
  • 53.  DAD B ▪ The result of execution is shown below Summary: DAD rp( 1-byte; DAD B; 3 opcodes) 53 Register Before After HL 1234H 0A84H BC F850H F any values Cy=1, no change in other flags
  • 54.  In digital computer every thing is represented by 0s and 1s.  For example an instruction will have a code using only 0s and 1s. Data is also represented using 0s and 1s.  Data can be of different types like unsigned numbers, signed numbers, floating point numbers, binary coded decimal(BCD) numbers. 54
  • 55.  Many time we are required to represent decimal numbers in a computer to perform arithmetic of these numbers.  For example we may be required to total marks a student has obtained in five different subjects where obviously the marks are awarded in decimal notation.  For this purpose BCD code is extensively used. 55
  • 56.  In BCD notation 4 bits are used to code a digit and so two digits of information is stored in a byte.  For example decimal 39 is represented in BCD so two digit of information is stored in a byte.  Decimal 39 is represented in BCD as 0011, 1001 Codes 1010,1011,1100,1101,1110 and 1111 are illegal in BCD notation. 56
  • 57.  Similarly decimal 1024 is represented in BCD as 0001 0000 0010 0100  Same decimal is represented in binary in binary as 0000 o100 0000 0000 57
  • 58.  Suppose we want to add two decimal numbers 38 and 45.They will be represented in BCD as 0011 1000 and 0100 0101.The addition will be 0111 1101. if we interpret this result as BCD number the answer is incorrect as well as illegal.  This is where DAA instruction proves its usefulness. 58
  • 59.  The working of DAA instruction depends on AL register, Cy and AC flags.  In effect , it adds 00H, 06H, 60H or 66H to accumulator as to get the correct BCD answer in the accumulator with given conditions.  Condition #1  If the LS hex digit in A is <=9 andAC flag is 0, the LS hex digit value will not be altered. 59
  • 60.  Condition#2  If the LS hex digit is >9 or ifAC flag is set to 1, it adds 6 to the LS hex digit of A. Further it increments the MS hex digit if this addition resulted in carry to the MS digit position.  In this process, the Cy flag will be set to 1 if the MS hex digit was incremented from F to 0. 60
  • 61.  Condition#3  If the MS hex digit is <=9 and Cy flag is 0.The MS hex digit will not be altered.And CY flag will be reset to 0.  Condition#4  If the MS hex digit is>9 or if Cy flag is set to 1, it adds 6 to the MS hex digit of A and sets Cy flag to 1.  Note: DAA instruction can not be used for decimal subtraction. 61
  • 62.  Add 45 BCD and 38 BCD and store the result 7DH inA.  In this case, Cy flag=0 and AC flag=0, But a D is an invalid BCD code,The DAA instruction adds 06 to A.Thus we get 83H in A which will now be interpreted as 83 BCD. 62
  • 63.  Add 63 BCD and 88 BCD and store the result EBH in A.  Add 53 BCD and 36 BCD and store the result 89H in A.  Add 99 BCD and 88BCD and store the result 21H in A.  Add 63 BCD and 42 BCD and store the result A5H in A. 63
  • 64.  Solution can be found in recommended book 64
  • 65. 65