TI MSP430 Learning Materials
-
Upload
harshsharma -
Category
Documents
-
view
229 -
download
8
Transcript of TI MSP430 Learning Materials
-
8/11/2019 TI MSP430 Learning Materials
1/164
UBI
>> Contents
Lecture 2MSP430 Architecture
MSP430 Teaching Materials
Texas Instruments IncorporatedUniversity of Beira Interior (PT)
Pedro Dinis Gaspar, Antnio Esprito Santo, Bruno Ribeiro, Humberto SantosUniversity of Beira Interior, Electromechanical Engineering Department
www.msp430.ubi.pt
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
-
8/11/2019 TI MSP430 Learning Materials
2/164
UBI
>> Contents2
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Contents (1/3)
MSP430 architecture:
Main characteristics
Architecture topology Address space
Interrupt vector table
Central Processing Unit (MSP430 CPU)
Central Processing Unit (MSP430X CPU)
Addressing modes
Instructions set
-
8/11/2019 TI MSP430 Learning Materials
3/164
UBI
>> Contents3
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Contents (2/3)
Exploring the addressing modes of the MSP430architecture:
Instruction format:
Instruction format I: Double operand
Instruction format II: Single operand
Jump instructions format
Emulated instructions
Addressing modes:
Register mode
Indexed mode
Symbolic mode
Absolute mode
Indirect register mode
Indirect auto-increment mode
Immediate mode
-
8/11/2019 TI MSP430 Learning Materials
4/164
UBI
>> Contents4
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Contents (3/3)
Exploring the addressing modes of the MSP430Xarchitecture:
Instruction format in the MSP430X CPU
Exceptions to the representation of the extended Format IIinstructions
Extended emulated instructions
MSP430X address instructions
MSP430X CPU addressing modes
-
8/11/2019 TI MSP430 Learning Materials
5/164
UBI
>> Contents5
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Introduction
A comprehensive description of the MSP430 architecture,covering its:
Main characteristics; Device architecture;
Address space;
Interrupt vector table;
Central Processing Unit (MSP430 CPU and MSP430X CPU);
7 seven addressing modes and instruction set composed of:
27 base opcodes;
24 emulated instructions.
-
8/11/2019 TI MSP430 Learning Materials
6/164
UBI
>> Contents6
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Microcontroller characteristics
Integration: Able to implement a whole design onto a singlechip.
Cost: Are usually low-cost devices (a few $ each);
Clock frequency: Compared with other devices(microprocessors and DSPs), MCUs use a low clock frequency:
MCUs today run up to 100 MHz/100 MIPS (Million
Instructions Per Second).
Power consumption: Low power (battery operation);
Bits: 4 bits (older devices) to 32 bits devices;
Memory: Limited available memory, usually less than 1 MByte;
Input/Output (I/O): Low to high (8 to 150) pin-out count.
-
8/11/2019 TI MSP430 Learning Materials
7/164
UBI
>> Contents7
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MSP430 main characteristics (1/3)
Low power consumption:
0.1 A for RAM data retention;
0.8 A for real-time clock mode operation;
250 A/MIPS during active operation.
Low operation voltage (from 1.8 V to 3.6 V);
< 1 s clock start-up;
< 50 nA port leakage;
Zero-power Brown-Out Reset (BOR).
-
8/11/2019 TI MSP430 Learning Materials
8/164
UBI
>> Contents8
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MSP430 main characteristics (2/3)
On-chip analogue features:
10/12/16-bit Analogue-to-Digital Converter (ADC);
12-bit dual Digital-to-Analogue Converter (DAC);
Comparator-gated timers;
Operational Amplifiers (Op Amps);
Supply Voltage Supervisor (SVS).
16 bit RISC CPU:
Compact core design reduces power consumption and cost;
16-bit data bus;
27 core instructions;
7 addressing modes;
Extensive vectored-interrupt capability.
-
8/11/2019 TI MSP430 Learning Materials
9/164
UBI
>> Contents9
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MSP430 main characteristics (3/3)
Flexibility:
Up to 256 kByte Flash;
Up to 100 pins;
USART, I2C, Timers; LCD driver;
Embedded emulation;
And many more peripherals modules
Microcontroller performance:
Instruction processing on either bits, bytes or words
Reduced instructions set;
Compiler efficient; Wide range of peripherals;
Flexible clock system.
-
8/11/2019 TI MSP430 Learning Materials
10/164
-
8/11/2019 TI MSP430 Learning Materials
11/164
UBI
>> Contents11
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Address Space
Mapped into a single, contiguous address space:
Flash/ROM: All code, tables, and hard-coded constantsreside in this memory space.
Information memory: Variables needed for the nextpower up can be stored here during power down. It can alsobe used as code memory.
Boot memory: The bootstrap loader performs some of the
same functions as the JTAG interface.
RAM: RAM is used for both code and data.
Peripheral Modules: Peripheral modules consist of all on-chip peripheral registers that are mapped into the address
space.
Special Function Registers (SFRs): Some peripheralfunctions are mapped into memory with special dedicatedfunctions.
-
8/11/2019 TI MSP430 Learning Materials
12/164
UBI
>> Contents12
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Memory Map
Memory Address Description Access
End: 0FFFFh
Start: 0FFE0h
Interrupt Vector TableWord/Byte
End: 0FFDFh
Flash/ROM
0F800hStart *:01100h
Word/Byte
010FFhEnd *:
0107Fh Information Memory
Start: 01000h (Flash devices only)
Word/Byte
End: 0FFFh
Start: 0C00h
Boot Memory(Flash devices only) Word/Byte
09FFhEnd *:
027Fh RAM
Start: 0200h
Word/Byte
End: 01FFh
Start: 0100h
16-bit Peripheral modules Word
End: 00FFh
Start: 0010h8-bit Peripheral modules Byte
End: 000Fh
Start: 0000hSpecial Function Registers Byte
-
8/11/2019 TI MSP430 Learning Materials
13/164
UBI
>> Contents13
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Interrupt vector table
Mapped at the very end of memory space (upper 16words of Flash/ROM): 0FFE0h - 0FFFEh (4xx devices);
Priority of the interrupt vector increases with the word
address.
-
8/11/2019 TI MSP430 Learning Materials
14/164
UBI
>> Contents14
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (1/7)
RISC (Reduced Instructions Set Computing) architecture: Instructions are reduced to the basic ones (short set):
27 physical instructions;
24 emulated instructions.
This provides simpler and faster instruction decoding;
Interconnect by a using a common memory address bus(MAB) and memory data bus (MDB) - Von Neumannarchitecture: Makes use of only one storage structure for data and
instructions sets.
The separation of the storage processing unit is implicit;
Instructions are treated as data (programmable).
-
8/11/2019 TI MSP430 Learning Materials
15/164
UBI
>> Contents15
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (2/7)
RISC (Reduced Instructions Set Computing) typearchitecture:
Uses a 3-stage instruction pipeline containing:
Instruction decoding; 16 bit ALU;
4 dedicated-use registers;
12 working registers.
Address bus has 16 bit so it can address 64 kB (includingRAM + Flash + Registers);
Arithmetic Logic Unit (ALU): Addition, subtraction, comparison and logical (AND, OR,
XOR) operations;
Operations can affect the overflow, zero, negative, and carryflags of the SR (Status Register).
-
8/11/2019 TI MSP430 Learning Materials
16/164
UBI
>> Contents16
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (3/7)
Incorporates sixteen 16-bit registers:
4 registers (R0, R1, R2 and R3) have dedicated functions;
12 register are working registers (R4 to R15) for general
use.
R0: Program Counter (PC):
Points to the next instruction to be read from memory andexecuted by the CPU.
R1: Stack Pointer (SP):
1st: stack can be used by user to store data for later use(instructions: store by PUSH, retrieve by POP);
2nd: stack can be used by user or by compiler for subroutineparameters (PUSH, POP in calling routine; addressed via offsetcalculation on stack pointer (SP) in called subroutine);
-
8/11/2019 TI MSP430 Learning Materials
17/164
UBI
>> Contents17
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (4/7)
R1: Stack Pointer (SP) (continued):
3rd: used by subroutine calls to store the program countervalue for return at subroutine's end (RET);
4th: used by interrupt - system stores the actual PC valuefirst, then the actual status register content (on top of stack)on return from interrupt (RETI) the system get the same
status as just before the interrupt happened (as long as nonehas changed the value on TOS) and the same programcounter value from stack.
-
8/11/2019 TI MSP430 Learning Materials
18/164
UBI
>> Contents18
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (5/7)
R2: Status Register (SR):
Stores status and control bits;
System flags are changed automatically by the CPU;
Reserved bits are used to support the constant generator.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved for CG1 V SCG1 SCG0 OSCOFF CPUOFF GIE N Z C
Bit Description
8 V Overflow bit. V = 1 Result of an arithmetic operation overflows the signed-variable range.
7 SCG1 System clock generator 0. SCG1 = 1 DCO generator is turned off if not used for MCLK or SMCLK
6 SCG0 System clock generator 1. SCG0 = 1 FLL+ loop control is turned off
5 OSCOFF Oscillator Off. OSCOFF = 1 turns off LFXT1 when it is not used for MCLK or SMCLK
4 CPUOFF CPU off. CPUOFF = 1 disable CPU core.3 GIE General interrupt enable. GIE = 1 enables maskable interrupts.
2 N Negative flag. N = 1 result of a byte or word operation is negative.
1 Z Zero flag. Z = 1 result of a byte or word operation is 0.
0 C Carry flag. C = 1 result of a byte or word operation produced a carry.
-
8/11/2019 TI MSP430 Learning Materials
19/164
UBI
>> Contents19
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt19
Copyright 2008 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (6/7)
R2/R3: Constant Generator Registers (CG1/CG2):
Depending of the source-register addressing modes (As)value, six constants can be generated without code word or
code memory access to retrieve them.
This is a very powerful feature which allows theimplementation of emulated instructions, for example,instead of implement a core instruction for an increment the
constant generator is used.Register As Constant Remarks
R2 00 - Register mode
R2 01 (0) Absolute mode
R2 10 00004h +4, bit processing
R2 11 00008h +8, bit processing
R3 00 00000h 0, word processing
R3 01 00001h +1R3 10 00002h +2, bit processing
R3 11 0FFFFh -1, word processing
-
8/11/2019 TI MSP430 Learning Materials
20/164
UBI
>> Contents20
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt20
Copyright 2008 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430 CPU) (7/7)
R4 - R15: GeneralPurpose Registers:
These general-purpose registers are adequate to store dataregisters, address pointers, or index values and can be
accessed with byte or word instructions.
-
8/11/2019 TI MSP430 Learning Materials
21/164
UBI
>> Contents21
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(1/10)
Main features of the MSP430X CPU architecture:
The MSP430X CPU extends the addressing capabilities of theMSP430 family beyond 64 kB to 1 MB;
To achieve this, some changes have been made to theaddressing modes and two new types of instructions havebeen added;
One instruction type allows access to the entire addressspace, and the other is designed for address calculations;
The MSP430X CPU address bus has 20 bits, although thedata bus still has 16 bits. Memory accesses to 8-bit, 16-bit
and 20-bit data are supported;
Despite these changes, the MSP430X CPU remainscompatible with the MSP430 CPU, having a similar numberof registers.
-
8/11/2019 TI MSP430 Learning Materials
22/164
UBI
>> Contents22
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Organization of the MSP430X CPU: Although the MSP430X CPU structure is
similar to that of the MSP430 CPU, thereare some differences that will now be
highlighted;
With the exception of the status registerSR, all MSP430X registers are 20 bits;
The CPU can now process 20-bit or 16-bit data.
Central Processing Unit (MSP430X CPU)(2/10)
-
8/11/2019 TI MSP430 Learning Materials
23/164
UBI
>> Contents23
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(3/10)
The MSP430X CPU has 16 registers, some of which havespecial use:
R0 (PC) Program Counter: Has the same function as the MSP430 CPU, although now it
has 20 bits.
R1 (SP) Stack Pointer:
Has the same function as the MSP430 CPU, although now ithas 20 bits.
R2 (SR) Status Register:
Has the same function as the MSP430 CPU, but it still has 16bits.
-
8/11/2019 TI MSP430 Learning Materials
24/164
UBI
>> Contents24
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(4/10)
R2 (SR) Status Register:
Description of the SR bits:
-
8/11/2019 TI MSP430 Learning Materials
25/164
UBI
>> Contents25
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(5/10)
R2 (SR/CG1) and R3 (CG2) Constant Generators:
Registers R2 and R3 can be used to generate six differentconstants commonly used in programming, without adding
an additional 16-bit word to the instruction;
The constants are fixed and are selected by the (As) bits ofthe instruction. (As) selects the addressing mode.
Values of constants
generated:
-
8/11/2019 TI MSP430 Learning Materials
26/164
UBI
>> Contents26
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
Central Processing Unit (MSP430X CPU)(6/10)
R2 (SR/CG1) and R3 (CG2) Constant Generators:
Whenever the operand is one of the six constants, theregisters are selected automatically;
Therefore, when used in constant mode, registers R2 and R3cannot be used as source registers.
R4-R15 General-purpose registers:
Have the same function as in the MSP430 CPU, althoughthey now have 20 bits;
These registers can process 8-bit, 16-bit or 20-bit data;
If a byte is written to one of these registers it takes bits 7:0,the bits 19:8 are filled with zeroes. If a word is written toone of these registers it takes bits 15:0, the bits 19:16 arefilled with zeroes.
-
8/11/2019 TI MSP430 Learning Materials
27/164
UBI
>> Contents27
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
Central Processing Unit (MSP430X CPU)(7/10)
R4-R15 General-purpose registers:
Handling byte data (8 bits) using the suffix . B:
-
8/11/2019 TI MSP430 Learning Materials
28/164
UBI
>> Contents28
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(8/10)
R4-R15 General-purpose registers:
Handling word data (16 bits) using the suffix . W:
-
8/11/2019 TI MSP430 Learning Materials
29/164
UBI
>> Contents29
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Central Processing Unit (MSP430X CPU)(9/10)
R4-R15 General-purpose registers:
Manipulation of a 20-bit address using the suffix . A:
-
8/11/2019 TI MSP430 Learning Materials
30/164
UBI
>> Contents30
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Addressing modes
7 addressing modes for the source operand:
4 addressing modes for the destination operand: Register mode; Indexed mode; Symbolic mode; Absolute
mode.
For the destination operand, two additional addressingmodes can be emulated.
-
8/11/2019 TI MSP430 Learning Materials
31/164
UBI
>> Contents31
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instruction set
27 core instructions;
24 emulated instructions;
The instruction set is orthogonal;
The core instructions have unique opcodes decoded bythe CPU, while the emulated ones need assemblers andcompilers for their mnemonics;
There are three core-instruction formats: Double operand;
Single operand;
Program flow control - Jump.
-
8/11/2019 TI MSP430 Learning Materials
32/164
E l i th dd i d f th
-
8/11/2019 TI MSP430 Learning Materials
33/164
UBI
>> Contents33
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Organization of the MSP430 CPU: 16-bit address bus (MAB) and 16-bit
data bus (MDB).
Both registers and memory can beaccessed either in word format or in byteformat.
Allows the direct transfer of data
between memory, without passingthrough the registers.
The 16-bit registers can be accesseddirectly through the instructions, someof which run in a single clock cycle.
Some of the constants most used inprogramming can be obtained from theconstant generator.
Exploring the addressing modes of theMSP430 architecture (2/11)
E l i th dd i d f th
-
8/11/2019 TI MSP430 Learning Materials
34/164
UBI
>> Contents34
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Organization of the MSP430 CPU(continued):
The architecture has a 16 bit Arithmetic
Logic Unit (ALU).
Carrying out operations affects the stateof the following flags:
Zero (Z); Carry (C); Overflow (V); Negative (N).
The MCLK (Master) clock signal drivesthe CPU.
Exploring the addressing modes of theMSP430 architecture (3/11)
-
8/11/2019 TI MSP430 Learning Materials
35/164
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
36/164
UBI
>> Contents36
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (5/11)
R1 (SP) Stack Pointer:
This register is used by the MSP430 CPU to store the returnaddress of routines or interrupts;
Each time the data stack is accessed, the SP is incrementedor decremented automatically;
The user should be careful to initialise the SP register withthe valid address of the data stack in RAM;
The stack pointer SP always points to an even address, soits LSB is always zero.
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
37/164
UBI
>> Contents37
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (6/11)
R2 SR/CG1 & R3 CG2 (Status Register):
The status of the MSP430 CPU is defined by a set of bits
contained in register R2 (SR) (status register);
This register can only be accessed through registeraddressing mode;
All other addressing modes are reserved to support theconstants generator;
The organization of the individual bits of register R2 isshown in the following figure:
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
38/164
UBI
>> Contents38
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
Exploring the addressing modes of theMSP430 architecture (7/11)
R2 SR/CG1 & R3 CG2 (Status Register):15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved for CG1 V SCG1 SCG0 OSCOFF CPUOFF GIE N Z C
Bit Description
8 V Overflow bit.
V = 1 Result of an arithmetic operation overflows the signed-variable range.7 SCG1 System clock generator 1.
SCG1 = 1 DCO generator is turned off if not used for MCLK or SMCLK6 SCG0 System clock generator 0.
SCG0 = 1 FLL+ loop control is turned off
5 OSCOFF Oscillator Off.
OSCOFF = 1 turns off LFXT1 when it is not used for MCLK or SMCLK4 CPUOFF CPU off.
CPUOFF = 1 disable CPU core.3 GIE General Interrupt Enable.
GIE = 1 enables maskable interrupts.
2 N Negative flag.
N = 1 result of a byte or word operation is negative.1 Z Zero flag.
Z = 1 result of a byte or word operation is 0.0 C Carry flag.
C = 1 result of a byte or word operation produced a carry.
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
39/164
UBI
>> Contents39
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (8/11)
R2 SR/CG1 & R3 CG2 (Constant Generators):
Six different constants commonly used in programming canbe generated using the registers R2 and R3, without the
need to add a 16-bit word of code to the instruction; The constants are fixed and are selected by the instruction
bits (As). These control the addressing mode.
Register As Constant RemarksR2 00 - Register mode
R2 01 (0) Absolute mode
R2 10 00004h +4, bit processing
R2 11 00008h +8, bit processing
R3 00 00000h 0, word processing
R3 01 00001h +1
R3 10 00002h +2, bit processing
R3 11 0FFFFh -1, word processing
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
40/164
UBI
>> Contents40
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (9/11)
R4-R15: General-purpose registers:
The general purpose registers R4 toR15 can be used as data registers,data pointers and indices. They canbe accessed either as a byte or as aword;
These registers support operations
on words or bytes;
In the example to the right, thecontents of the least significant byte
of register R5 (0x8F) is added to thecontents of the memory addresspointed to by the register R6 (0x12h);
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
41/164
UBI
>> Contents41
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (10/11)
R4-R15: General-purpose registers:
The contents of the memory addressis updated with the result of the
operation (0xA1);
The status flags of the CPU in the SRare updated after the execution of
the instruction.
Exploring the addressing modes of the
-
8/11/2019 TI MSP430 Learning Materials
42/164
UBI
>> Contents42
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Exploring the addressing modes of theMSP430 architecture (11/11)
R4-R15: General-purpose registers:
The contents of the memory addresspointed to by R6 (0x5F) is added to
the contents of the least significantbyte of register R5 (0x02);
The result of the operation (0x61) is
stored in the least significant byte ofregister R5;
Meanwhile, the most significant byte
of register R5 is set to zero;
The system flags in SR are updatedin accordance with the result.
I t ti f t (1/4)
-
8/11/2019 TI MSP430 Learning Materials
43/164
UBI
>> Contents43
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instructions format (1/4)
In addition to the 27 instructions of the CPU there are 24emulated instructions;
The CPU coding is unique;
The emulated instructions make reading and writingcode more easy, but do not have their own op-codes;
Emulated instructions are replaced automatically byinstructions from the CPU;
There are no penalties for using emulated instructions. There are three formats used to encode instructions for
processing by the CPU core:
Double operand;
Single operand;
Jumps.
I t ti f t (2/4)
-
8/11/2019 TI MSP430 Learning Materials
44/164
UBI
>> Contents44
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instructions format (2/4)
The instructions for double and single operands, dependon the suffix used, (. W) word or (. B) byte.
These suffixes allow word or byte data access;
If the suffix is ignored, the instruction processes worddata by default.
Instructions format (3/4)
-
8/11/2019 TI MSP430 Learning Materials
45/164
UBI
>> Contents45
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instructions format (3/4)
The source and destination of the data operated by aninstruction are defined by the following fields:
src: source operand address, as defined in As and S-reg;
dst: destination operand address, as defined in Ad and D-reg; As: addressing bits used to define the addressing mode used
by the source operand;
S-reg: register used by the source operand;
Ad: Addressing bits used to define the addressing mode usedby the destination operand;
D-reg: register used by the destination operand;
B/W: word or byte access definition bit.
Instructions format (4/4)
-
8/11/2019 TI MSP430 Learning Materials
46/164
UBI
>> Contents46
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instructions format (4/4)
While all addresses within the address space are valid, itis the responsibility of the user to check that the type ofaccess is valid.
Example: the contents of the flash memory can be usedas a source operand, but can only be written to in certainconditions.
Instruction format I: Double operand
-
8/11/2019 TI MSP430 Learning Materials
47/164
UBI
>> Contents47
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
Instruction format I: Double operand
Organization of instructions with two operands:
Double operand instructions:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Op-code S-Reg Ad B/W As D-Reg
Mnemonic Operation Description
Arithmetic instructions
ADD( . B or . W) sr c, dst src+dstdst Add source to destination
ADDC( . B or . W) sr c, dst src+dst+Cdst Add source and carry to destination
DADD( . B or . W) sr c, dst src+dst+Cdst (dec) Decimal add source and carry to destination
SUB( . B or . W) sr c, dst dst+.not.src+1dst Subtract source from destination
SUBC( . B or . W) sr c, dst dst+.not.src+Cdst Subtract source and not carry from destination
Logical and register control instructions
AND( . B or . W) sr c, dst src.and.dstdst AND source with destination
BI C( . B or . W) sr c, dst .not.src.and.dstdst Clear bits in destination
BI S( . B or . W) sr c, dst src.or.dstdst Set bits in destinationBI T( . B or . W) sr c, dst src.and.dst Test bits in destination
XOR( . B or . W) sr c, dst src.xor.dstdst XOR source with destination
Data instructions
CMP(. B or . W) sr c, dst dst-src Compare source to destination
MOV( . B or . W) sr c, dst srcdst Move source to destination
Examples: double operand (1/3)
-
8/11/2019 TI MSP430 Learning Materials
48/164
UBI
>> Contents48
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Examples: double operand (1/3)
Move the contents of register R5 to register R4:
MOV R5, R4
Instruction code: 0x4504
This instruction uses 1 word;
The instruction coding specifies that the CPU must perform a16-bit data MOV instruction, with the contents of register R5
as the source and with register R4 as the destination.
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0
MOV R5 Register 16-Bits Register R4
Examples: double operand (2/3)
-
8/11/2019 TI MSP430 Learning Materials
49/164
UBI
>> Contents49
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Examples: double operand (2/3)
Move the contents of register R5 to the address inmemory TONI:
MOV R5, TONI
Instruction code: 0x4580
This instruction uses 2 words;
The instruction coding specifies that the CPU must perform a16-bit data MOV instruction using the contents of register R5to the memory address pointed to by X1 + PC;
The word X1 is stored in the word following the instruction.
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0
MOV R5 Symbolic 16 Bits Register PC
Examples: double operand (3/3)
-
8/11/2019 TI MSP430 Learning Materials
50/164
UBI
>> Contents50
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Examples: double operand (3/3)
Move the contents between the memory addresses EDENand TONI:MOV EDEN, TONI
Instruction code: 0x4090
This instruction uses 3 words;
The instruction coding specifies that the CPU must perform a16-bit data MOV instruction using the contents of the EDENmemory address pointed to by X1 + PC to the TONI memoryaddress pointed to by X2 + PC;
The word X1 followed by the word X2 are stored after theinstruction.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0MOV PC Symbolic 16-Bits Symbolic PC
Instruction format II: Single operand
-
8/11/2019 TI MSP430 Learning Materials
51/164
UBI
>> Contents51
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
Instruction format II: Single operand
The instructions with one operand are coded using thefollowing structure:
Single operand instructions:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Op-code B/W Ad D/S-Reg
Mnemonic Operation Description
Logical and register control instructions
RRA( . B or . W) dst MSBMSBLSBC Roll destination right
RRC( . B or . W) dst CMSBLSBC Roll destination right through (from) carry
SWPB( or . W) dst Swap bytes Swap bytes in destination
SXT dst bit 7bit 8bit 15 Sign extend destination
PUSH( . B or . W) sr c SP-2SP, src@SP Push source on stack
Program flow control instructions
CALL( . B or . W) dst SP-2SP, PC+2@SPdstPC
Subroutine call to destination
RETI TOSSR, SP+2SPTOSPC, SP+2SP
Return from interrupt
Examples: single operand (1/2)
-
8/11/2019 TI MSP430 Learning Materials
52/164
UBI
>> Contents52
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Examples: single operand (1/2)
Move the contents of register R5 to the right with carryflag:
RRC R5
Instruction code: 0x1005
This instruction uses 1 word;
The instruction coding specifies that the CPU must perform a16-bit data RRC instruction using the contents of register R5.
Op-code B/W Ad D-reg
0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1
RRC 16 bits Register R5
Examples: single operand (2/2)
-
8/11/2019 TI MSP430 Learning Materials
53/164
UBI
>> Contents53
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Examples: single operand (2/2)
Rotate the contents of memory TONI to the right withcarry flag:
RRC TONI
Instruction code: 0x1010
This instruction uses 2 words;
The instruction coding specifies that the CPU must perform a16-bit data RRC instruction pointed to by X1 + PC;
Word X1 is stored in the word following the instruction.
Op-code B/W Ad D-reg
0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0
RRC 16 bits Symbolic PC
-
8/11/2019 TI MSP430 Learning Materials
54/164
Jump instructions format (2/3)
-
8/11/2019 TI MSP430 Learning Materials
55/164
UBI
>> Contents55
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
p ( / )
The op-code always takes the value 001b, indicating thatit is a jump instruction;
The condition on which a jump occurs depends on the Cfield consisting of 3 bits, and may take the followingvalues:
000b: jump if not equal;
001b: jump if equal; 010b: jump if carry flag equal to zero;
011b: jump if carry flag equal to one;
100b: jump if negative (N = 1);
101b: jump if greater than or equal (N=V or (N OR V=0));
110b: jump if lower (N! = V or (V XOR N = 1));
111b: unconditional jump.
-
8/11/2019 TI MSP430 Learning Materials
56/164
Examples: jump format (1/2)
-
8/11/2019 TI MSP430 Learning Materials
57/164
UBI
>> Contents57
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Continue execution at the label mai n if the carry flag isactive:
J C mai n
Instruction code: 0x2FE4
This instruction uses 1 word;
The instruction coding specifies that the PC must be loadedwith the value resulting from the offset - 0x1C being appliedto the previous expression.
Op-code C 10-Bit PC offset
0 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0JC Carry = 1 0x1C
Examples: jump format (2/2)
-
8/11/2019 TI MSP430 Learning Materials
58/164
UBI
>> Contents58
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Continue to unconditionally execute code at the labelmai n:
J MP mai n
Instruction code: 0x3FE3
This instruction uses 1 word;
The instruction coding specifies that the PC must be loadedwith the value resulting from the offset - 0x1D being appliedto the previous expression.
Op-code C 10-Bit PC offset
0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1
JMP unconditional 0x1D
Emulated instructions (1/3)
-
8/11/2019 TI MSP430 Learning Materials
59/164
UBI
>> Contents59
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
In addition to the 27 CPU instructions, the following 24emulated instructions can also be used:
Mnemonic Operation Emulation Description
Arithmetic instructions
ADC(.B or .W) dst dst+Cdst ADDC(.B or .W) #0,dst Add carry to destination
DADC(.B or .W) dst dst+Cdst (decimally) DADD(.B or .W) #0,dst Decimal add carry todestination
DEC(.B or .W) dst dst-1dst SUB(.B or .W) #1,dst Decrement destination
DECD(.B or .W) dst dst-2dst SUB(.B or .W) #2,dst Decrement destination twice
INC(.B or .W) dst dst+1dst ADD(.B or .W) #1,dst Increment destination
INCD(.B or .W) dst dst+2dst ADD(.B or .W) #2,dst Increment destination twice
SBC(.B or .W) dst dst+0FFFFh+Cdstdst+0FFhdst
SUBC(.B or .W) #0,dst Subtract source and borrow/.NOT. carry from dest.
Emulated instructions (2/3)
-
8/11/2019 TI MSP430 Learning Materials
60/164
UBI
>> Contents60
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
In addition to the 27 CPU instructions, the following 24emulated instructions can also be used (continued):
Mnemonic Operation Emulation Description
Logical and register control instructions
INV(.B or .W) dst .NOT.dstdst XOR(.B or .W) #0(FF)FFh,dst Invert bits in destination
RLA(.B or .W) dst CMSBMSB-1LSB+1LSB0
ADD(.B or .W) dst,dst Rotate left arithmetically
RLC(.B or .W) dst CMSBMSB-1LSB+1LSBC
ADDC(.B or .W) dst,dst Rotate left through carry
Program flow control
BR dst dstPC MOV dst,PC Branch to destination
DINT 0GIE BIC #8,SR Disable (general)
interruptsEINT 1GIE BIS #8,SR Enable (general) interrupts
NOP None MOV #0,R3 No operation
RET @SPPCSP+2SP
MOV @SP+,PC Return from subroutine
Emulated instructions (3/3)
-
8/11/2019 TI MSP430 Learning Materials
61/164
UBI
>> Contents61
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
In addition to the 27 CPU instructions, the following 24emulated instructions can also be used (continued):
Mnemonic Operation Emulation Description
Data instructions
CLR(.B or .W) dst 0dst MOV(.B or .W) #0,dst Clear destination
CLRC 0C BIC #1,SR Clear carry flag
CLRN 0N BIC #4,SR Clear negative flag
CLRZ 0Z BIC #2,SR Clear zero flag
POP(.B or .W) dst @SPtempSP+2SPtempdst
MOV(.B or .W) @SP+,dst Pop byte/word from stackto destination
SETC 1C BIS #1,SR Set carry flag
SETN 1N BIS #4,SR Set negative flagSETZ 1Z BIS #2,SR Set zero flag
TST(.B or .W) dst dst + 0FFFFh + 1dst + 0FFh + 1
CMP(.B or .W) #0,dst Test destination
Examples: Emulated instructions (1/6)
-
8/11/2019 TI MSP430 Learning Materials
62/164
UBI
>> Contents62
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Clear the contents of register R5:
CLR R5
Instruction code: 0x4305
This instruction is equivalent to using MOV R3, R5 where R3takes the value #0.
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 1 1 0 0 0 0 0 1 0 1MOV R3 Register 16 Bits Register R5
Examples: Emulated instructions (2/6)
-
8/11/2019 TI MSP430 Learning Materials
63/164
UBI
>> Contents 63Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Increment the content of register R5:
I NC R5
Instruction code: 0x5315
This instruction is equivalent to having ADD 0( R3) , R5 whereR3 takes the value #1.
Op-code S-reg Ad B/W As D-reg
0 1 0 1 0 0 1 1 0 0 0 1 0 1 0 1ADD R3 Register 16 Bits Indexed R5
Examples: Emulated instructions (3/6)
-
8/11/2019 TI MSP430 Learning Materials
64/164
UBI
>> Contents 64Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Decrement the contents of register R5:
DEC R5
Instruction code: 0x8315
This instruction is equivalent to using SUB 0( R3) , R5 whereR3 takes the value #1.
Op-code S-reg Ad B/W As D-reg
1 0 0 0 0 0 1 1 0 0 0 1 0 1 0 1
SUB R3 Register 16 Bits Indexed R5
Examples: Emulated instructions (4/6)
-
8/11/2019 TI MSP430 Learning Materials
65/164
UBI
>> Contents 65Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Decrement by two the contents of register R5:
DECD R5
Instruction code: 0x8325
This instruction is equivalent to using SUB @R3, R5 where R3points to the value #2.
Op-code S-reg Ad B/W As D-reg
1 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1
SUB R3 Register 16 Bits Indirect R5
Examples: Emulated instructions (5/6)
-
8/11/2019 TI MSP430 Learning Materials
66/164
UBI
>> Contents 66Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Do not carry out any operation:
NOP
Instruction code: 0x4303
This instruction is equivalent to using MOV R3, R3 and
therefore the contents of R3 are moved to itself.
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 1 1 0 0 0 0 0 0 1 1
MOV R3 Register 16 Bits Register R3
UBI
Examples: Emulated instructions (6/6)
-
8/11/2019 TI MSP430 Learning Materials
67/164
UBI
>> Contents 67Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Add the carry flag to the register R5:
ADC R5
Instruction code: 0x6305
This instruction is equivalent to using ADDC R3, R5 where R3takes the value #0.
Op-code S-reg Ad B/W As D-reg
0 1 1 0 0 0 1 1 0 0 0 0 0 1 0 1
ADDC R3 Register 16 Bits Register R5
UBI
Addressing modes (1/2)
-
8/11/2019 TI MSP430 Learning Materials
68/164
UBI
>> Contents 68Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
There are seven addressing modes that take a sourceoperand and four of these addressing modes also take adestination operand;
The operands can be located in any memory spaceaddress, but the user needs to be aware of the effectsthat their accesses may have;
The addressing modes are selected by the As and Adfields that make up the instruction;
The following table summarizes the seven addressingmodes:
-
8/11/2019 TI MSP430 Learning Materials
69/164
UBI
Register mode (1/3)
-
8/11/2019 TI MSP430 Learning Materials
70/164
UBI
>> Contents 70Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In Register addressing mode, the contents of a registeris used as the operand;
This type of addressing mode can be used both withsource and destination operands.
Move the contents of register R5 to register R4:
MOV R5,R4
Instruction code: 0x4504
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0MOV R5 Register 16-bit Register R4
UBI
Register mode (2/3)
-
8/11/2019 TI MSP430 Learning Materials
71/164
UBI
>> Contents 71Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the contents of register R5 to register R4
MOV R5,R4
Instruction code: 0x4504
The 16-bit contents (B/ W = 0) of register R5 (S-reg) aretransferred to the register R4 (D-reg);
After the instruction fetch, the PC is incremented by 2 andpoints to the next instruction to be executed;
The addressing mode used for the source and destinationoperands is determined by As = 00 (Register mode) andAd = 0 (Register mode), respectively.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0MOV R5 Register 16-bit Register R4
UBI
Register mode (3/3)
-
8/11/2019 TI MSP430 Learning Materials
72/164
UBI
>> Contents 72Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the contents of register R5 to register R4 (cont.):MOV R5,R4
Instruction code: 0x4504
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0MOV R5 Register 16-bit Register R4
UBI
Indexed mode (1/4)
-
8/11/2019 TI MSP430 Learning Materials
73/164
>> Contents 73Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In indexed mode, whether used to indicate the sourceaddress or the destination address, the sum of theregister contents and the signed offset point to thelocation in memory;
The offset value is stored in the word following theinstruction;
After the execution of the instruction, the contents ofregisters are not affected and the PC is incremented topoint to the next instruction to be executed;
This addressing mode is useful to access data stored intables. Apart from the registers PC and SR, all otherregisters can be used as an index in indexed mode.
UBI
Indexed mode (2/4)
-
8/11/2019 TI MSP430 Learning Materials
74/164
>> Contents 74Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the byte pointed to by (R5 + 4) to the byte pointedto by (R4 + 1):
MOV.B 4(R5),1(R4)
Instruction code: 0x45D4
The instruction coding specifies that the byte (B/ W = 1)
pointed to by the sum of the contents of register R5(S- r eg = 0101) and the word X1 should be moved to the
memory address pointed to by the sum of register R4(D- r eg = 0100) and the contents of the word X2;
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 1 1 0 1 0 1 0 0MOV R5 Indexed 8-bit Indexed R4
-
8/11/2019 TI MSP430 Learning Materials
75/164
UBI
Indexed mode (4/4)
-
8/11/2019 TI MSP430 Learning Materials
76/164
>> Contents 76Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the byte pointed to by (R5 + 4) to the byte pointedto by (R4 + 1) (continued):
MOV.B 4(R5),1(R4)
UBI
Symbolic mode (1/5)
-
8/11/2019 TI MSP430 Learning Materials
77/164
>> Contents 77Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In symbolic addressing mode, for either the source ordestination operands, the memory address is determinedby adding an offset to the program counter (PC) register;
The offset value is obtained by determining the codeposition in the memory, then calculating the differencebetween the offset address and the memory position thatshould be achieved;
The assembler determines the offset value and puts it inthe word following to the instruction;
After the execution of the instruction, the programcounter (PC) register is incremented in order to point tothe next instruction.
UBI
Symbolic mode (2/5)
-
8/11/2019 TI MSP430 Learning Materials
78/164
>> Contents 78Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Although this mode of address is similar to register modeit request more cycles, but in this case, the programcounter (PC) is used to point to the data;
This addressing mode can be used to determine eitherthe source or the destination of the data.
UBI
Symbolic mode (3/5)
-
8/11/2019 TI MSP430 Learning Materials
79/164
>> Contents 79Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by EDEN to the word pointed toby TONI:
MOV EDEN,TONI
Instruction code: 0x4090
The instruction coding specifies that the value pointed to bythe sum of the PC register contents (S- r eg = 0) and theword X1 should be moved to the memory address pointed to
by the sum of register PC contents (D- r eg = 0) and theword X2;
The words X1 and X2 are stored in the memory addresses
following the instruction.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0MOV PC Symbolic 16-bit Symbolic PC
UBI
Symbolic mode (4/5)
-
8/11/2019 TI MSP430 Learning Materials
80/164
>> Contents 80Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by EDEN to the word pointed toby TONI (continued):
MOV EDEN,TONI
Instruction code: 0x4090
The addressing mode used for the source and destinationoperands is controlled by the bits Ad = 1 (Symbolic mode)and As = 01 (Symbolic mode) because (D- r eg = 0000) and
(S- r eg = 0000), respectively.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0MOV PC Symbolic 16-bit Symbolic PC
UBI
Symbolic mode (5/5)
-
8/11/2019 TI MSP430 Learning Materials
81/164
>> Contents 81Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by EDEN to the word pointed toby TONI:
MOV EDEN,TONI
UBI
Absolute mode (1/4)
-
8/11/2019 TI MSP430 Learning Materials
82/164
>> Contents 82Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In Absolute mode, the data memory address is placedafter the instruction;
The difference between this addressing mode andIndexed mode is that the register R2 is now used as anindex, using the constants generator to generate thevalue zero;
This addressing mode can be used to define either thesource address or the destination address.
UBI
Absolute mode (2/4)
-
8/11/2019 TI MSP430 Learning Materials
83/164
>> Contents 83Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by EDEN to the word pointed toby TONI:
MOV &EDEN,&TONI
Instruction code: 0x4292
From the instruction coding it can be seen that the register
R2 has (S- r eg = 0010) and (D- r eg = 0010). Register R2 isused as an addresses index, in which the constant generatorloads the value zero;
When the contents of this register is added to the offset
value X1 or X2, the source and destination addresses areobtained;
The words X1 and X2 are stored in the memory addresses
following the instruction.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0MOV R2/CG1 Absolute 16-bit Absolute R2/CG1
UBI
Absolute mode (3/4)
-
8/11/2019 TI MSP430 Learning Materials
84/164
>> Contents 84Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by EDEN to the word pointed toby TONI (continued):
MOV &EDEN,&TONI
Instruction code: 0x4292
The addressing mode used for the source and destinationoperands is specified by the bits Ad = 1 (Absolute mode)and As = 01 (Absolute mode) because (D- r eg = 0010) and
(S- r eg = 0010), respectively.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 1 0 1 0 0 1 0 0 1 0MOV R2/CG1 Absolute 16-bit Absolute R2/CG1
-
8/11/2019 TI MSP430 Learning Materials
85/164
UBI
Indirect register mode (1/3)
-
8/11/2019 TI MSP430 Learning Materials
86/164
>> Contents 86
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In Indirect register mode, any of the 16 CPU registerscan be used. If R2 or R3 are used then a constant valueis used as an operand, #0x04 for R2 and #0x02 for R3;
A restriction arises from the fact that this addressingmode can only be used to specify the source operandaddress in dual-operand instructions;
An alternative way to avoid this restriction is to useindexed mode to specify the destination operand address,with a zero offset.
UBI
Indirect register mode (2/3)
h d i d b h d i d b
-
8/11/2019 TI MSP430 Learning Materials
87/164
>> Contents 87
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by R5 to the word pointed to byR4:
MOV @R5,0(R4)
Instruction code: 0x45A4
The instruction coding specifies that register R5(S- r eg = 0101) uses the source address (As = 10);
The destination address is pointed to in Indexed mode(Ad = 1) by R4 (D- r eg = 0100), using a zero value offset.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0MOV R5 Indexed 16-bit Indirect R4
UBI
Indirect register mode (3/3)
-
8/11/2019 TI MSP430 Learning Materials
88/164
>> Contents88
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by R5 to the word pointed toby R4 (continued):
MOV @R5,0(R4)
UBI
Indirect auto-increment mode (1/3)
Thi dd i d i i il t th i
-
8/11/2019 TI MSP430 Learning Materials
89/164
>> Contents89
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
This addressing mode is similar to the previous one;
The contents of source register is incremented accordingto the data type processed;
If the data value is byte, the source register isincremented by 1;
If the data value is a word, the source register isincremented by 2;
Note that this addressing mode can only be used tospecify the s o u r c e operand in dual-operand instructions.
UBI
Indirect auto-increment mode (2/3)
M th d i t d t b R5 t th d i t d t
-
8/11/2019 TI MSP430 Learning Materials
90/164
>> Contents90
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by R5 to the word pointed toby R4, and increment the source pointer:
MOV @R5+,0(R4)
Instruction code: 0x45B4
The instruction coding specifies that the register R5(S- r eg = 0101) contains the source address (As = 11);
The destination address is pointed to in indexed mode by R4
(D- r eg = 0100), using a zero value offset; The execution of the instruction increments the contents of
register R5 by 2.
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 1 0 1 1 0 1 0 0MOV R5 Indexed 16-bit Ind. aut. inc. R4
UBI
Indirect auto-increment mode (3/3)
Mo e the o d pointed to b R5 to the o d pointed to
-
8/11/2019 TI MSP430 Learning Materials
91/164
>> Contents91
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the word pointed to by R5 to the word pointed toby R4, and increment the source pointer (continued):
MOV @R5+,0(R4)
UBI
Immediate mode (1/2)
The Immediate addressing mode allows values to be
-
8/11/2019 TI MSP430 Learning Materials
92/164
>> Contents92
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
The Immediate addressing mode allows values to beloaded directly into registers or memory addresses. Itcan only be used with source operands.
Move the value 0x0200 to R5:
MOV #0x0200,R5
Instruction code: 0x4035
The instruction coding specifies that the register PC(S- r eg = 0000) is used to define the address of the word inmemory that loads the register R5 (D- r eg = 0101)with (As = 11).
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 1MOV PC Register 16-bit Immediate R5
UBI
Immediate mode (2/2)
Move the value 0x0200 to R5 (continued):
-
8/11/2019 TI MSP430 Learning Materials
93/164
>> Contents93
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Move the value 0x0200 to R5 (continued):
MOV 0x0200,R5
UBI
Instruction format in the MSP430X CPU(1/2)
There are three possibilities to choose between the
-
8/11/2019 TI MSP430 Learning Materials
94/164
>> Contents94
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
There are three possibilities to choose between theinstructions of the MSP430 CPU and MSP430X CPU:
Use only the MSP430 CPU instructions. The followingrules must be followed, with the exception of the
instructions CALLA/RETA, BRA:
Put all the data in memory below 64 kB and accessthe data using 16-bit pointers;
Place the routines at an address within the range
PC 32 kB;
No 20-bits data.
Use only the MSP430X CPU instructions. This causes a
reduction in the application execution speed and anincrease in the memory space occupied by the program;
Use an appropriate selection of the instruction types.
UBI
Instruction format in the MSP430X CPU (2/2)
The MSP430X CPU supports all functions of the MSP430
-
8/11/2019 TI MSP430 Learning Materials
95/164
>> Contents95
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
The MSP430X CPU supports all functions of the MSP430CPU;
It also offers a set of instructions that provide full accessto the 20-bit addressing space;
An additional op-code word is added to some of theinstructions. Therefore all addresses, indexes andimmediate numbers have 20 bits.
UBI
Extension word for register addressingmode (1/2)
In register mode the
-
8/11/2019 TI MSP430 Learning Materials
96/164
>> Contents
96
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In register mode, theextension word of aninstruction of format type I(two operands) or format
type II (single operand) iscoded as:
The description of each field:
UBI
Extension word for register addressingmode (1/2)
Unlike the MSP430, the MSP430X CPU supports the
-
8/11/2019 TI MSP430 Learning Materials
97/164
>> Contents
97
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Unlike the MSP430, the MSP430X CPU supports therepeated execution of the same instruction, providedthat the operands are of the register type;
The repetition is set by placing the repeat RPT instructionbefore the instruction to be executed;
The assembler incorporates information in the extensionword in the fields # (bit 7) and in the repetition counter(bits 3:0);
An example of this feature will be provided later.
UBI
Extension word for the other addressingmodes
In a non-register
-
8/11/2019 TI MSP430 Learning Materials
98/164
>> Contents
98
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
In a non registeraddressing mode, theextension word of aninstruction, whether
format I (doubleoperands) or format II(single operand), iscoded as:
The description of each
field:
UBI
Extended format I -Double operand-instructions
There are twelve extended instructions that use two
-
8/11/2019 TI MSP430 Learning Materials
99/164
>> Contents
99
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
There are twelve extended instructions that use twooperands:
UBI
Examples: Extended double operandinstructions (1/7)
Move the contents of register R5 to register R4:
-
8/11/2019 TI MSP430 Learning Materials
100/164
>> Contents
100
Copyright 2009 Texas Instruments
All Rights Reserved
www.ms 430.ubi. t
g g
MOVX R5,R4
Instruction code: 0x1840 0x4504
This instruction uses 2 words;
The instruction coding specifies that the CPU must performthe 16-bit data function MOVX, using the contents of the
source register R5 and the destination register R4.
0 0 0 1 1 0 0 ZC # A/L 0 0 n-1/Rn
0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0
MOVX R5 Register 16-bit Register R4
UBI
Examples: Extended double operandinstructions (2/7)
Move the contents of the register R5 to the memory
-
8/11/2019 TI MSP430 Learning Materials
101/164
>> Contents
101
Copyright 2009 Texas Instruments
All Rights Reservedwww.msp430.ubi.pt
g yaddress TONI:
MOVX R5,TONI
Instruction code: 0x184F 0x4580
This instruction uses 3 words;
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 1
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0
MOVX R5 Symbolic 16-bits Register PC
UBI
Examples: Extended double operandinstructions (3/7)
Move the contents of the register R5 to the memorydd TONI ( ti d)
-
8/11/2019 TI MSP430 Learning Materials
102/164
>> Contents
102
Copyright 2009 Texas Instruments
All Rights Reservedwww.msp430.ubi.pt
g yaddress TONI (continued):
MOVX R5,TONI
The instruction coding specifies that the CPU must performthe 16-bit data function MOVX, the source being the contentsof register R5 and the destination being the memory addresspointed to by (dst 19: 16: X1 + PC);
The bits dst 19: 16 is stored in the extension word and thevalue X1 is stored in the word following.
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 1
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0
MOVX R5 Symbolic 16-bits Register PC
UBI
Examples: Extended double operandinstructions (4/7)
Move the contents of the memory address TONI to
-
8/11/2019 TI MSP430 Learning Materials
103/164
>> Contents
103
Copyright 2009 Texas Instruments
All Rights Reservedwww.msp430.ubi.pt
register R5:
MOVX TONI,R5
Instruction code: 0x1FC0 0x4015
This instruction uses 3 words;
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1
MOVX PC Register 16-bit Symbolic R5
UBI
Examples: Extended double operandinstructions (5/7)
Move the contents of the memory address TONI toregister R5 (contin ed)
-
8/11/2019 TI MSP430 Learning Materials
104/164
>> Contents
104
Copyright 2009 Texas Instruments
All Rights Reservedwww.msp430.ubi.pt
register R5 (continued):
MOVX TONI,R5
The coding specifies that the CPU must perform the 16-bitdata function MOVX, the source being the contents of memoryaddress pointed to by (sr c 19: 16: X1 + PC) and thedestination being register R5;
The bits dst 19: 16 are stored in the extension word and thevalue X1 is stored in the word following.
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1
MOVX PC Register 16-bit Symbolic R5
UBI
Examples: Extended double operandinstructions (6/7)
Move the contents of the memory address TONI to thedd EDEN
-
8/11/2019 TI MSP430 Learning Materials
105/164
>> Contents
105
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
memory address EDEN:
MOVX TONI,EDEN
Instruction code: 0x1FCF 0x4090
This instruction uses 4 words;
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1
Op-code S-reg Ad B/W As D-reg0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0
MOVX PC Symbolic 16-Bit Symbolic PC
UBI
Examples: Extended double operandinstructions (7/7)
Move the contents of the memory address TONI to theaddress memory EDEN:
-
8/11/2019 TI MSP430 Learning Materials
106/164
>> Contents
106
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
address memory EDEN:
MOVX TONI,EDEN
The coding specifies that the CPU must perform the 16-bitdata function MOVX, the source being the contents of thememory address pointed to by (sr c 19: 16: X1 + PC) andthe destination being the contents of the memory address
pointed to by (dst 19: 16: X2 + PC); The bits sr c 19: 16 and dst 19: 16 are stored in the
extension word and the words X1 and X2 are stored in thewords following.
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0
MOVX PC Symbolic 16-Bit Symbolic PC
UBI
Extended format II - single operand-instructions (1/2)
Extended instructions using format II are:
-
8/11/2019 TI MSP430 Learning Materials
107/164
>> Contents
107
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
UBI
Extended format II - single operand-instructions (2/2)
The MSP430X CPU has some additional capabilities inaddition to those of the MSP430 CPU:
-
8/11/2019 TI MSP430 Learning Materials
108/164
>> Contents
108
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
addition to those of the MSP430 CPU:
The ability to push/pop several registers on/off the data
stack using only a single instruction;
The ability to rotate the contents of a register several timesduring the execution of a single instruction.
UBI
Examples: Extended single operandinstructions (1/4)
Rotate right the 20-bit contents of register R5 with thecarry flag:
-
8/11/2019 TI MSP430 Learning Materials
109/164
>> Contents
109
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
carry flag:
RRCX.A R5
Instruction code: 0x1800 0x1045
This instruction uses 2 words; The coding specifies that the CPU must perform the function
RRCX using the 20-bit data contents of register R5.
0 0 0 1 1 0 0 ZC # A/L 0 0 n-1/Rn
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0
Op-code B/W Ad D/S-reg0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1
RRCX 20-bit Register R5
UBI
Examples: Extended single operandinstructions (2/4)
Rotate right the 20-bit contents of the memory addressTONI with carry flag:
-
8/11/2019 TI MSP430 Learning Materials
110/164
>> Contents
110
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
TONI with carry flag:
RRCX.A TONI
Instruction code: 0x180F 0x1050
This instruction uses 3 words;
The coding specifies that the CPU must perform the functionRRCX using the 20-bit data contents of the memory addresspointed to by (dst 19: 16: X1 + PC);
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1
Op-code B/W Ad D/S-reg0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0
RRCX 20-bit Symbolic PC
UBI
Examples: Extended single operandinstructions (3/4)
Rotate right the 20-bit contents of the memory addressTONI with carry flag (continued):
-
8/11/2019 TI MSP430 Learning Materials
111/164
>> Contents
111
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
TONI with carry flag (continued):
RRCX.A TONI
Instruction code: 0x180F 0x1050
The bits dst 19: 16 are stored in the extension word and thevalue X1 is stored in the word following;
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1
Op-code B/W Ad D/S-reg0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0
RRCX 20-bit Symbolic PC
UBI
Examples: Extended single operandinstructions (4/4)
Rotate right the 20-bit contents of the memory addressTONI with carry flag (continued):
-
8/11/2019 TI MSP430 Learning Materials
112/164
>> Contents
112
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
TONI with carry flag (continued):
RRCX.A TONI
Because the instruction operand is located in memory ratherthan in a CPU register, two words are used to store theoperand. The format is shown in the figure below:
UBI
Exceptions to the representation of theextended Format II instructions (1/7)
Store the 20-bit registers R10, R9, R8:PUSHM.A #3,R10
-
8/11/2019 TI MSP430 Learning Materials
113/164
>> Contents
113
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
PUSHM.A #3,R10
The instructions PUSHMand POPMare coded according to the
structure given in the figure below:
Instruction code: 0x142A
This instruction uses 1 word;
The coding specifies that the CPU must perform the functionPUSHMof the 20-bit registers R10 to R8.
Op-code n - 1 D-reg
0 0 0 1 0 1 0 0 0 0 1 0 1 0 1 0
PUSHM.A #3 R10
UBI
Exceptions to the representation of theextended Format II instructions (2/7)
Rotate right three times the contents of the 20-bit registerR5 with the carry flag:
-
8/11/2019 TI MSP430 Learning Materials
114/164
>> Contents
114
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
R5 with the carry flag:
RRCM.A #3,R5
The instructions RRCM, RRAM, RRUMand RLAMare coded
according to the structure given in the figure below:
UBI
Exceptions to the representation of theextended Format II instructions (3/7)
Rotate right three times the content of the 20-bit registerR5 with the carry flag (continued):
-
8/11/2019 TI MSP430 Learning Materials
115/164
>> Contents
115
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
y g ( )
RRCM.A #3,R5
Instruction code: 0x0845
This instruction uses 1 word;
The coding specifies that the CPU must perform the functionRRCMusing the contents of the 20-bit register R5 a total of 3
times.
C n-1 Op-code R-reg
0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 1
#3 RRCM R5
UBI
Exceptions to the representation of theextended Format II instructions (4/7)
Perform a branch in the program flow:BRA R5
-
8/11/2019 TI MSP430 Learning Materials
116/164
>> Contents
116
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
BRA R5
This type of instruction can be coded in three differentformats, as shown in the figure below:
UBI
Exceptions to the representation of theextended Format II instructions (5/7)
Perform a branch in the program flow (continued):BRA R5
-
8/11/2019 TI MSP430 Learning Materials
117/164
>> Contents
117
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
BRA R5
Instruction code: 0x05C0
This instruction uses 1 word;
The coding specifies that the PC must be loaded with thevalue in register R5.
C R-reg Op-code 0(PC)
0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0
R5 BRA PC
UBI
Exceptions to the representation of theextended Format II instructions (6/7)
Call a routine:CALLA R5
-
8/11/2019 TI MSP430 Learning Materials
118/164
>> Contents
118
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
This type of instruction can be coded in three differentformats, as shown in the figure below:
UBI
Exceptions to the representation of theextended Format II instructions (7/7)
Call a routine (continued):CALLA R5
-
8/11/2019 TI MSP430 Learning Materials
119/164
>> Contents
119
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instruction code: 0x1345
This instruction uses 1 word;
The coding specifies that the PC must be loaded with thevalue in register R5;
The execution of this instruction saves the PC on the datastack, so the function can return at the end of execution ofthe routine.
Op-code D-reg
0 0 0 1 0 0 1 1 0 1 0 0 0 1 0 1
CALLA R5
UBI
Extended emulated instructions
The constant generator provide a set of extendedemulated instructions, as shown in the following table:
-
8/11/2019 TI MSP430 Learning Materials
120/164
>> Contents
120
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
UBI
MSP430X address instructions
Address instructions support 20-bit operands, but theyhave restrictions on the addressing modes they can use;
-
8/11/2019 TI MSP430 Learning Materials
121/164
>> Contents
121
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.ms 430.ubi. t
List of extended address instructions:
UBI
MSP430X CPU addressing modes
As with the MSP430 CPU, the MSP430X CPU supportsseven addressing modes for the source operand and fourdd i d f th d ti ti d
-
8/11/2019 TI MSP430 Learning Materials
122/164
>> Contents
122
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
addressing modes for the destination operand;
Both the MSP430 CPU and MSP430X CPU instructions canbe used throughout the 1 MB address space;
In the following sections we will explore the different
addressing modes available to the MSP430X CPU.
UBI
Register mode (1/3)
This addressing mode is identical to that of the MSP430CPU;
-
8/11/2019 TI MSP430 Learning Materials
123/164
>> Contents
123
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
There are three different types of access to the registers:
8-bit access (Byte operation);
16-bit access (Word operation);
20-bit access (Address-word).
The instruction SXT is the only exception, as the sign ofthe value is extended to the other bits of the register.
-
8/11/2019 TI MSP430 Learning Materials
124/164
UBI
Register mode (3/3)
Move the 20-bit contents of register R5 to register R4(continued):
MOVX A R5 R4
-
8/11/2019 TI MSP430 Learning Materials
125/164
>> Contents
125
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MOVX. A R5, R4
After the execution of the instruction, the PC is incrementedby 4 and pointed to the next instruction;
The addressing mode used for the source and destinationoperands is specified by Ad = 0 (Register mode) and
As = 00 (Register mode).
UBI
Indexed mode
Indexed mode can be used in three different situations:
-
8/11/2019 TI MSP430 Learning Materials
126/164
>> Contents
126
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Indexed mode in the memory address space below 64 kB;
Indexed mode in the memory address space above 64 kB;
Indexed mode using a MSP430X CPU instruction.
UBI
Indexed mode: below 64 kB (1/4)
Indexed mode in the memory address space below 64 kB:
If h CPU i R i dd l d
-
8/11/2019 TI MSP430 Learning Materials
127/164
>> Contents
127
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
If the CPU register Rn points to a memory address locatedbelow 64 kB, the address resulting from the sum of the index
and the register Rn has the value zero in bits 19:16.
This ensures that the address is always located in memorybelow 64 kB.
UBI
Indexed mode: below 64 kB (2/4)
Move the word pointed to by (R5 0x30) to the wordpointed to by (R4 + 2):
MOV 0XFFD0( R5) , 2( R4)
-
8/11/2019 TI MSP430 Learning Materials
128/164
>> Contents
128
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
( ) , ( )
Instruction code: 0x4594
This instruction uses 3 words;
The instruction coding specifies that the word (B/ W = 0)pointed to by the sum of register R5 contents (S- r eg = 0101)and the word X1 should be moved to the memory addresspointed to by the sum of the register R4 contents(D- r eg = 0100) and the word X2;
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 1 0 1 1 0 0 1 0 1 0 0
MOV R5 Indexed 16-bit Indexed R4
UBI
Indexed mode: below 64 kB (3/4)
Move the word pointed to by (R5 0x30) to the wordpointed to by (R4 + 2) (continued):
MOV 0XFFD0( R5) 2( R4)
-
8/11/2019 TI MSP430 Learning Materials
129/164
>> Contents
129
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MOV 0XFFD0( R5) , 2( R4)
The words X1 and X2 are located in the memory addressesfollowing the instruction;
The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Indexed mode) andAs = 01 (Indexed mode), because D- r eg = 0100 andS- r eg = 0101 respectively;
In this example, bits 19:16 are set to zero when the operandaddresses are calculated.
UBI
Indexed mode: below 64 kB (4/4)
Move the word pointed to by (R5 0x30) to the wordpointed to by (R4 + 2) (continued):
MOV 0XFFD0( R5) 2( R4)
-
8/11/2019 TI MSP430 Learning Materials
130/164
>> Contents
130
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
MOV 0XFFD0( R5) , 2( R4)
UBI
Indexed mode: above 64 kB (1/2)
Indexed mode in the memory address space above 64 kB:
If the CPU register Rn points to a memory address above 64
-
8/11/2019 TI MSP430 Learning Materials
131/164
>> Contents
131
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
If the CPU register Rn points to a memory address above 64kB, bits 19:16 are used to calculate the operand of the
address;
A prerequisite is that the operand must be located in therange Rn 32KB, because the index is a signed 16-bit value;
Outside this range, the operand address can overflow orunderflow the memory address space below or above the64 kB.
If the registers now point to a memory address space above64 kB, bits 19:16 are used to determine the address in theoperands.
UBI
Indexed mode: above 64 kB (2/2)
Indexed mode in the memory address space above 64 kB(continued):
-
8/11/2019 TI MSP430 Learning Materials
132/164
>> Contents
132
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
UBI
Indexed mode: MSP430X CPU (1/4)
Indexed mode using a MSP430X CPU instruction:
When a MSP430X CPU instruction is used in indexed mode
-
8/11/2019 TI MSP430 Learning Materials
133/164
>> Contents
133
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
When a MSP430X CPU instruction is used in indexed mode,the operand can reside anywhere in the range of addresses
Rn 19 bits;
The operand address is calculated from the sum of the 20-bitcontents of the register Rn and the signed 20-bit index.
UBI
Indexed mode: MSP430X (2/4)
Move the word pointed to by (R5 0x30) to the wordpointed to by (R4 + 2):
MOVX 0xFFFD0( R5) , 2( R4)
-
8/11/2019 TI MSP430 Learning Materials
134/164
>> Contents
134
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
( ) ( )
Instruction code: 0x1FC0 0x4594
This instruction uses 4 words;
0 0 0 1 1 src 19:16 A/L 0 0 dst 19:16
0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0
Op-code S-reg Ad B/W As D-reg1 0 0 0 0 1 0 1 1 0 0 1 0 1 0 0
MOVX R5 Indexed 16-bit Indexed R4
UBI
Indexed mode: MSP430X CPU (3/4)
Move the word pointed to by (R5 0x30) to the wordpointed to by (R4 + 2) (continued):MOVX 0xFFFD0( R5) , 2( R4)
-
8/11/2019 TI MSP430 Learning Materials
135/164
>> Contents
135
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
The instruction coding specifies that the word (B/ W = 0 andA/ L = 1) pointed to by the sum of register R5 contents(S- r eg = 0101) and the word X1 should be moved to thememory address pointed to by the sum of the register R4contents (D- r eg = 0100) and the word X2;
The four MSB indices are placed in the extension word of theinstruction and the other 16 bits are placed in the wordsfollowing the instruction;
The addressing mode used for the source and destinationoperands is specified by the bits Ad = 1 (Indexed mode) andAs = 01 (Indexed mode), because D- r eg = 0100 andS- r eg = 0101 respectively.
-
8/11/2019 TI MSP430 Learning Materials
136/164
UBI
Symbolic mode
The symbolic addressing mode uses the register PC todetermine the location of the operand based on an index;
-
8/11/2019 TI MSP430 Learning Materials
137/164
>> Contents137
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Similar to the previous addressing mode, there are threedifferent ways to use symbolic mode with the MSP30XCPU.
Symbolic mode in the memory address space below 64 kB;
Symbolic mode in the memory address space above 64 kB;
Symbolic mode using a MSP430X CPU instruction.
UBI
Symbolic mode: below 64 kB (1/3)
As in the indexed addressing mode, if the PC registerpoints to a memory address below 64 kB, the bits 19:16of the address calculated from the sum of the PC register
d th i d 16 bit i d t t
-
8/11/2019 TI MSP430 Learning Materials
138/164
>> Contents138
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
and the signed 16-bit index are set to zero.
Move the contents of the address EDEN located at0x00200 to the address TONI located at 0x00202:
MOV EDEN, TONI
Instruction code: 0x4090
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0
MOV PC Symbolic 16-bit Symbolic PC
UBI
Symbolic mode: below 64 kB (2/3)
Move the contents of the address EDEN located at0x00200 to the address TONI located at 0x00202 (cont.):MOV EDEN, TONI
-
8/11/2019 TI MSP430 Learning Materials
139/164
>> Contents139
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
This instruction uses 3 words;
The instruction decoding specifies that the word (B/ W = 0)pointed to by the sum of the register PC contents(S- r eg = 0000) and the word X1 should be moved to thememory address pointed to by the sum of the register PC
contents (D- r eg = 0000) and the word X2; The words X1 and X2 are stored in the memory addresses
following the instruction;
The addressing mode used for the source and destinationoperands is specified by the bits Ad = 1 (Symbolic mode)
and As = 01 (Symbolic mode), because D- r eg = 0000 andS- r eg = 0000, respectively.
UBI
Symbolic mode: below 64 kB (3/3)
Move the contents of address the EDEN located at0x00200 to the address TONI located at 0x00202 (cont.):
MOV EDEN, TONI
-
8/11/2019 TI MSP430 Learning Materials
140/164
>> Contents140
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
UBI
Symbolic mode: above 64 kB (1/4)
If the PC register points to a memory address above 64kB, bits 19:16 of the PC are used to calculate the operandaddress;
-
8/11/2019 TI MSP430 Learning Materials
141/164
>> Contents141
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
The operand must be located in the memory rangePC 32 kB, because the index is a signed 16-bit value;
If outside this range, there may be an overflow or
underflow in the address space corresponding to memorybelow 64 kB.
UBI
Symbolic mode: above 64 kB (2/4)
Move the contents of the address EDEN located at0x10200 to register R5:
MOV EDEN, R5
-
8/11/2019 TI MSP430 Learning Materials
142/164
>> Contents142
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
Instruction code: 0x4015
This instruction uses 2 words;
The instruction coding specifies that the word (B/ W = 0)
pointed to by the sum of the register PC contents(S- r eg = 0000) and the word X1 should be moved to theregister R5 (D- r eg = 0101);
Op-code S-reg Ad B/W As D-reg
0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1
MOV PC Register 16-bit Symbolic R5
UBI
Symbolic mode: above 64 kB (3/4)
Move the contents of the address EDEN located at0x10200 to register R5 (continued):
MOV EDEN, R5
-
8/11/2019 TI MSP430 Learning Materials
143/164
>> Contents143
Copyright 2009 Texas InstrumentsAll Rights Reserved
www.msp430.ubi.pt
The word X1 is in the memory address following theinstruction;
The addressing mode used for the source and destination
operands is specified by the bits Ad = 0 (Register mode) andAs = 01 (Symbolic mode), because D- r eg = 0101 andS- r eg = 0000, respectively.
UBI
Symbolic mode: above 64 kB (4/4)
Move the contents of the address EDEN located at0x10200 to register R5 (continued):
MOV EDEN, R5
-
8/11/2019 TI MSP430 Learning Materials
144/164
>> Contents144
Copyright 2009 Texas Ins