SlideShare a Scribd company logo
1 of 46
Download to read offline
1
Chapter 7
Programming Techniques with Additional
Instructions
2
Register Pairs
• The 8085 is an 8-bit microprocessor. So, its general purpose
registers are 8-bits wide.
– But, it uses 16-bit addresses.
• To allow manipulation of the 16-bit addresses, the 8085 allows its
registers to be paired.
– In other words, it is possible to combine two 8-bit registers together
into a 16-bit super register or a register pair.
• The 8085 recognizes only 3 register pairs: B and C, D and E and H
and L.
– It is not possible to pair B and E for example.
3
Identifying Register Pairs
• A register pair is identified with the name of the first register in the
pair.
• Therefore, the three register pairs are called:
– B for the B,C pair
– D for the D,E pair
– H for the H,L pair
4
Placing 16-bit Data into a Register Pair
• To place a 16-bit number into a register pair, we can place an 8-bit
number in each of the two registers.
MVI L 00H
MVI H 32H
– But, in what order?
MVI L 00H or MVI L 32H
MVI H 32H MVI H 00H
5
The LXI instruction
• The 8085 provides an instruction to place the 16-bit data into the
register pair in one step.
• LXI Rp, <16-bit address> (Load eXtended Immediate)
– The instruction LXI B 4000H will place the 16-bit number 4000 into
the register pair B, C.
• The upper two digits are placed in the 1st register of the pair and the lower two
digits in the 2nd .
40 00LXI B 40 00H B C
6
The Memory “Register”
• Most of the instructions of the 8085 can use a memory location in
place of a register.
– The memory location will become the “memory” register M.
• MOV M, R
• MOV M, B
– copy the data from register B into a memory location.
– Which memory location?
• The memory location is identified by the contents of the HL register
pair.
– The 16-bit contents of the HL register pair are treated as a 16-bit
address and used to identify the memory location.
7
Direct Memory Access Operations
8
Direct Memory Access Operations
9
Indirect Addressing Mode
• Using data in memory directly (without loading first into a
Microprocessor’s register) is called Indirect Addressing.
• Indirect addressing uses the data in a register pair as a 16-bit
address to identify the memory location being accessed.
– The HL register pair is always used in conjunction with the memory
register “M”.
– The BC and DE register pairs can be used to load data into the
Accumultor using indirect addressing.
10
Using the Other Register Pairs
– There is also an instruction for moving data from memory to the
accumulator without disturbing the contents of the H and L register.
• LDAX B/D (LoaD Accumulator eXtended)
– Copy the 8-bit contents of the memory location identified by the Rp register pair into
the Accumulator.
– This instruction only uses the BC or DE pair.
– It does not accept the HL pair.
11
Indirect Memory Access Operations
 Use a register PAIR as an address pointer !
 We can define memory access operations
using the memory location (16 bit address)
stored in a register pair: BC, DE or HL.
 First, we have be able to load the register pairs.
LXI B, (16-bit address)
LXI D, (16-bit address)
LXI H, (16-bit address)
 We can also increment / decrement register pairs.
12
Loading Register Pairs
13
Data Transfer from Memory to Processor
 Once the register pairs are loaded with the
memory address, we can use them as pointers.
 MOV R,M
Move the contents of the memory location stored
in HL register pair into register (R).
 LDAX B / LDAX D
Move the contents of the memory location stored
in BC (or DE) register pair into the accumulator.
14
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
H L
20 04
H L
20 04
MOV B, M
B C
XX XX
B C
FF XX
15
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
H L
20 05
H L
20 05
MOV C, M
B C
FF XX
B C
FF 24
16
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
B C
20 05
B C
20 05
LDAX B
A F
XX XX
A F
24 XX
B C
XX XX
LXI B, 2005
17
Data Transfer from Memory to Processor
18
Data Transfer from Processor to Memory
 Once the register pairs are loaded with the
memory address, we can use them as pointers.
 MOV M,R
Move the contents of the register (R) into memory
location stored in HL register pair.
 STAX B / STAX D
Move the contents of the accumulator into the
memory location stored in BC (or DE) register pair.
19
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
H L
70 00
H L
70 00
MOV M, C
B C
FF 24
B C
FF 24
247000
20
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
H L
70 01
H L
70 01
MOV M, B
B C
FF 24
B C
FF 24
FF7001
21
The Memory “Register”
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
FFFA
FF
24
XX
XX
0000
0001
0002
0003
0004
0005
2004
2005
7000
7001
FFFF
FFFB
FFFC
FFFD
FFFE
M
Register(s)
The
question
is which
register?
Answer
B C
70 01
B C
70 01
STAX B
A F
78 XX
B C
XX XX
LXI B, 7001
787001
22
Data Transfer from Processor to Memory
23
Arithmetic Operations Related to 16 Bits or Register Pairs
• Now that we have a 16-bit address in a register pair, how do we manipulate it?
– It is possible to manipulate a 16-bit address stored in a register pair as one entity
using some special instructions.
• INX Rp (Increment the 16-bit number in the register pair)
– INX B
– INX D
– INX H
– INX SP
• DCX Rp (Decrement the 16-bit number in the register pair)
– DCX B
– DCX D
– DCX H
– DCX SP
– The register pair is incremented or decremented as one entity. No need to worry
about a carry from the lower 8-bits to the upper. It is taken care of automatically.
24
Programing Tecniques: Looping, Counting, and
Indexing
• The programming technique used to instruct the
microprocessor to repeat tasks is called looping.
A loop is set up by instructing the microprocessor
to change the sequence of execution and
perform the task again. This process is
accomplished by using JUMP instructions. In
addition, techniques such as counting and
indexing are setting up a loop.
• Loops can be classified into two groups
– Continuous loop: Repeats a task continuously
– Conditional loop: Repeats a task until certain data
conditions are met.
25
Continuos Loop
Start
Perform Task
Go Back and Repeat
• A program with a
continuous loop does
not stop repeating the
task until the system is
reset.
26
Conditional Loop
• The microprocessor needs a counter to
repeat the task five times, and when the
counting is completed, it needs a flag.
1. Counter is set up by loading an
appropriate count ain a register.
2. Counting is performed by either
incrementing or decrementing the counter.
3. Loop is set up by a conditional JUMP
instruction.
4. End of counting is indicating by a flag.
– It is easier to count down to zero than
count up because the Z flag is set when
the register becomes zero.
Start
Set Up
Counter for
five tasks
. Task
performed.
. Reduced
count by 1.
Is
Counte
r
ZERO
?
Stop
27
Programing Tecniques: Looping, Counting, and Indexing
• Conditional loop, Counter, and Indexing Another
type of loop includes indexing along with a
counter. (Indexing means pointing or referencing
objects with sequential numbers. In a library,
books are arranged according to numbers, and
they are referred to or stored by numbers. This is
called indexing.) Similarly, data bytes are stored
in memory locations, and those data bytes are
referred to by their memory locations.
28
Block Data Transfer Example
 16 bytes of data are stored in memory locations
XX50 to XX5F (16 consecutive memory addresses).
 Transfer (copy) the entire block of data to new
memory locations starting at XX70.
 Make use of memory address pointers and
indirect addressing !
29
30
31
32
Arithmetic Operations Related to Memory
• These instructions perform an arithmetic operation using the
contents of a memory location while they are still in memory.
– ADD M
• Add the contents of M to the Accumulator
– SUB M
• Sub the contents of M from the Accumulator
– INR M / DCR M
• Increment/decrement the contents of the memory location in place.
– All of these use the contents of the HL register pair to identify the
memory location being used.
33
Arithmetic Operations Using Memory
34
Arithmetic Operations Using Memory
35
Illustrative Program: Addition With Carry
• Six bytes of data are stored in memory locations starting at XX50H.
Add all the data bytes. Use register B to save any carries
generated, while adding the data bytes. Display the entire sum at
two output ports, or store the sum at two consecutive memory
locations XX70 H. And XX71 H.
– Data(H): A2, FA, DF, E5, 98, 8B
36
Memory
Address
HI-LO
Machine
Code
Label Instructions
Opcode Operand
Comments
XX00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
AF
47
0E
06
21
50
XX
86
D2
0C
XX
04
23
0D
C2
07
XX
D3
PORT1
78
D3
PORT2
76
NXTBYTE:
NXTMEM:
XRA
MOV
MVI
LXI
ADD
JNC
INR
INX
DCR
JNZ
OUT
MOV
OUT
HLT
A
B,A
C,06H
H, XX50H
M
NXTMEM
B
H
C
NXTBYTE
PORT1
A,B
PORT2
; Clear (A) to save sum
; Clear (B) to save carry
; Set up register C as counter
; Set up HL as memory pointer
; Add byte from memory
; If no carry , do not increment
; carry register
; If carry, save carry bit
; Point to next memory location
; One addition is completed
; decrement counter
; If all bytes are not yet added,
; go back to get next byte
; Display low-order byte of the
; sum at PORT1
; Transfer carry to accumulator
; Display Carry digits
; End of program
37
Memory
Address
HI-LO
Machine
Code
Label Instructions
Opcode Operand
Comments
11
12
13
14
15
16
17
21
70
XX
77
23
70
76
LXI
MOV
INX
MOV
HLT
H, XX70H
M,A
H
M,B
; Point to the memory location
; to store answer
; Store low-order byte at XX70H
; Point to location XX71H
; Store carry bits
; End of the program
Illustrative Program: Addition With Carry
Storing in memory – Alternative to ouput display
38
Additional Logic Operations
• Rotate
– Rotate the contents of the accumulator one position to the left or
right.
– RLC Rotate the accumulator left.
Bit 7 goes to bit 0 AND the Carry flag.
– RAL Rotate the accumulator left through the carry.
Bit 7 goes to the carry and carry goes to bit 0.
– RRC Rotate the accumulator right.
Bit 0 goes to bit 7 AND the Carry flag.
– RAR Rotate the accumulator right through the carry.
Bit 0 goes to the carry and carry goes to bit 7.
39
RLC vs. RAL
• RLC
• RAL
Accumulator
Carry Flag
7 6 5 4 3 2 1 0
Accumulator
Carry Flag
7 6 5 4 3 2 1 0
40
RLC - Example
41
RAL - Example
42
RRC vs. RAR
• RRC
• RAR
Accumulator
Carry Flag
7 6 5 4 3 2 1 0
Accumulator
Carry Flag
7 6 5 4 3 2 1 0
43
RRC - Example
44
RAR - Example
45
Logical Operations
• Compare
• Compare the contents of a register or memory location with the contents of the
accumulator.
– CMP R/M Compare the contents of the register
or memory location to the contents of
the accumulator.
– CPI # Compare the 8-bit number to the
contents of the accumulator.
• The compare instruction sets the flags (Z, Cy, and S).
• The compare is done using an internal subtraction that does not change the
contents of the accumulator.
A – (R / M / #)
46
Logical Operations - Compare
• CMP R/M: This is a 1-byte instruction
– It compares the data byte in register or memory with the contents of the
accumulator.
– If (A)<(R/M), the CY flag is set and the Z flag is reset
– If (A)=(R/M), the Z flag is set and the CY flag is reset
– If (A)>(R/M), the CY and Z flags are reset
– When memory is operand, its address is specified by (HL).
– No contents are modified.
• CPI 8-bit: This is a 2 byte instruction
– It compares the second byte with the contents of the accumulator.
– If (A)<(8-bit), the CY flag is set and the Z flag is reset
– If (A)=(8-bit), the Z flag is set and the CY flag is reset
– If (A)>(8-bit), the CY and Z flags are reset
– No contents are modified.

More Related Content

What's hot

8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorKanchanPatil34
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
Register transfer and micro-operation
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operationNikhil Pandit
 
Register Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorRegister Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorNikhil Kumar
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operationsLakshya Sharma
 
programming techniques
programming techniquesprogramming techniques
programming techniquesRamaPrabha24
 
8086 modes
8086 modes8086 modes
8086 modesPDFSHARE
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORRamaPrabha24
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Demultiplexing of buses of 8085 microprocessor
Demultiplexing of buses of 8085 microprocessor Demultiplexing of buses of 8085 microprocessor
Demultiplexing of buses of 8085 microprocessor Rajal Patel
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086Estiak Khan
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5Motaz Saad
 

What's hot (20)

8086
80868086
8086
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
Register transfer and micro-operation
Register transfer and micro-operationRegister transfer and micro-operation
Register transfer and micro-operation
 
Register Organisation of 8086 Microprocessor
Register Organisation of 8086 MicroprocessorRegister Organisation of 8086 Microprocessor
Register Organisation of 8086 Microprocessor
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
 
programming techniques
programming techniquesprogramming techniques
programming techniques
 
8086 modes
8086 modes8086 modes
8086 modes
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 
Demultiplexing of buses of 8085 microprocessor
Demultiplexing of buses of 8085 microprocessor Demultiplexing of buses of 8085 microprocessor
Demultiplexing of buses of 8085 microprocessor
 
Huffman coding
Huffman coding Huffman coding
Huffman coding
 
Internal architecture-of-8086
Internal architecture-of-8086Internal architecture-of-8086
Internal architecture-of-8086
 
8255 PPI
8255 PPI8255 PPI
8255 PPI
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 

Viewers also liked

Threads and Game Programming In Java
Threads and Game Programming In JavaThreads and Game Programming In Java
Threads and Game Programming In Javacmkandemir
 
Web Sitesi Geliştirme Adımları
Web Sitesi Geliştirme AdımlarıWeb Sitesi Geliştirme Adımları
Web Sitesi Geliştirme Adımlarıcmkandemir
 
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1cmkandemir
 
CSS Uygulamaları 1
CSS Uygulamaları 1CSS Uygulamaları 1
CSS Uygulamaları 1cmkandemir
 
JDK and Eclipse Installation and Configuration
JDK and Eclipse Installation and ConfigurationJDK and Eclipse Installation and Configuration
JDK and Eclipse Installation and Configurationcmkandemir
 
İnternet Tabanlı Programlama Uygulama Notları
İnternet Tabanlı Programlama Uygulama Notlarıİnternet Tabanlı Programlama Uygulama Notları
İnternet Tabanlı Programlama Uygulama Notlarıcmkandemir
 
Matching Game In Java
Matching Game In JavaMatching Game In Java
Matching Game In Javacmkandemir
 
PHP ve MySQL Bağlantısı - Temel İşlemler
PHP ve MySQL Bağlantısı - Temel İşlemlerPHP ve MySQL Bağlantısı - Temel İşlemler
PHP ve MySQL Bağlantısı - Temel İşlemlercmkandemir
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructionscmkandemir
 
Kod Akış Kontrolü - Döngüler, Fonksiyonlar
Kod Akış Kontrolü - Döngüler, FonksiyonlarKod Akış Kontrolü - Döngüler, Fonksiyonlar
Kod Akış Kontrolü - Döngüler, Fonksiyonlarcmkandemir
 
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2cmkandemir
 
impress.js Framework
impress.js Frameworkimpress.js Framework
impress.js Frameworkcmkandemir
 
openCV and Java - Face Detection
openCV and Java - Face DetectionopenCV and Java - Face Detection
openCV and Java - Face Detectioncmkandemir
 
CSS - Sunum Bileşenleri
CSS - Sunum BileşenleriCSS - Sunum Bileşenleri
CSS - Sunum Bileşenlericmkandemir
 

Viewers also liked (15)

Threads and Game Programming In Java
Threads and Game Programming In JavaThreads and Game Programming In Java
Threads and Game Programming In Java
 
Web Sitesi Geliştirme Adımları
Web Sitesi Geliştirme AdımlarıWeb Sitesi Geliştirme Adımları
Web Sitesi Geliştirme Adımları
 
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 1
 
CSS Uygulamaları 1
CSS Uygulamaları 1CSS Uygulamaları 1
CSS Uygulamaları 1
 
JDK and Eclipse Installation and Configuration
JDK and Eclipse Installation and ConfigurationJDK and Eclipse Installation and Configuration
JDK and Eclipse Installation and Configuration
 
İnternet Tabanlı Programlama Uygulama Notları
İnternet Tabanlı Programlama Uygulama Notlarıİnternet Tabanlı Programlama Uygulama Notları
İnternet Tabanlı Programlama Uygulama Notları
 
Matching Game In Java
Matching Game In JavaMatching Game In Java
Matching Game In Java
 
PHP ve MySQL Bağlantısı - Temel İşlemler
PHP ve MySQL Bağlantısı - Temel İşlemlerPHP ve MySQL Bağlantısı - Temel İşlemler
PHP ve MySQL Bağlantısı - Temel İşlemler
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructions
 
Kod Akış Kontrolü - Döngüler, Fonksiyonlar
Kod Akış Kontrolü - Döngüler, FonksiyonlarKod Akış Kontrolü - Döngüler, Fonksiyonlar
Kod Akış Kontrolü - Döngüler, Fonksiyonlar
 
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2
Canvas Öğrenme Yönetim Sistemi Kullanım Kılavuzu Bölüm 2
 
impress.js Framework
impress.js Frameworkimpress.js Framework
impress.js Framework
 
PHP Temelleri
PHP TemelleriPHP Temelleri
PHP Temelleri
 
openCV and Java - Face Detection
openCV and Java - Face DetectionopenCV and Java - Face Detection
openCV and Java - Face Detection
 
CSS - Sunum Bileşenleri
CSS - Sunum BileşenleriCSS - Sunum Bileşenleri
CSS - Sunum Bileşenleri
 

Similar to Chapter 7 - Programming Techniques with Additional Instructions

Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdfHimanshuPant41
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).pptKanikaJindal9
 
Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Swati Watve-Phadke
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3Sajan Agrawal
 
Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085Sumit Swain
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture IIDr.YNM
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085 vijaydeepakg
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085Shifali Sharma
 
8085-instruction.ppt
8085-instruction.ppt8085-instruction.ppt
8085-instruction.pptSudeshnaDey22
 
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
 
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
 
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
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 
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
 

Similar to Chapter 7 - Programming Techniques with Additional Instructions (20)

Unit 2 Instruction set.pdf
Unit 2 Instruction set.pdfUnit 2 Instruction set.pdf
Unit 2 Instruction set.pdf
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt
 
Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02Assemblylanguageprogrammingof8085 100523023329-phpapp02
Assemblylanguageprogrammingof8085 100523023329-phpapp02
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
 
Pdemodule 4
Pdemodule 4Pdemodule 4
Pdemodule 4
 
Lab manual mp
Lab manual mpLab manual mp
Lab manual mp
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085
 
8085-instruction.ppt
8085-instruction.ppt8085-instruction.ppt
8085-instruction.ppt
 
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
 
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
 
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
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 
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
 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecture
 

More from cmkandemir

Temel HTML Etiketleri ve Kullanım Örnekleri
Temel HTML Etiketleri ve Kullanım ÖrnekleriTemel HTML Etiketleri ve Kullanım Örnekleri
Temel HTML Etiketleri ve Kullanım Örneklericmkandemir
 
Yapay Zeka Nedir?
Yapay Zeka Nedir?Yapay Zeka Nedir?
Yapay Zeka Nedir?cmkandemir
 
Zekayı Anlamak
Zekayı AnlamakZekayı Anlamak
Zekayı Anlamakcmkandemir
 
PHP - Kullanıcı Girişlerinin İşlenmesi
PHP - Kullanıcı Girişlerinin İşlenmesiPHP - Kullanıcı Girişlerinin İşlenmesi
PHP - Kullanıcı Girişlerinin İşlenmesicmkandemir
 
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer SystemsChapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systemscmkandemir
 
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly LanguageChapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly Languagecmkandemir
 
CSS - Genel Bakış
CSS - Genel BakışCSS - Genel Bakış
CSS - Genel Bakışcmkandemir
 
Temel HTML Etiketleri - Tablo, Form
Temel HTML Etiketleri - Tablo, FormTemel HTML Etiketleri - Tablo, Form
Temel HTML Etiketleri - Tablo, Formcmkandemir
 
Temel HTML Etiketleri - Text, Image, Link, List, Image
Temel HTML Etiketleri - Text, Image, Link, List, ImageTemel HTML Etiketleri - Text, Image, Link, List, Image
Temel HTML Etiketleri - Text, Image, Link, List, Imagecmkandemir
 
Vaadin JPAContainer
Vaadin JPAContainerVaadin JPAContainer
Vaadin JPAContainercmkandemir
 

More from cmkandemir (10)

Temel HTML Etiketleri ve Kullanım Örnekleri
Temel HTML Etiketleri ve Kullanım ÖrnekleriTemel HTML Etiketleri ve Kullanım Örnekleri
Temel HTML Etiketleri ve Kullanım Örnekleri
 
Yapay Zeka Nedir?
Yapay Zeka Nedir?Yapay Zeka Nedir?
Yapay Zeka Nedir?
 
Zekayı Anlamak
Zekayı AnlamakZekayı Anlamak
Zekayı Anlamak
 
PHP - Kullanıcı Girişlerinin İşlenmesi
PHP - Kullanıcı Girişlerinin İşlenmesiPHP - Kullanıcı Girişlerinin İşlenmesi
PHP - Kullanıcı Girişlerinin İşlenmesi
 
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer SystemsChapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
 
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly LanguageChapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
 
CSS - Genel Bakış
CSS - Genel BakışCSS - Genel Bakış
CSS - Genel Bakış
 
Temel HTML Etiketleri - Tablo, Form
Temel HTML Etiketleri - Tablo, FormTemel HTML Etiketleri - Tablo, Form
Temel HTML Etiketleri - Tablo, Form
 
Temel HTML Etiketleri - Text, Image, Link, List, Image
Temel HTML Etiketleri - Text, Image, Link, List, ImageTemel HTML Etiketleri - Text, Image, Link, List, Image
Temel HTML Etiketleri - Text, Image, Link, List, Image
 
Vaadin JPAContainer
Vaadin JPAContainerVaadin JPAContainer
Vaadin JPAContainer
 

Recently uploaded

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 

Recently uploaded (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 

Chapter 7 - Programming Techniques with Additional Instructions

  • 1. 1 Chapter 7 Programming Techniques with Additional Instructions
  • 2. 2 Register Pairs • The 8085 is an 8-bit microprocessor. So, its general purpose registers are 8-bits wide. – But, it uses 16-bit addresses. • To allow manipulation of the 16-bit addresses, the 8085 allows its registers to be paired. – In other words, it is possible to combine two 8-bit registers together into a 16-bit super register or a register pair. • The 8085 recognizes only 3 register pairs: B and C, D and E and H and L. – It is not possible to pair B and E for example.
  • 3. 3 Identifying Register Pairs • A register pair is identified with the name of the first register in the pair. • Therefore, the three register pairs are called: – B for the B,C pair – D for the D,E pair – H for the H,L pair
  • 4. 4 Placing 16-bit Data into a Register Pair • To place a 16-bit number into a register pair, we can place an 8-bit number in each of the two registers. MVI L 00H MVI H 32H – But, in what order? MVI L 00H or MVI L 32H MVI H 32H MVI H 00H
  • 5. 5 The LXI instruction • The 8085 provides an instruction to place the 16-bit data into the register pair in one step. • LXI Rp, <16-bit address> (Load eXtended Immediate) – The instruction LXI B 4000H will place the 16-bit number 4000 into the register pair B, C. • The upper two digits are placed in the 1st register of the pair and the lower two digits in the 2nd . 40 00LXI B 40 00H B C
  • 6. 6 The Memory “Register” • Most of the instructions of the 8085 can use a memory location in place of a register. – The memory location will become the “memory” register M. • MOV M, R • MOV M, B – copy the data from register B into a memory location. – Which memory location? • The memory location is identified by the contents of the HL register pair. – The 16-bit contents of the HL register pair are treated as a 16-bit address and used to identify the memory location.
  • 9. 9 Indirect Addressing Mode • Using data in memory directly (without loading first into a Microprocessor’s register) is called Indirect Addressing. • Indirect addressing uses the data in a register pair as a 16-bit address to identify the memory location being accessed. – The HL register pair is always used in conjunction with the memory register “M”. – The BC and DE register pairs can be used to load data into the Accumultor using indirect addressing.
  • 10. 10 Using the Other Register Pairs – There is also an instruction for moving data from memory to the accumulator without disturbing the contents of the H and L register. • LDAX B/D (LoaD Accumulator eXtended) – Copy the 8-bit contents of the memory location identified by the Rp register pair into the Accumulator. – This instruction only uses the BC or DE pair. – It does not accept the HL pair.
  • 11. 11 Indirect Memory Access Operations  Use a register PAIR as an address pointer !  We can define memory access operations using the memory location (16 bit address) stored in a register pair: BC, DE or HL.  First, we have be able to load the register pairs. LXI B, (16-bit address) LXI D, (16-bit address) LXI H, (16-bit address)  We can also increment / decrement register pairs.
  • 13. 13 Data Transfer from Memory to Processor  Once the register pairs are loaded with the memory address, we can use them as pointers.  MOV R,M Move the contents of the memory location stored in HL register pair into register (R).  LDAX B / LDAX D Move the contents of the memory location stored in BC (or DE) register pair into the accumulator.
  • 14. 14 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer H L 20 04 H L 20 04 MOV B, M B C XX XX B C FF XX
  • 15. 15 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer H L 20 05 H L 20 05 MOV C, M B C FF XX B C FF 24
  • 16. 16 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer B C 20 05 B C 20 05 LDAX B A F XX XX A F 24 XX B C XX XX LXI B, 2005
  • 17. 17 Data Transfer from Memory to Processor
  • 18. 18 Data Transfer from Processor to Memory  Once the register pairs are loaded with the memory address, we can use them as pointers.  MOV M,R Move the contents of the register (R) into memory location stored in HL register pair.  STAX B / STAX D Move the contents of the accumulator into the memory location stored in BC (or DE) register pair.
  • 19. 19 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer H L 70 00 H L 70 00 MOV M, C B C FF 24 B C FF 24 247000
  • 20. 20 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer H L 70 01 H L 70 01 MOV M, B B C FF 24 B C FF 24 FF7001
  • 21. 21 The Memory “Register” Accumulator Flags B C D E H L Program Counter Stack Pointer FFFA FF 24 XX XX 0000 0001 0002 0003 0004 0005 2004 2005 7000 7001 FFFF FFFB FFFC FFFD FFFE M Register(s) The question is which register? Answer B C 70 01 B C 70 01 STAX B A F 78 XX B C XX XX LXI B, 7001 787001
  • 22. 22 Data Transfer from Processor to Memory
  • 23. 23 Arithmetic Operations Related to 16 Bits or Register Pairs • Now that we have a 16-bit address in a register pair, how do we manipulate it? – It is possible to manipulate a 16-bit address stored in a register pair as one entity using some special instructions. • INX Rp (Increment the 16-bit number in the register pair) – INX B – INX D – INX H – INX SP • DCX Rp (Decrement the 16-bit number in the register pair) – DCX B – DCX D – DCX H – DCX SP – The register pair is incremented or decremented as one entity. No need to worry about a carry from the lower 8-bits to the upper. It is taken care of automatically.
  • 24. 24 Programing Tecniques: Looping, Counting, and Indexing • The programming technique used to instruct the microprocessor to repeat tasks is called looping. A loop is set up by instructing the microprocessor to change the sequence of execution and perform the task again. This process is accomplished by using JUMP instructions. In addition, techniques such as counting and indexing are setting up a loop. • Loops can be classified into two groups – Continuous loop: Repeats a task continuously – Conditional loop: Repeats a task until certain data conditions are met.
  • 25. 25 Continuos Loop Start Perform Task Go Back and Repeat • A program with a continuous loop does not stop repeating the task until the system is reset.
  • 26. 26 Conditional Loop • The microprocessor needs a counter to repeat the task five times, and when the counting is completed, it needs a flag. 1. Counter is set up by loading an appropriate count ain a register. 2. Counting is performed by either incrementing or decrementing the counter. 3. Loop is set up by a conditional JUMP instruction. 4. End of counting is indicating by a flag. – It is easier to count down to zero than count up because the Z flag is set when the register becomes zero. Start Set Up Counter for five tasks . Task performed. . Reduced count by 1. Is Counte r ZERO ? Stop
  • 27. 27 Programing Tecniques: Looping, Counting, and Indexing • Conditional loop, Counter, and Indexing Another type of loop includes indexing along with a counter. (Indexing means pointing or referencing objects with sequential numbers. In a library, books are arranged according to numbers, and they are referred to or stored by numbers. This is called indexing.) Similarly, data bytes are stored in memory locations, and those data bytes are referred to by their memory locations.
  • 28. 28 Block Data Transfer Example  16 bytes of data are stored in memory locations XX50 to XX5F (16 consecutive memory addresses).  Transfer (copy) the entire block of data to new memory locations starting at XX70.  Make use of memory address pointers and indirect addressing !
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32 Arithmetic Operations Related to Memory • These instructions perform an arithmetic operation using the contents of a memory location while they are still in memory. – ADD M • Add the contents of M to the Accumulator – SUB M • Sub the contents of M from the Accumulator – INR M / DCR M • Increment/decrement the contents of the memory location in place. – All of these use the contents of the HL register pair to identify the memory location being used.
  • 35. 35 Illustrative Program: Addition With Carry • Six bytes of data are stored in memory locations starting at XX50H. Add all the data bytes. Use register B to save any carries generated, while adding the data bytes. Display the entire sum at two output ports, or store the sum at two consecutive memory locations XX70 H. And XX71 H. – Data(H): A2, FA, DF, E5, 98, 8B
  • 36. 36 Memory Address HI-LO Machine Code Label Instructions Opcode Operand Comments XX00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 AF 47 0E 06 21 50 XX 86 D2 0C XX 04 23 0D C2 07 XX D3 PORT1 78 D3 PORT2 76 NXTBYTE: NXTMEM: XRA MOV MVI LXI ADD JNC INR INX DCR JNZ OUT MOV OUT HLT A B,A C,06H H, XX50H M NXTMEM B H C NXTBYTE PORT1 A,B PORT2 ; Clear (A) to save sum ; Clear (B) to save carry ; Set up register C as counter ; Set up HL as memory pointer ; Add byte from memory ; If no carry , do not increment ; carry register ; If carry, save carry bit ; Point to next memory location ; One addition is completed ; decrement counter ; If all bytes are not yet added, ; go back to get next byte ; Display low-order byte of the ; sum at PORT1 ; Transfer carry to accumulator ; Display Carry digits ; End of program
  • 37. 37 Memory Address HI-LO Machine Code Label Instructions Opcode Operand Comments 11 12 13 14 15 16 17 21 70 XX 77 23 70 76 LXI MOV INX MOV HLT H, XX70H M,A H M,B ; Point to the memory location ; to store answer ; Store low-order byte at XX70H ; Point to location XX71H ; Store carry bits ; End of the program Illustrative Program: Addition With Carry Storing in memory – Alternative to ouput display
  • 38. 38 Additional Logic Operations • Rotate – Rotate the contents of the accumulator one position to the left or right. – RLC Rotate the accumulator left. Bit 7 goes to bit 0 AND the Carry flag. – RAL Rotate the accumulator left through the carry. Bit 7 goes to the carry and carry goes to bit 0. – RRC Rotate the accumulator right. Bit 0 goes to bit 7 AND the Carry flag. – RAR Rotate the accumulator right through the carry. Bit 0 goes to the carry and carry goes to bit 7.
  • 39. 39 RLC vs. RAL • RLC • RAL Accumulator Carry Flag 7 6 5 4 3 2 1 0 Accumulator Carry Flag 7 6 5 4 3 2 1 0
  • 42. 42 RRC vs. RAR • RRC • RAR Accumulator Carry Flag 7 6 5 4 3 2 1 0 Accumulator Carry Flag 7 6 5 4 3 2 1 0
  • 45. 45 Logical Operations • Compare • Compare the contents of a register or memory location with the contents of the accumulator. – CMP R/M Compare the contents of the register or memory location to the contents of the accumulator. – CPI # Compare the 8-bit number to the contents of the accumulator. • The compare instruction sets the flags (Z, Cy, and S). • The compare is done using an internal subtraction that does not change the contents of the accumulator. A – (R / M / #)
  • 46. 46 Logical Operations - Compare • CMP R/M: This is a 1-byte instruction – It compares the data byte in register or memory with the contents of the accumulator. – If (A)<(R/M), the CY flag is set and the Z flag is reset – If (A)=(R/M), the Z flag is set and the CY flag is reset – If (A)>(R/M), the CY and Z flags are reset – When memory is operand, its address is specified by (HL). – No contents are modified. • CPI 8-bit: This is a 2 byte instruction – It compares the second byte with the contents of the accumulator. – If (A)<(8-bit), the CY flag is set and the Z flag is reset – If (A)=(8-bit), the Z flag is set and the CY flag is reset – If (A)>(8-bit), the CY and Z flags are reset – No contents are modified.