Beruflich Dokumente
Kultur Dokumente
POLITECNICO
NACIONAL
ESCUELA
SUPERIOR
DE
INGENIERIA
MECANICA
Y
ELECTRICA
UNIDAD
ZACATENCO
INGENIERIA
EN
COMUNICACIONES
Y
ELECTRONICA
Guia
de
Instrucciones
del
Microcontrolador
MSP430G2231
y
Modos
de
Direccionamiento
Alumno:
Gonzlez
Mondragn
Luis
Alejandro
Grupo:
7CM7
Materia:
Microcontroladores
Profesor:
Edgar
Roman
Caldern
Daz
Indice
Modos
de
Direccionamiento
a) Modo
de
Registros
b) Modo
Indexado
c) Modo
Simbolico
d) Modo
Absoluto
e) Modo
de
Registros
Indirecto
f) Modo
Indirecto
de
Registro
Autoincrementado
g) Modo
Inmediato
Set
de
Instrucciones
del
Microcontrolador
MSP430G2231
a) b) c) d) e) Set
de
Instrucciones
Instrucciones
de
Formato
Doble
Instrucciones
de
Formato
Simple
Instrucciones
de
Salto
Ciclos
y
Longitudes
de
las
Instrucciones
Mem (0203h) = 0A1h C = 0, Z = 0, N = 1 (Low byte of register) + (Addressed byte) - (Addressed byte)
R5 = 00061h C = 0, Z = 0, N = 0 (Addressed byte) + (Low byte of register) - (Low byte of register, zero to High byte)
Modos de Direccionamiento
3.3
Existen 7 diferentes modos de direccionamiento para el operando de Seven addressing modes for the source operand and four addressing modes for the destination operand fuente y 4 para el de destino que pueden direccionar numbers in Table 3-3 describe the can address the complete address space with no exceptions. The bit el espacio contents of the direccin sin e (destination) mode completo de As (source) and Ad xcepciones. bits.
Addressing Modes
As/Ad 00/0 01/1 01/1 01/1
10/11/11/-
@Rn @Rn+ #N
seven addressing modes detail in the following sections. Most of the examples Thesame addressing mode forare explained in destination, but any valid combination of source and show the the source and NOTA: .B o .W explican lis possible inn qinstruction. destination addressing modes a forma e an ue se tratara la instruccin, si es a
NOTE:
Use of Labels EDE, TONI, TOM, and LEO Throughout MSP430 documentation EDE, TONI, TOM, and LEO are used as generic labels. They are only labels. They have no special meaning.
50
R5 02 R6 AA R7 00 0A FF 0A
0XDC
R4 DC R5 02 R6 0A
BH 0X21 BL 0XDC
0x020D 0x020C
MOV.B
R6
,
3(R5)
AA
0XAAFF
Dato
4+
0X020A=
0X020D
00
R6 FF R7 0A
BH
0X20
BL
0X00
0X20
0X00
0x0207
0x0206
0x0205
0x0204
0x0203
0x0202
d) Modo
Absoluto
(&)
Se
usa
en
Registros
de
los
subsistemas
del
Microcontrolador
MOV.W
&TONY
,
2(R4)
R4
0X206
Dato
2
+0X200=
0x202
02
00
0X00
MOV.B
@R5
,
4(R5)
0X20A
Dato
0X20
f)
Modo
Indirecto
de
Registro
Auto-Incrementado
@Rn+
MOV.W
@R4++2
,
R7
0X20A
Dato
0X00FF
MOV.B
@R5++1
,
R7
0X207
Dato
0X00
g)
Modo
Inmediato
#
MOV.W
#0X3575
,
0(R4)
MOV.B
#0XFF,
EDE
MOV.W
#EDE
,
R4
EDE=0X201
El
set
completo
del
MSP430
consiste
en
27
instrucciones
de
Nucleo
y
24
instrucciones
emuladas.
Hay
3
formatos
para
las
instrucciones
de
Nucleo:
Operando
Doble
Operando
Simple
Salto
Todas
las
instrucciones
de
operando
Simple
y
de
Doble
Operando
pueden
ser
instrucciones
usadas
como
byte
o
palabra
mediante
las
extensiones
.B
o
.W.
Si
no
se
usa
una
extensin,
la
instruccin
es
una
Figure 3-12. Core Instruction Map instruccin
de
palabra.
Table 3-17. MSP430 Instruction Set
Mnemonic ADC(.B) ADD(.B) ADDC(.B) AND(.B) BIC(.B) BIS(.B) BIT(.B) BR
(1) (1)
8xxx Cxxx 1xxx 14xx 18xx 1Cxx 20xx 24xx 28xx 2Cxx 30xx 34xx 38xx 3Cxx 4xxx 5xxx 6xxx 7xxx 8xxx 9xxx Axxx Bxxx Cxxx Dxxx Exxx Fxxx
RRA
RRA.B
SXT
PUSH
PUSH.B
CALL
RETI
Description Add C to destination Add source to destination Add source and C to destination AND source and destination Clear bits in destination Set bits in destination Test bits in destination Branch to destination Call destination Clear destination Clear C Clear N Clear Z dst + C src + dst dst dst dst dst dst dst
N * * * * * 0 * * * N *
Z * * * * * 0 * * * *Z
C * * * * * 0 * * * *C
src + dst + C src .and. dst src .or. dst src .and. dst dst PC+2 0 0 0 0 dst C N Z PC not.src .and. dst
stack, dst
dst
src,dst dst
Instruction Set
Add source and C decimally to dst src + dst + C Description - 1 Decrement destination dst dst
DECD(.B)
(1)
(1)
dst
Double-decrement destination Disable interrupts Enable interrupts Increment destination Invert destination Jump if C set/Jump if higher or same Jump if equal/Jump if Z set Jump if greater or equal Jump if less Jump Jump if N set Jump if C not set/Jump if lower Jump if not equal/Jump if Z not set Move source to destination No operation Pop item from stack to destination Push source onto stack Return from subroutine Return from interrupt
* -
* -
* -
* -
64
EINT (1) CPU INC(.B) INV(.B) JC/JHS JEQ/JZ JGE JL JMP JN JNC/JLO JNE/JNZ MOV(.B) NOP
(2)
dst dst dst label label label label label label label label src,dst
dst +1 .not.dst
SLAU144H December 2004 Revised April 2011 dst * * * * Submit Documentation Feedback * * * * * * * * * * * * * * * * * * * * dst
INCD(.B)
Copyright 2004 2011, Texas Double-increment destination Instruments Incorporated dst+2 dst
(1)
PC + 2
offset
PC
* * * 0
PUSH(.B)
RET
POP(.B)
(2)
(2)
dst src
Jump if N set Jump if C not set/Jump if lower Jump if not equal/Jump if Z not set Move source to destination No operation Pop item from stack to destination Push source onto stack Return from subroutine Return from interrupt src @SP SP - 2 @SP dst dst, SP+2 SP, src PC, SP + 2 SP @SP SP
* * * 0 * dst + 0FFFFh + C 1 1 1 C N C dst dst dst * * * 0 dst + 0FFFFh + 1 src .xor. dst dst 0 *
* * * * * * 1 * * * * *
* * * * * * 1 * * * * *
* * * * * * 1 * * * 1 *
NOP
(2)
POP(.B) RET
(2)
dst src
PUSH(.B) RETI RLA(.B) RLC(.B) RRA(.B) RRC(.B) SBC(.B) SETC SETN SETZ
(2) (2) (2) (2) (2) (2)
Rotate left arithmetically Rotate left through C Rotate right arithmetically Rotate right through C Subtract not(C) from destination Set C Set N Set Z
Subtract source from destination Subtract source and not(C) from dst Swap bytes Extend sign Test destination Exclusive OR source and destination
Emulated Instruction
SLAU144H December 2004 Revised April 2011 Submit Documentation Feedback Copyright
CPU
2004 2011, Texas Instruments Incorporated
65
www.ti.com
Instruction Set
6 B/W
5 As
2 D-Reg
En
el
siguiente
listado
se
pueden
apreciar
las
instrucciones
que
gozan
Table 3-11 lists and describes the double operand instructions. de
este
formato.
Table 3-11. Double Operand Instructions
Mnemonic MOV(.B) ADD(.B) ADDC(.B) SUB(.B) SUBC(.B) CMP(.B) DADD(.B) BIT(.B) BIC(.B) BIS(.B) XOR(.B) AND(.B) S-Reg, D-Reg src,dst src,dst src,dst src,dst src,dst src,dst src,dst src,dst src,dst src,dst src,dst src,dst Operation src dst dst dst dst dst Status Bits V * * * * * dst (decimally) * 0 dst * 0 N * * * * * * * * * Z * * * * * * * * * C * * * * * * * * *
src + dst
src + dst + C
dst + .not.src + 1 dst + .not.src + C dst - src src + dst + C src .and. dst not.src .and. dst src .or. dst src .xor. dst src .and. dst dst dst dst
* The status bit is affected The status bit is not affected 0 The status bit is de algunas instrucciones de Doble formato usando Ejemplos de el uso cleared 1 The status algunos modos bite Direccionamiento previamente vistos: d is set NOTE: Instructions CMP and MOV.B #0X00, &P2SEL SUB The instructions CMP and MOV.W #DATOS, R5 AND SUB are identical except for the storage of the result. The same is true for the BIT and instructions. MOV.B @R5+,&PIOUT MOV.W #49998,R4 MOV.B &P2IN,R5 CMP.B #0XC0,R5 BIC.B #BIT6 + BIT7,&P2DIR BIS.B #0XFF, &P1DIR AND.B #0XC0,R5 SLAU144H December 2004 Revised April 2011 CPU Submit Documentation Feedback Copyright 2004 2011, Texas Instruments Incorporated
59
14
13
12
11
10
6 B/W
5 Ad
D/S-Reg
Ahora
tenemos
las
Instrucciones
de
Formato
Simple
en
la
siguiente
Table 3-12 lists and describes the single operand instructions. Tabla:
Mnemonic RRC(.B) RRA(.B) PUSH(.B) SWPB CALL RETI SXT dst S-Reg, D-Reg dst dst src dst dst
MSB
SP, src
@SP
Swap bytes SP dst TOS TOS Bit 7 2 PC SR, SP + 2 PC,SP + 2 SP, PC+2
Bit 8........Bit 15
* 0
The status bit is affected The status bit is not affected The status bit is cleared Algunos The status bitde las Instrucciones de Formato Simple: ejemplos is set 1
60
All addressing modes are possible for the CALL instruction. If the symbolic mode (ADDRESS), the immediate mode (#N), the absolute mode ( EDE) or the indexed mode x(RN) is used, the word that follows contains the address information. CALL #TIEMP0 CALL #0AA04h CALL R5 MOVE.B &EDE,R5 SXT R5 ADD R5,R7 MOV #1234h,&EDE SWPB &EDE CPU SLAU144H December 2004 Revised April 2011 Submit Documentation Feedback Copyright 2004 2011, Texas Instruments Incorporated
10-Bit PC Offset
Conditional jumps support program branching relative to the PC and do not affect the status bits. The possible jump range is from 511 to +512 words relative to the PC value at the jump instruction. The 10-bit Algunos ejemplos de lis utilizacin de estas Instrucciones dentro de un added to the progr program-counter offset a treated as a signed 10-bit value that is doubled and counter: programa:
CPU
2004 2011, Texas Instruments Incorporated
Copyright
addressing modes used - not the instruction itself. The number of clock cycles refers to the MCLK. 3.4.4.1 Interrupt and Reset Cycles
Table 3-14 lists the CPU cycles for interrupt overhead and reset.
Ciclos
y
Longitudes
de
las
Instrucciones
Table 3-14. Interrupt and Reset Cycles
Action No. of Cycles Length of Instruction
Return from interrupt (RETI) 5 1
Interrupt ciclos El numero de accepted de reloj del CPU requeridos 6por una Instruccin WDT reset 4 depende del formato de la instruccin y de los modos de Reset (RST/NMI) 4 direccionamiento usados, no de la misma Instruccin. El numero -de ciclos de reloj se refiere al MCLK. 3.4.4.2 Format-II (Single Operand) Instruction Cycles and Lengths Table 3-15 lists the length Ciclos y Longitudes de land ICPU cycles for alldaddressing modes of format-II instructions. as nstrucciones e Formato Simple: Table 3-15. Format-II Instruction Cycles and Lengths No. of Cycles Addressing Mode Rn @Rn @Rn+ #N X(Rn) EDE EDE RRA, RRC SWPB, SXT 1 3 3 (See note) 4 4 4 PUSH 3 4 5 4 5 5 5 CALL 4 4 5 5 5 5 5 Length of Instruction 1 1 1 2 2 2 2 Example
SWPB R5 RRC @R9 SWPB @R10+ CALL #0F000h CALL 2(R7) PUSH EDE SXT &EDE
NOTE: Instruction Format Salto requieren Todas las instrucciones de II Immediate Mode un cdigo de palabra, y Do not e CPU para ejecutarse, and importar si el salto s in the destination toman 2 ciclos duse instruction RRA, RRC, SWPB, sin SXT with the immediate modee hace o field. Use of these in the immediate mode results in an unpredictable program operation. no. 3.4.4.3 Format-III (Jump) Instruction Cycles and Lengths All jump instructions require one code word, and take two CPU cycles to execute, regardless of whether the jump is taken or not. 62 CPU SLAU144H December 2004 Revised April 2011 Submit Documentation Feedback Copyright 2004 2011, Texas Instruments Incorporated
www.ti.com
Instruction Set
3.4.4.4
Format-I (Double Operand) Instruction Cycles and Lengths Table 3-16 lists the length Ciclos
y
Longitudes
and las
Icycles for all addressing ormato
Doble:
de
CPU nstrucciones
de
Fmodes of format-I instructions. Table 3-16. Format 1 Instruction Cycles and Lengths
Addressing Mode Src Rn Rm PC x(Rm) EDE EDE @Rn Rm PC x(Rm) EDE EDE @Rn+ Rm PC x(Rm) EDE EDE #N Rm PC x(Rm) EDE EDE x(Rn) Rm PC TONI x(Rm) TONI EDE Rm PC TONI x(Rm) TONI EDE Rm PC TONI x(Rm) TONI Dst No. of Cycles 1 2 4 4 4 2 2 5 5 5 2 3 5 5 5 2 3 5 5 5 3 3 6 6 6 3 3 6 6 6 3 3 6 6 6 Length of Instruction 1 1 2 2 2 1 1 2 2 2 1 1 2 2 2 2 2 3 3 3 2 2 3 3 3 2 2 3 3 3 2 2 3 3 3 Example
MOV BR ADD XOR MOV AND BR XOR MOV XOR ADD BR XOR MOV MOV MOV BR MOV ADD ADD MOV BR MOV ADD MOV AND BR CMP MOV MOV MOV BRA MOV MOV MOV
R5,R8 R9 R5,4(R6) R8,EDE R5,&EDE @R4,R5 @R8 @R5,8(R6) @R5,EDE @R5,&EDE @R5+,R6 @R9+ @R5,8(R6) @R9+,EDE @R9+,&EDE #20,R9 #2AEh #0300h,0(SP) #33,EDE #33,&EDE 2(R5),R7 2(R6) 4(R7),TONI 4(R4),6(R9) 2(R4),&TONI EDE,R6 EDE EDE,TONI EDE,0(SP) EDE,&TONI &EDE,R8 &EDE &EDE,TONI &EDE,0(SP) &EDE,&TONI
CPU
2004 2011, Texas Instruments Incorporated
63
Copyright