SlideShare uma empresa Scribd logo
1 de 26
SET DE INSTRUCCIONES ATMEL
OPERACIONES ARITMETICAS Y LOGICAS
José Arturo Álvarez Mtz.
Universidad Autónoma de Querétaro
Facultad de Informática
MAESTRÍA EN SOFTWARE EMBEBIDO
AVR Registers
• General purpose registers
• 32 8-bit registers, R0 ~ R31 or r0 ~ r31
• Can be further divided into two groups
• First half group: R0 ~ R15 and second half group:
R16~ R31
• Some instructions work only on the second half group
R16~R31
▪ E.g. ldi rd, #number ;rd ∈ R16~R31
2
AVR Registers
3
AVR Registers
• General purpose registers
• The following register pairs can work as
address indexes
• • X, R26:R27
• • Y, R28:R29
• • Z, R31:R31
• The following registers can be applied for
specific use
• R1:R0 store the result of multiplication instruction
• R0 stores the data loaded from the program
memory
4
AVR Registers
• I/O registers
• 64 8-bit registers
• Their names are defined in the m64def.inc file
• Used in input/output instructions
• Mainly storing data/addresses and control signal bits
• Some instructions work only with I/O registers, others
with general purpose registers – don’t confuse them
• E.g. in rd, port ; port must be an I/O register
• Will be covered in detail later
• Status register (SREG)
• A special I/O register
5
6
The Status Register in AVR
• The Status Register (SREG) contains
information about the result of the most recently
executed arithmetic instruction. This information
can be used for altering program flow in order to
perform conditional operations.
• SREG is updated after any of ALU operations by
hardware.
• SREG is not automatically stored when entering
an interrupt routine and restored when returning
from an interrupt. This must be handled by
software.
• Using in/out instruction to store/restore SREG
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 7 – I: Global Interrupt Enable
• Used to enable and disable interrupts.
• 1: enabled. 0: disabled.
• The I-bit is cleared by hardware after an interrupt
has occurred, and is set by the RETI instruction to
enable subsequent interrupts.
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 6 – T: Bit Copy Storage
• The Bit Copy instructions BLD (Bit LoaD) and
BST (Bit STore) use the T-bit as source or
destination for the operated bit. A bit from a
register in the Register File can be copied into
T by the BST instruction, and a bit in T can
be copied into a bit in a register in the
Register File by the BLD instruction.
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 5 – H: Half Carry Flag
• The Half Carry Flag H indicates a Half Carry
(carry from bit 4) in some arithmetic
operations.
• Half Carry is useful in BCD arithmetic.
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 4 – S: Sign Bit
• Exclusive OR between the Negative Flag N and the
Two’s Complement Overflow Flag V ( S = N ⊕V).
• Bit 3 – V: Two’s Complement Overflow Flag
• The Two’s Complement Overflow Flag V supports two’s
complement arithmetic.
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 2 – N: Negative Flag
• N is the most significant bit of the result.
• Bit 1 – Z: Zero Flag
• Z indicates a zero result in an arithmetic or logic
operation. 1: zero. 0: Non-zero.
The Status Register in
AVR (cont.)
I T H S V N Z C
Bit 7 6 5 4 3 2 1 0
• Bit 0 – C: Carry Flag
• Its meaning depends on the operation.
• For addition X+Y, it is the carry from the most
significant bit
• For subtraction x-y, where x and y are unsigned
integers, it indicates if x<y. If x<y, C=1; otherwise, C=0.
15
Data Memory Space
• Covers
• Register file
• I.e. registers in the
register file also have
memory address
• I/O registers
• I.e. I/O registers have two
versions of addresses
▪ I/O addresses
▪ Memory addresses
• SRAM data memory
• The highest memory
location is defined as
RAMEND
32 General purpose
Working Registers
0x0000
64 Input/Output
Registers
Internal SRAM
(128~4K
bytes)
External SRAM
0x1F
0x20
End Address
Data Memory
0x5F
0x60
8 bits
16
Program Memory Space
Program Memory
• Covers
• 16 bit Flash Memory
• Read only
▪ Instructions are retained
when power off
• Can be accessed with
special instructions
• LPM
• SPM
0x0000
Program Flash Memory
(1K bytes~128K bytes)
16 Bits
End Address
17
EEPROM Memory Space
• Covers
• 8-bit EEPROM
memory
• Use to permanently
store large set of data
• Can be accessed
using load and store
instructions with
special control bit
settings
• Not covered in this
course
Data EEPROM Memory
0x0000
EEPROM Memory
(64~4K bytes)
8 bits
End address
18
AVR Instruction Format
• For AVR, almost all instructions are 16 bits
long
• add Rd, Rr
• sub Rd, Rr
• mul Rd, Rr
• brge k
• Few instructions are 32 bits long
• lds Rd, k ( 0 ≤ k ≤ 65535 )
• loads 1 byte from the SRAM to a register.
AL Instructions
17
• Arithmetic
• addition
• E.g. ADD Rd, Rr
• Subtraction
• E.g. SUB Rd, Rr
• Increment/decrement
• E.g INC Rd
• Multiplication
• E.g. MUL Rd, Rr
• Logic
• E.g. AND Rd, Rr
• Shift
• E.g. LSL Rd
Transfer Instructions
18
• GP register
• E.g. MOV Rd, Rr
• I/O registers
• E.g. IN Rd, PORTA
• OUT PORTB, Rr
• Stack
• PUSH Rr
• POP Rd
• Immediate values
• E.g. LDI Rd, K8
• Memory
• Data memory
• E.g. LD Rd, X ST X,
Rr
• Program memory
• E.g. LPM
• EEPROM memory
• Not covered in this
course
Program Control Instructions
19
• Branch
• Conditional
• Jump to address
▪ BREQ des
▪ test ALU flag and jump
to specified address if
the test was true
• skips
▪ SBIC k
▪ test a bit in a register or
an IO register and skip
the next instruction if the
test was true.
• Unconditional
• Jump to the specified
address
▪ RJMP des
• Call subroutine
• E.g. RCALL k
• Return from subroutine
• E.g. RET
Bit & Other Instructions
20
• Bit
• Set bit
• E.g. SBI PORTA, b
• Clear bit
• E.g CBI PORTA, b
• Bit copy
• E.g. BST Rd, b
• Others
• NOP
• BREAK
• SLEEP
• WDR
Juego de instrucciones: Aritméticas y lógicas
-Los operandos sólo pueden ser registros o
constantes.
-Suma aritmética
- Sin acarreo
- Con acarreo
- Suma con registros 16 bits y dato inmediato
21
Juego de instrucciones: Aritméticas y lógicas
- Resta aritmética
- Sin acarreo
- Con dato inmediato
- Con acarreo
- Con dato inmediato y acarreo
- Con dato inmediato y con registros de 16 bits.
22
Juego de instrucciones: Aritméticas y lógicas
- Comparación
- 2 registros sin acarreo
- 1 registro con dato inmediato
- 2 registros con acarreo
- INCrementa y
DECrementa
23
Juego de instrucciones: Aritméticas y
lógicas
-CLR (poner a cero)
-SER (poner a $FF)
-NEG (Ca2)
24
Microcontrolador AT90S2313
Juego de instrucciones: Aritméticas y lógicas
- AND
- OR
- EO
R
- CO
M
25
Bibliografía
• http://www.atmel.com/images/Atmel-0856-AVR-Instruction-Set-
Manual.pdf
• http://www.cse.unsw.edu.au/~cs2121/LectureNotes/week4_notes.
pdf
• https://www.dte.us.es/tec_inf/itig/microele/docu/curso0506/tema
4/tema4_parte1_micro_0506.pdf
26

Mais conteúdo relacionado

Mais procurados (20)

Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
 
Abc2
Abc2Abc2
Abc2
 
Registers
RegistersRegisters
Registers
 
Interfacing ics for microprocessor
Interfacing ics for microprocessorInterfacing ics for microprocessor
Interfacing ics for microprocessor
 
Registers
RegistersRegisters
Registers
 
Lec12
Lec12Lec12
Lec12
 
Class7
Class7Class7
Class7
 
8255 Programmable parallel I/O
8255 Programmable parallel I/O 8255 Programmable parallel I/O
8255 Programmable parallel I/O
 
Microprocessor systems 8085(2)
Microprocessor systems 8085(2)Microprocessor systems 8085(2)
Microprocessor systems 8085(2)
 
Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
 
Register
RegisterRegister
Register
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
 
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
 
Lecture 04 branch call and time delay
Lecture 04  branch call and time delayLecture 04  branch call and time delay
Lecture 04 branch call and time delay
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
16. memory interfacing ii
16. memory interfacing ii16. memory interfacing ii
16. memory interfacing ii
 
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
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
 
Class2
Class2Class2
Class2
 

Semelhante a set de instrucciones primera parte de atmel

itft-8085 microprocessor
itft-8085 microprocessoritft-8085 microprocessor
itft-8085 microprocessorShifali Sharma
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxGowrishankar C
 
80386_ Bus Cycles & System Architecture.pdf
80386_ Bus Cycles & System Architecture.pdf80386_ Bus Cycles & System Architecture.pdf
80386_ Bus Cycles & System Architecture.pdfrupalidalvi10
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxMadavanR1
 
8085 microprocessor
8085 microprocessor8085 microprocessor
8085 microprocessorIama Marsian
 
The microprocessor and it's architecture
The microprocessor and it's architectureThe microprocessor and it's architecture
The microprocessor and it's architecturesamaa ali
 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsSreenivas Hanumandla
 
8085 paper-presentation-1232646931472979-2
8085 paper-presentation-1232646931472979-28085 paper-presentation-1232646931472979-2
8085 paper-presentation-1232646931472979-2manish singhal
 

Semelhante a set de instrucciones primera parte de atmel (20)

itft-8085 microprocessor
itft-8085 microprocessoritft-8085 microprocessor
itft-8085 microprocessor
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptx
 
80386_ Bus Cycles & System Architecture.pdf
80386_ Bus Cycles & System Architecture.pdf80386_ Bus Cycles & System Architecture.pdf
80386_ Bus Cycles & System Architecture.pdf
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
 
UNIT 3 mp (1).ppt
UNIT 3 mp (1).pptUNIT 3 mp (1).ppt
UNIT 3 mp (1).ppt
 
8085 microprocessor
8085 microprocessor8085 microprocessor
8085 microprocessor
 
The microprocessor and it's architecture
The microprocessor and it's architectureThe microprocessor and it's architecture
The microprocessor and it's architecture
 
8085 MICROPROCESSOR
8085 MICROPROCESSOR 8085 MICROPROCESSOR
8085 MICROPROCESSOR
 
Unit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller pptsUnit iv introduction to 8051 microcontroller ppts
Unit iv introduction to 8051 microcontroller ppts
 
MPMC
MPMC MPMC
MPMC
 
Lecture 03 basics of pic
Lecture 03 basics of picLecture 03 basics of pic
Lecture 03 basics of pic
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Topic 1
Topic 1Topic 1
Topic 1
 
arm.pptx
arm.pptxarm.pptx
arm.pptx
 
Chp 2 and 3.pptx
Chp 2 and 3.pptxChp 2 and 3.pptx
Chp 2 and 3.pptx
 
8085 paper-presentation-1232646931472979-2
8085 paper-presentation-1232646931472979-28085 paper-presentation-1232646931472979-2
8085 paper-presentation-1232646931472979-2
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 

Último

Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
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
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 

Último (20)

Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
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
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
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
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 

set de instrucciones primera parte de atmel

  • 1. SET DE INSTRUCCIONES ATMEL OPERACIONES ARITMETICAS Y LOGICAS José Arturo Álvarez Mtz. Universidad Autónoma de Querétaro Facultad de Informática MAESTRÍA EN SOFTWARE EMBEBIDO
  • 2. AVR Registers • General purpose registers • 32 8-bit registers, R0 ~ R31 or r0 ~ r31 • Can be further divided into two groups • First half group: R0 ~ R15 and second half group: R16~ R31 • Some instructions work only on the second half group R16~R31 ▪ E.g. ldi rd, #number ;rd ∈ R16~R31 2
  • 4. AVR Registers • General purpose registers • The following register pairs can work as address indexes • • X, R26:R27 • • Y, R28:R29 • • Z, R31:R31 • The following registers can be applied for specific use • R1:R0 store the result of multiplication instruction • R0 stores the data loaded from the program memory 4
  • 5. AVR Registers • I/O registers • 64 8-bit registers • Their names are defined in the m64def.inc file • Used in input/output instructions • Mainly storing data/addresses and control signal bits • Some instructions work only with I/O registers, others with general purpose registers – don’t confuse them • E.g. in rd, port ; port must be an I/O register • Will be covered in detail later • Status register (SREG) • A special I/O register 5
  • 6. 6 The Status Register in AVR • The Status Register (SREG) contains information about the result of the most recently executed arithmetic instruction. This information can be used for altering program flow in order to perform conditional operations. • SREG is updated after any of ALU operations by hardware. • SREG is not automatically stored when entering an interrupt routine and restored when returning from an interrupt. This must be handled by software. • Using in/out instruction to store/restore SREG
  • 7. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 7 – I: Global Interrupt Enable • Used to enable and disable interrupts. • 1: enabled. 0: disabled. • The I-bit is cleared by hardware after an interrupt has occurred, and is set by the RETI instruction to enable subsequent interrupts.
  • 8. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 6 – T: Bit Copy Storage • The Bit Copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T-bit as source or destination for the operated bit. A bit from a register in the Register File can be copied into T by the BST instruction, and a bit in T can be copied into a bit in a register in the Register File by the BLD instruction.
  • 9. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 5 – H: Half Carry Flag • The Half Carry Flag H indicates a Half Carry (carry from bit 4) in some arithmetic operations. • Half Carry is useful in BCD arithmetic.
  • 10. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 4 – S: Sign Bit • Exclusive OR between the Negative Flag N and the Two’s Complement Overflow Flag V ( S = N ⊕V). • Bit 3 – V: Two’s Complement Overflow Flag • The Two’s Complement Overflow Flag V supports two’s complement arithmetic.
  • 11. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 2 – N: Negative Flag • N is the most significant bit of the result. • Bit 1 – Z: Zero Flag • Z indicates a zero result in an arithmetic or logic operation. 1: zero. 0: Non-zero.
  • 12. The Status Register in AVR (cont.) I T H S V N Z C Bit 7 6 5 4 3 2 1 0 • Bit 0 – C: Carry Flag • Its meaning depends on the operation. • For addition X+Y, it is the carry from the most significant bit • For subtraction x-y, where x and y are unsigned integers, it indicates if x<y. If x<y, C=1; otherwise, C=0.
  • 13. 15 Data Memory Space • Covers • Register file • I.e. registers in the register file also have memory address • I/O registers • I.e. I/O registers have two versions of addresses ▪ I/O addresses ▪ Memory addresses • SRAM data memory • The highest memory location is defined as RAMEND 32 General purpose Working Registers 0x0000 64 Input/Output Registers Internal SRAM (128~4K bytes) External SRAM 0x1F 0x20 End Address Data Memory 0x5F 0x60 8 bits
  • 14. 16 Program Memory Space Program Memory • Covers • 16 bit Flash Memory • Read only ▪ Instructions are retained when power off • Can be accessed with special instructions • LPM • SPM 0x0000 Program Flash Memory (1K bytes~128K bytes) 16 Bits End Address
  • 15. 17 EEPROM Memory Space • Covers • 8-bit EEPROM memory • Use to permanently store large set of data • Can be accessed using load and store instructions with special control bit settings • Not covered in this course Data EEPROM Memory 0x0000 EEPROM Memory (64~4K bytes) 8 bits End address
  • 16. 18 AVR Instruction Format • For AVR, almost all instructions are 16 bits long • add Rd, Rr • sub Rd, Rr • mul Rd, Rr • brge k • Few instructions are 32 bits long • lds Rd, k ( 0 ≤ k ≤ 65535 ) • loads 1 byte from the SRAM to a register.
  • 17. AL Instructions 17 • Arithmetic • addition • E.g. ADD Rd, Rr • Subtraction • E.g. SUB Rd, Rr • Increment/decrement • E.g INC Rd • Multiplication • E.g. MUL Rd, Rr • Logic • E.g. AND Rd, Rr • Shift • E.g. LSL Rd
  • 18. Transfer Instructions 18 • GP register • E.g. MOV Rd, Rr • I/O registers • E.g. IN Rd, PORTA • OUT PORTB, Rr • Stack • PUSH Rr • POP Rd • Immediate values • E.g. LDI Rd, K8 • Memory • Data memory • E.g. LD Rd, X ST X, Rr • Program memory • E.g. LPM • EEPROM memory • Not covered in this course
  • 19. Program Control Instructions 19 • Branch • Conditional • Jump to address ▪ BREQ des ▪ test ALU flag and jump to specified address if the test was true • skips ▪ SBIC k ▪ test a bit in a register or an IO register and skip the next instruction if the test was true. • Unconditional • Jump to the specified address ▪ RJMP des • Call subroutine • E.g. RCALL k • Return from subroutine • E.g. RET
  • 20. Bit & Other Instructions 20 • Bit • Set bit • E.g. SBI PORTA, b • Clear bit • E.g CBI PORTA, b • Bit copy • E.g. BST Rd, b • Others • NOP • BREAK • SLEEP • WDR
  • 21. Juego de instrucciones: Aritméticas y lógicas -Los operandos sólo pueden ser registros o constantes. -Suma aritmética - Sin acarreo - Con acarreo - Suma con registros 16 bits y dato inmediato 21
  • 22. Juego de instrucciones: Aritméticas y lógicas - Resta aritmética - Sin acarreo - Con dato inmediato - Con acarreo - Con dato inmediato y acarreo - Con dato inmediato y con registros de 16 bits. 22
  • 23. Juego de instrucciones: Aritméticas y lógicas - Comparación - 2 registros sin acarreo - 1 registro con dato inmediato - 2 registros con acarreo - INCrementa y DECrementa 23
  • 24. Juego de instrucciones: Aritméticas y lógicas -CLR (poner a cero) -SER (poner a $FF) -NEG (Ca2) 24
  • 25. Microcontrolador AT90S2313 Juego de instrucciones: Aritméticas y lógicas - AND - OR - EO R - CO M 25