MSP430 Teaching Materials
UBI
Lecture 2
MSP430 Architecture
Texas Instruments Incorporated
University of Beira Interior (PT)
Pedro Dinis Gaspar, António Espírito Santo, Bruno Ribeiro, Humberto Santos
University of Beira Interior, Electromechanical Engineering Department
www.msp430.ubi.pt
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
Contents (1/3)
UBI
 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
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
2
Contents (2/3)
UBI
 Exploring the addressing modes of the MSP430
architecture:
 Instruction format:
•
•
•
•
Instruction format I: Double operand
Instruction format II: Single operand
Jump instructions format
Emulated instructions
 Addressing modes:
•
•
•
•
•
•
•
>> Contents
Register mode
Indexed mode
Symbolic mode
Absolute mode
Indirect register mode
Indirect auto-increment mode
Immediate mode
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
3
Contents (3/3)
UBI
 Exploring the addressing modes of the MSP430X
architecture:
 Instruction format in the MSP430X CPU
 Exceptions to the representation of the extended Format II
instructions
 Extended emulated instructions
 MSP430X address instructions
 MSP430X CPU addressing modes
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
4
Introduction
UBI
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
5
Microcontroller characteristics
UBI
 Integration: Able to implement a whole design onto a single
chip.
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
6
MSP430 main characteristics (1/3)
UBI
 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).
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
7
MSP430 main characteristics (2/3)
UBI
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
8
MSP430 main characteristics (3/3)
UBI
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
9
MSP430 Architecture
UBI
 Block diagram:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
10
Address Space
UBI
 Mapped into a single, contiguous address space:
 Flash/ROM: All code, tables, and hard-coded constants
reside in this memory space.
 Information memory: Variables needed for the next
power up can be stored here during power down. It can also
be 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 onchip peripheral registers that are mapped into the address
space.
 Special Function Registers (SFRs): Some peripheral
functions are mapped into memory with special dedicated
functions.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
11
Memory Map
UBI
Memory Address
0FFFFh
End:
Start:
0FFE0h
End:
0FFDFh
Description
Interrupt Vector Table
Flash/ROM
Start *:
End *:
Start:
End:
Start:
End *:
Start:
End:
Start:
End:
Start:
End:
Start:
>> Contents
0F800h
01100h
010FFh
0107Fh
01000h
0FFFh
0C00h
09FFh
027Fh
0200h
01FFh
0100h
00FFh
0010h
000Fh
0000h
Access
Word/Byte
Word/Byte
Information Memory
(Flash devices only)
Boot Memory
(Flash devices only)
Word/Byte
RAM
Word/Byte
Word/Byte
16-bit Peripheral modules
Word
8-bit Peripheral modules
Byte
Special Function Registers
Byte
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
12
Interrupt vector table
UBI
 Mapped at the very end of memory space (upper 16
words of Flash/ROM): 0FFE0h - 0FFFEh (4xx devices);
 Priority of the interrupt vector increases with the word
address.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
13
Central Processing Unit (MSP430 CPU) (1/7)
UBI
 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 Neumann
architecture:
• 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).
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
14
Central Processing Unit (MSP430 CPU) (2/7)
UBI
 RISC (Reduced Instructions Set Computing) type
architecture:
 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 (including
RAM + Flash + Registers);
 Arithmetic Logic Unit (ALU):
 Addition, subtraction, comparison and logical (AND, OR,
XOR) operations;
 Operations can affect the overflow, zero, negative, and carry
flags of the SR (Status Register).
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
15
Central Processing Unit (MSP430 CPU) (3/7)
UBI
 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 and
executed 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 subroutine
parameters (PUSH, POP in calling routine; addressed via offset
calculation on stack pointer (SP) in called subroutine);
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
16
Central Processing Unit (MSP430 CPU) (4/7)
UBI
 R1: Stack Pointer (SP) (continued):
 3rd: used by subroutine calls to store the program counter
value for return at subroutine's end (RET);
 4th: used by interrupt - system stores the actual PC value
first, 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 none
has changed the value on TOS) and the same program
counter value from stack.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
17
Central Processing Unit (MSP430 CPU) (5/7)
UBI
 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
Reserved for CG1
Bit
7
V
6
SCG1
SCG0
5
OSCOFF
4
CPUOFF
3
GIE
2
N
1
Z
0
C
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
4
CPUOFF
CPU off. CPUOFF = 1
3
GIE
General interrupt enable. GIE = 1
2
N
Negative flag. N = 1

1
Z
Zero flag. Z = 1
result of a byte or word operation is 0.
0
C
Carry flag. C = 1
>> Contents




turns off LFXT1 when it is not used for MCLK or SMCLK
disable CPU core.

enables maskable interrupts.
result of a byte or word operation is negative.
result of a byte or word operation produced a carry.
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
18
Central Processing Unit (MSP430 CPU) (6/7)
UBI
 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 the
implementation 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
(0)
R2
01
10
00004h
Absolute mode
+4, bit processing
R2
11
00008h
+8, bit processing
R3
00000h
R3
R3
00
01
10
00001h
00002h
0, word processing
+1
+2, bit processing
R3
11
0FFFFh
-1, word processing
>> Contents
Copyright 2008
2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
19
Central Processing Unit (MSP430 CPU) (7/7)
UBI
 R4 - R15: General–Purpose Registers:
 These general-purpose registers are adequate to store data
registers, address pointers, or index values and can be
accessed with byte or word instructions.
>> Contents
Copyright 2008
2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
20
UBI
Central Processing Unit (MSP430X CPU)
(1/10)
 Main features of the MSP430X CPU architecture:
 The MSP430X CPU extends the addressing capabilities of the
MSP430 family beyond 64 kB to 1 MB;
 To achieve this, some changes have been made to the
addressing modes and two new types of instructions have
been added;
 One instruction type allows access to the entire address
space, and the other is designed for address calculations;
 The MSP430X CPU address bus has 20 bits, although the
data bus still has 16 bits. Memory accesses to 8-bit, 16-bit
and 20-bit data are supported;
 Despite these changes, the MSP430X CPU remains
compatible with the MSP430 CPU, having a similar number
of registers.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
21
UBI
Central Processing Unit (MSP430X CPU)
(2/10)
 Organization of the MSP430X CPU:
 Although the MSP430X CPU structure is
similar to that of the MSP430 CPU, there
are some differences that will now be
highlighted;
 With the exception of the status register
SR, all MSP430X registers are 20 bits;
 The CPU can now process 20-bit or 16bit data.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
22
UBI
Central Processing Unit (MSP430X CPU)
(3/10)
 The MSP430X CPU has 16 registers, some of which have
special 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 it
has 20 bits.
 R2 (SR) Status Register:
 Has the same function as the MSP430 CPU, but it still has 16
bits.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
23
UBI
Central Processing Unit (MSP430X CPU)
(4/10)
 R2 (SR) Status Register:
 Description of the SR bits:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
24
UBI
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 different
constants 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 of
the instruction. (As) selects the addressing mode.
 Values of constants
generated:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
25
UBI
Central Processing Unit (MSP430X CPU)
(6/10)
 R2 (SR/CG1) and R3 (CG2) Constant Generators:
 Whenever the operand is one of the six constants, the
registers are selected automatically;
 Therefore, when used in constant mode, registers R2 and R3
cannot be used as source registers.
 R4-R15 – General-purpose registers:
 Have the same function as in the MSP430 CPU, although
they 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 to
one of these registers it takes bits 15:0, the bits 19:16 are
filled with zeroes.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
26
UBI
Central Processing Unit (MSP430X CPU)
(7/10)
 R4-R15 – General-purpose registers:
 Handling byte data (8 bits) using the suffix .B:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
27
UBI
Central Processing Unit (MSP430X CPU)
(8/10)
 R4-R15 – General-purpose registers:
 Handling word data (16 bits) using the suffix .W:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
28
UBI
Central Processing Unit (MSP430X CPU)
(9/10)
 R4-R15 – General-purpose registers:
 Manipulation of a 20-bit address using the suffix .A:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
29
Addressing modes
UBI
 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 addressing
modes can be emulated.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
30
Instruction set
UBI
 27 core instructions;
 24 emulated instructions;
 The instruction set is orthogonal;
 The core instructions have unique opcodes decoded by
the CPU, while the emulated ones need assemblers and
compilers for their mnemonics;
 There are three core-instruction formats:
 Double operand;
 Single operand;
 Program flow control - Jump.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
31
Exploring the addressing modes of the
MSP430 architecture (1/11)
UBI
 The MSP430 architecture:
 The MSP430 CPU incorporates features specifically designed
to allow the use of modern programming techniques, such
as:
• The computation of jump addresses;
• Data processing in tables;
• The use of high-level languages such as C.
 The whole memory space can be addressed by the MSP430
CPU, without needing paging, using seven different
addressing modes.
 The MSP430 CPU has a set of 27 instructions that can be
used with any of the addressing modes.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
32
Exploring the addressing modes of the
MSP430 architecture (2/11)
UBI
 Organization of the MSP430 CPU:
 16-bit address bus (MAB) and 16-bit
data bus (MDB).
 Both registers and memory can be
accessed either in word format or in byte
format.
 Allows the direct transfer of data
between memory, without passing
through the registers.
 The 16-bit registers can be accessed
directly through the instructions, some
of which run in a single clock cycle.
 Some of the constants most used in
programming can be obtained from the
constant generator.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
33
Exploring the addressing modes of the
MSP430 architecture (3/11)
UBI
 Organization of the MSP430 CPU
(continued):
 The architecture has a 16 bit Arithmetic
Logic Unit (ALU).
 Carrying out operations affects the state
of the following flags:
• Zero (Z);
• Carry (C);
• Overflow (V);
• Negative (N).
 The MCLK (Master) clock signal drives
the CPU.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
34
Exploring the addressing modes of the
MSP430 architecture (4/11)
UBI
 The MSP430 CPU has 16 registers, some of which are
dedicated to special use:
 R0 (PC) (Program Counter):
 This register always points to the next instruction to be
fetched;
 Each instruction occupies an even number of bytes.
Therefore, the least significant bit (LSB) of the PC register is
always zero;
 After fetch of an instruction, the PC register is incremented
to point to the next instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
35
Exploring the addressing modes of the
MSP430 architecture (5/11)
UBI
 R1 (SP) Stack Pointer:
 This register is used by the MSP430 CPU to store the return
address of routines or interrupts;
 Each time the data stack is accessed, the SP is incremented
or decremented automatically;
 The user should be careful to initialise the SP register with
the valid address of the data stack in RAM;
 The stack pointer SP always points to an even address, so
its LSB is always zero.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
36
Exploring the addressing modes of the
MSP430 architecture (6/11)
UBI
 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 register
addressing mode;
 All other addressing modes are reserved to support the
constants generator;
 The organization of the individual bits of register R2 is
shown in the following figure:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
37
Exploring the addressing modes of the
MSP430 architecture (7/11)
UBI
 R2 – SR/CG1 & R3 – CG2 (Status Register):
15
14
13
12
11
10
9
8
Reserved for CG1
Bit
8
V
7
6
SCG1
SCG0
5
OSCOFF
4
CPUOFF
3
GIE
2
N
V
Description
Overflow bit.
SCG1
V = 1  Result of an arithmetic operation overflows the signed-variable range.
System clock generator 1.
6
SCG0
SCG1 = 1  DCO generator is turned off – if not used for MCLK or SMCLK
System clock generator 0.
5
OSCOFF
SCG0 = 1 
Oscillator Off.
CPUOFF
OSCOFF = 1
CPU off.
GIE
CPUOFF = 1  disable CPU core.
General Interrupt Enable.
2
N
GIE = 1  enables maskable interrupts.
Negative flag.
1
Z
N=1

Zero flag.
result of a byte or word operation is negative.
C
Z=1

Carry flag.
result of a byte or word operation is 0.
C=1
result of a byte or word operation produced a carry.
7
4
3
0
>> Contents

1
Z
C
FLL+ loop control is turned off

turns off LFXT1 when it is not used for MCLK or SMCLK
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
0
38
Exploring the addressing modes of the
MSP430 architecture (8/11)
UBI
 R2 – SR/CG1 & R3 – CG2 (Constant Generators):
 Six different constants commonly used in programming can
be 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
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
+1
R3
10
00002h
+2, bit processing
R3
11
0FFFFh
-1, word processing
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
39
Exploring the addressing modes of the
MSP430 architecture (9/11)
UBI
 R4-R15: General-purpose registers:
 The general purpose registers R4 to
R15 can be used as data registers,
data pointers and indices. They can
be accessed either as a byte or as a
word;
 These registers support operations
on words or bytes;
 In the example to the right, the
contents of the least significant byte
of register R5 (0x8F) is added to the
contents of the memory address
pointed to by the register R6 (0x12h);
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
40
Exploring the addressing modes of the
MSP430 architecture (10/11)
UBI
 R4-R15: General-purpose registers:
 The contents of the memory address
is updated with the result of the
operation (0xA1);
 The status flags of the CPU in the SR
are updated after the execution of
the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
41
Exploring the addressing modes of the
MSP430 architecture (11/11)
UBI
 R4-R15: General-purpose registers:
 The contents of the memory address
pointed to by R6 (0x5F) is added to
the contents of the least significant
byte of register R5 (0x02);
 The result of the operation (0x61) is
stored in the least significant byte of
register R5;
 Meanwhile, the most significant byte
of register R5 is set to zero;
 The system flags in SR are updated
in accordance with the result.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
42
Instructions format (1/4)
UBI
 In addition to the 27 instructions of the CPU there are 24
emulated instructions;
 The CPU coding is unique;
 The emulated instructions make reading and writing
code more easy, but do not have their own op-codes;
 Emulated instructions are replaced automatically by
instructions 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
43
Instructions format (2/4)
UBI
 The instructions for double and single operands, depend
on the suffix used, (.W) word or (.B) byte.
 These suffixes allow word or byte data access;
 If the suffix is ignored, the instruction processes word
data by default.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
44
Instructions format (3/4)
UBI
 The source and destination of the data operated by an
instruction 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 used
by the destination operand;
 D-reg: register used by the destination operand;
 B/W: word or byte access definition bit.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
45
Instructions format (4/4)
UBI
 While all addresses within the address space are valid, it
is the responsibility of the user to check that the type of
access is valid.
 Example: the contents of the flash memory can be used
as a source operand, but can only be written to in certain
conditions.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
46
Instruction format I: Double operand
UBI
 Organization of instructions with two operands:
15
14
13
12
11
10
Op-code
9
S-Reg
8
7
6
Ad
B/W
5
4
3
As
2
1
0
D-Reg
 Double operand instructions:
Mnemonic
Operation
Description
ADD(.B or .W) src,dst
src+dstdst
Add source to destination
ADDC(.B or .W) src,dst
src+dst+Cdst
Add source and carry to destination
DADD(.B or .W) src,dst
src+dst+Cdst (dec)
Decimal add source and carry to destination
SUB(.B or .W) src,dst
dst+.not.src+1dst
Subtract source from destination
SUBC(.B or .W) src,dst
dst+.not.src+Cdst
Subtract source and not carry from destination
AND(.B or .W) src,dst
src.and.dstdst
AND source with destination
BIC(.B or .W) src,dst
.not.src.and.dstdst
Clear bits in destination
BIS(.B or .W) src,dst
src.or.dstdst
Set bits in destination
BIT(.B or .W) src,dst
src.and.dst
Test bits in destination
XOR(.B or .W) src,dst
src.xor.dstdst
XOR source with destination
CMP(.B or .W) src,dst
dst-src
Compare source to destination
MOV(.B or .W) src,dst
srcdst
Move source to destination
Arithmetic instructions
Logical and register control instructions
Data instructions
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
47
Examples: double operand (1/3)
UBI
 Move the contents of register R5 to register R4:
MOV R5,R4
 Instruction code: 0x4504
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
0
0
00
0100
MOV
R5
Register
16-Bits
Register
R4
 This instruction uses 1 word;
 The instruction coding specifies that the CPU must perform a
16-bit data MOV instruction, with the contents of register R5
as the source and with register R4 as the destination.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
48
Examples: double operand (2/3)
UBI
 Move the contents of register R5 to the address in
memory TONI:
MOV R5,TONI
 Instruction code: 0x4580
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
00
0000
MOV
R5
Symbolic
16 Bits
Register
PC
 This instruction uses 2 words;
 The instruction coding specifies that the CPU must perform a
16-bit data MOV instruction using the contents of register R5
to the memory address pointed to by X1 + PC;
 The word X1 is stored in the word following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
49
Examples: double operand (3/3)
UBI
 Move the contents between the memory addresses EDEN
and TONI:
MOV EDEN,TONI
 Instruction code: 0x4090
Op-code
0100
MOV
S-reg
0000
PC
Ad
1
Symbolic
B/W
0
16-Bits
As
01
Symbolic
D-reg
0000
PC
 This instruction uses 3 words;
 The instruction coding specifies that the CPU must perform a
16-bit data MOV instruction using the contents of the EDEN
memory address pointed to by X1 + PC to the TONI memory
address pointed to by X2 + PC;
 The word X1 followed by the word X2 are stored after the
instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
50
Instruction format II: Single operand
UBI
 The instructions with one operand are coded using the
following structure:
15
14
13
12
11
10
9
8
7
Op-code
6
5
B/W
4
3
Ad
2
1
0
D/S-Reg
 Single operand instructions:
Mnemonic
Operation
Description
Logical and register control instructions
RRA(.B or .W) dst
MSBMSB…LSBC
Roll destination right
RRC(.B or .W) dst
CMSB…LSBC
Roll destination right through (from) carry
SWPB( or .W) dst
Swap bytes
Swap bytes in destination
SXT dst
bit 7bit 8…bit 15
Sign extend destination
PUSH(.B or .W) src
SP-2SP, src@SP
Push source on stack
Program flow control instructions
CALL(.B or .W) dst
SP-2SP, PC+2@SP
dstPC
Subroutine call to destination
RETI
TOSSR, SP+2SP
TOSPC, SP+2SP
Return from interrupt
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
51
Examples: single operand (1/2)
UBI
 Move the contents of register R5 to the right with carry
flag:
RRC
R5
 Instruction code: 0x1005
Op-code
B/W
Ad
D-reg
000100000
0
00
0101
RRC
16 bits
Register
R5
 This instruction uses 1 word;
 The instruction coding specifies that the CPU must perform a
16-bit data RRC instruction using the contents of register R5.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
52
Examples: single operand (2/2)
UBI
 Rotate the contents of memory TONI to the right with
carry flag:
RRC
TONI
 Instruction code: 0x1010
Op-code
B/W
Ad
D-reg
000100000
0
01
0000
RRC
16 bits
Symbolic
PC
 This instruction uses 2 words;
 The instruction coding specifies that the CPU must perform a
16-bit data RRC instruction pointed to by X1 + PC;
 Word X1 is stored in the word following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
53
Jump instructions format (1/3)
UBI
 These instructions are used to direct program flow to
another part of the program.
15
14
13
12
Op-code
Mnemonic
11
10
9
8
7
C
6
5
4
3
2
1
10 bit PC offset
Description
Program flow control instructions
JEQ/JZ label
Jump to label if zero flag is set
JNE/JNZ label
Jump to label if zero flag is reset
JC label
Jump to label if carry flag is set
JNC label
Jump to label if carry flag is reset
JN label
Jump to label if negative flag is set
JGE label
Jump to label if greater than or equal
JL label
Jump to label if less than
JMP label
Jump to label unconditionally
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
54
0
Jump instructions format (2/3)
UBI
 The op-code always takes the value 001b, indicating that
it is a jump instruction;
 The condition on which a jump occurs depends on the C
field consisting of 3 bits, and may take the following
values:
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
55
Jump instructions format (3/3)
UBI
 The jumps are executed based on the PC contents, are
controlled by the status bits, but do not affect the status
bits;
 The jump off-set is represented by a signed 10-bit value:
PC new  PC old  2  PC offset  2
 The range of the jump can be between -511 to +512
words, in relation to the PC position.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
56
Examples: jump format (1/2)
UBI
 Continue execution at the label main if the carry flag is
active:
JC
main
 Instruction code: 0x2FE4
Op-code
C
10-Bit PC offset
001
011
1111100100
JC
Carry = 1
– 0x1C
 This instruction uses 1 word;
 The instruction coding specifies that the PC must be loaded
with the value resulting from the offset - 0x1C being applied
to the previous expression.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
57
Examples: jump format (2/2)
UBI
 Continue to unconditionally execute code at the label
main:
JMP
main
 Instruction code: 0x3FE3
Op-code
C
10-Bit PC offset
001
111
1111100011
JMP
unconditional
– 0x1D
 This instruction uses 1 word;
 The instruction coding specifies that the PC must be loaded
with the value resulting from the offset - 0x1D being applied
to the previous expression.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
58
Emulated instructions (1/3)
UBI
 In addition to the 27 CPU instructions, the following 24
emulated instructions can also be used:
Mnemonic
Operation
Emulation
Description
ADC(.B or .W) dst
dst+Cdst
ADDC(.B or .W) #0,dst
Add carry to destination
DADC(.B or .W) dst
dst+Cdst (decimally)
DADD(.B or .W) #0,dst
Decimal add carry to
destination
DEC(.B or .W) dst
dst-1dst
SUB(.B or .W) #1,dst
Decrement destination
DECD(.B or .W) dst
dst-2dst
SUB(.B or .W) #2,dst
Decrement destination twice
INC(.B or .W) dst
dst+1dst
ADD(.B or .W) #1,dst
Increment destination
INCD(.B or .W) dst
dst+2dst
ADD(.B or .W) #2,dst
Increment destination twice
SBC(.B or .W) dst
dst+0FFFFh+Cdst
dst+0FFhdst
SUBC(.B or .W) #0,dst
Subtract source and borrow
/.NOT. carry from dest.
Arithmetic instructions
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
59
Emulated instructions (2/3)
UBI
 In addition to the 27 CPU instructions, the following 24
emulated instructions can also be used (continued):
Mnemonic
Operation
Emulation
Description
Logical and register control instructions
INV(.B or .W) dst
.NOT.dstdst
XOR(.B or .W) #0(FF)FFh,dst
Invert bits in destination
RLA(.B or .W) dst
CMSBMSB1…LSB+1LSB0
ADD(.B or .W) dst,dst
Rotate left arithmetically
RLC(.B or .W) dst
CMSBMSB1…LSB+1LSBC
ADDC(.B or .W) dst,dst
Rotate left through carry
Program flow control
BR dst
dstPC
MOV dst,PC
Branch to destination
DINT
0GIE
BIC #8,SR
Disable (general)
interrupts
EINT
1GIE
BIS #8,SR
Enable (general) interrupts
NOP
None
MOV #0,R3
No operation
RET
@SPPC
SP+2SP
MOV @SP+,PC
Return from subroutine
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
60
Emulated instructions (3/3)
UBI
 In addition to the 27 CPU instructions, the following 24
emulated instructions can also be used (continued):
Mnemonic
Operation
Emulation
Description
CLR(.B or .W) dst
0dst
MOV(.B or .W) #0,dst
Clear destination
CLRC
0C
BIC #1,SR
Clear carry flag
CLRN
0N
BIC #4,SR
Clear negative flag
CLRZ
0Z
BIC #2,SR
Clear zero flag
POP(.B or .W) dst
@SPtemp
SP+2SP
tempdst
MOV(.B or .W) @SP+,dst
Pop byte/word from stack
to destination
SETC
1C
BIS #1,SR
Set carry flag
SETN
1N
BIS #4,SR
Set negative flag
SETZ
1Z
BIS #2,SR
Set zero flag
TST(.B or .W) dst
dst + 0FFFFh + 1
dst + 0FFh + 1
CMP(.B or .W) #0,dst
Test destination
Data instructions
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
61
Examples: Emulated instructions (1/6)
UBI
 Clear the contents of register R5:
CLR R5
 Instruction code: 0x4305
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0011
0
0
00
0101
MOV
R3
Register
16 Bits
Register
R5
 This instruction is equivalent to using MOV R3, R5 where R3
takes the value #0.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
62
Examples: Emulated instructions (2/6)
UBI
 Increment the content of register R5:
INC R5
 Instruction code: 0x5315
Op-code
S-reg
Ad
B/W
As
D-reg
0101
0011
0
0
01
0101
ADD
R3
Register
16 Bits
Indexed
R5
 This instruction is equivalent to having ADD 0(R3),R5 where
R3 takes the value #1.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
63
Examples: Emulated instructions (3/6)
UBI
 Decrement the contents of register R5:
DEC R5
 Instruction code: 0x8315
Op-code
S-reg
Ad
B/W
As
D-reg
1000
0011
0
0
01
0101
SUB
R3
Register
16 Bits
Indexed
R5
 This instruction is equivalent to using SUB 0(R3),R5 where
R3 takes the value #1.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
64
Examples: Emulated instructions (4/6)
UBI
 Decrement by two the contents of register R5:
DECD R5
 Instruction code: 0x8325
Op-code
S-reg
Ad
B/W
As
D-reg
1000
0011
0
0
10
0101
SUB
R3
Register
16 Bits
Indirect
R5
 This instruction is equivalent to using SUB @R3,R5 where R3
points to the value #2.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
65
Examples: Emulated instructions (5/6)
UBI
 Do not carry out any operation:
NOP
 Instruction code: 0x4303
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0011
0
0
00
0011
MOV
R3
Register
16 Bits
Register
R3
 This instruction is equivalent to using MOV R3,R3 and
therefore the contents of R3 are moved to itself.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
66
Examples: Emulated instructions (6/6)
UBI
 Add the carry flag to the register R5:
ADC R5
 Instruction code: 0x6305
Op-code
S-reg
Ad
B/W
As
D-reg
0110
0011
0
0
00
0101
ADDC
R3
Register
16 Bits
Register
R5
 This instruction is equivalent to using ADDC R3,R5 where R3
takes the value #0.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
67
Addressing modes (1/2)
UBI
 There are seven addressing modes that take a source
operand and four of these addressing modes also take a
destination operand;
 The operands can be located in any memory space
address, but the user needs to be aware of the effects
that their accesses may have;
 The addressing modes are selected by the As and Ad
fields that make up the instruction;
 The following table summarizes the seven addressing
modes:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
68
Addressing modes (2/2)
UBI
Operands (single-operand instructions)
Source operands (double-operand instructions)
Addressing mode
As
S-reg
Destination operands (double-operand instructions)
Addressing mode
Ad
D-reg
Register mode
00
0 0 0 0 to 1 1 1 1
Register mode
0
0 0 0 0 to 1 1 1 1
Indexed mode
01
0 0 0 1, 0 0 1 1 to 1 1 1 1
Indexed mode
1
0 0 0 1, 0 0 1 1 to 1 1 1 1
Symbolic mode
01
0000
Symbolic mode
1
0000
Absolute mode
01
0010
Absolute mode
1
0010
Indirect register
mode
10
0 0 0 0 to 1 1 1 1
Indirect auto
increment mode
11
0 0 0 1 to 1 1 1 1
Immediate mode
11
0000
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
69
Register mode (1/3)
UBI
 In Register addressing mode, the contents of a register
is used as the operand;
 This type of addressing mode can be used both with
source and destination operands.
 Move the contents of register R5 to register R4:
MOV R5,R4
 Instruction code: 0x4504
Op-code
0100
MOV
>> Contents
S-reg
0101
R5
Ad
0
Register
B/W
0
16-bit
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
As
00
Register
D-reg
0100
R4
70
Register mode (2/3)
UBI
 Move the contents of register R5 to register R4
MOV R5,R4
 Instruction code: 0x4504
Op-code
0100
MOV
S-reg
0101
R5
Ad
0
Register
B/W
0
16-bit
As
00
Register
D-reg
0100
R4
 The 16-bit contents (B/W = 0) of register R5 (S-reg) are
transferred to the register R4 (D-reg);
 After the instruction fetch, the PC is incremented by 2 and
points to the next instruction to be executed;
 The addressing mode used for the source and destination
operands is determined by As = 00 (Register mode) and
Ad = 0 (Register mode), respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
71
Register mode (3/3)
UBI
 Move the contents of register R5 to register R4 (cont.):
MOV R5,R4
 Instruction code: 0x4504
Op-code
0100
MOV
>> Contents
S-reg
0101
R5
Ad
0
Register
B/W
0
16-bit
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
As
00
Register
D-reg
0100
R4
72
Indexed mode (1/4)
UBI
 In indexed mode, whether used to indicate the source
address or the destination address, the sum of the
register contents and the signed offset point to the
location in memory;
 The offset value is stored in the word following the
instruction;
 After the execution of the instruction, the contents of
registers are not affected and the PC is incremented to
point to the next instruction to be executed;
 This addressing mode is useful to access data stored in
tables. Apart from the registers PC and SR, all other
registers can be used as an index in indexed mode.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
73
Indexed mode (2/4)
UBI
 Move the byte pointed to by (R5 + 4) to the byte pointed
to by (R4 + 1):
MOV.B 4(R5),1(R4)
 Instruction code: 0x45D4
Op-code
0100
MOV
S-reg
0101
R5
Ad
1
Indexed
B/W
1
8-bit
As
01
Indexed
D-reg
0100
R4
 The instruction coding specifies that the byte (B/W = 1)
pointed to by the sum of the contents of register R5
(S-reg = 0101) and the word X1 should be moved to the
memory address pointed to by the sum of register R4
(D-reg = 0100) and the contents of the word X2;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
74
Indexed mode (3/4)
UBI
 Move the byte pointed to by (R5 + 4) to the byte pointed
to by (R4 + 1) (continued):
MOV.B 4(R5),1(R4)
 Instruction code: 0x45D4
Op-code
0100
MOV
S-reg
0101
R5
Ad
1
Indexed
B/W
1
8-bit
As
01
Indexed
D-reg
0100
R4
 The words X1 and X2 are located in the memory addresses
following the instruction;
 The addressing mode used for the source and destination
operands is controlled by the bits Ad = 1 (Indexed mode)
and As = 01 (Indexed mode), because (D-reg = 0100) and
(S-reg = 0101) respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
75
Indexed mode (4/4)
UBI
 Move the byte pointed to by (R5 + 4) to the byte pointed
to by (R4 + 1) (continued):
MOV.B 4(R5),1(R4)
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
76
Symbolic mode (1/5)
UBI
 In symbolic addressing mode, for either the source or
destination operands, the memory address is determined
by adding an offset to the program counter (PC) register;
 The offset value is obtained by determining the code
position in the memory, then calculating the difference
between the offset address and the memory position that
should be achieved;
 The assembler determines the offset value and puts it in
the word following to the instruction;
 After the execution of the instruction, the program
counter (PC) register is incremented in order to point to
the next instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
77
Symbolic mode (2/5)
UBI
 Although this mode of address is similar to register mode
it request more cycles, but in this case, the program
counter (PC) is used to point to the data;
 This addressing mode can be used to determine either
the source or the destination of the data.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
78
Symbolic mode (3/5)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI:
MOV EDEN,TONI
 Instruction code: 0x4090
Op-code
0100
MOV
S-reg
0000
PC
Ad
1
Symbolic
B/W
0
16-bit
As
01
Symbolic
D-reg
0000
PC
 The instruction coding specifies that the value pointed to by
the sum of the PC register contents (S-reg = 0) and the
word X1 should be moved to the memory address pointed to
by the sum of register PC contents (D-reg = 0) and the
word X2;
 The words X1 and X2 are stored in the memory addresses
following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
79
Symbolic mode (4/5)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI (continued):
MOV EDEN,TONI
 Instruction code: 0x4090
Op-code
0100
MOV
S-reg
0000
PC
Ad
1
Symbolic
B/W
0
16-bit
As
01
Symbolic
D-reg
0000
PC
 The addressing mode used for the source and destination
operands is controlled by the bits Ad = 1 (Symbolic mode)
and As = 01 (Symbolic mode) because (D-reg = 0000) and
(S-reg = 0000), respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
80
Symbolic mode (5/5)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI:
MOV EDEN,TONI
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
81
Absolute mode (1/4)
UBI
 In Absolute mode, the data memory address is placed
after the instruction;
 The difference between this addressing mode and
Indexed mode is that the register R2 is now used as an
index, using the constants generator to generate the
value zero;
 This addressing mode can be used to define either the
source address or the destination address.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
82
Absolute mode (2/4)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI:
MOV &EDEN,&TONI
 Instruction code: 0x4292
Op-code
0100
MOV
S-reg
0010
R2/CG1
Ad
1
Absolute
B/W
0
16-bit
As
01
Absolute
D-reg
0010
R2/CG1
 From the instruction coding it can be seen that the register
R2 has (S-reg = 0010) and (D-reg = 0010). Register R2 is
used as an addresses index, in which the constant generator
loads the value zero;
 When the contents of this register is added to the offset
value X1 or X2, the source and destination addresses are
obtained;
 The words X1 and X2 are stored in the memory addresses
following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
83
Absolute mode (3/4)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI (continued):
MOV &EDEN,&TONI
 Instruction code: 0x4292
Op-code
0100
MOV
S-reg
0010
R2/CG1
Ad
1
Absolute
B/W
0
16-bit
As
01
Absolute
D-reg
0010
R2/CG1
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Absolute mode)
and As = 01 (Absolute mode) because (D-reg = 0010) and
(S-reg = 0010), respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
84
Absolute mode (4/4)
UBI
 Move the word pointed to by EDEN to the word pointed to
by TONI (continued):
MOV &EDEN,&TONI
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
85
Indirect register mode (1/3)
UBI
 In Indirect register mode, any of the 16 CPU registers
can be used. If R2 or R3 are used then a constant value
is used as an operand, #0x04 for R2 and #0x02 for R3;
 A restriction arises from the fact that this addressing
mode can only be used to specify the source operand
address in dual-operand instructions;
 An alternative way to avoid this restriction is to use
indexed mode to specify the destination operand address,
with a zero offset.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
86
Indirect register mode (2/3)
UBI
 Move the word pointed to by R5 to the word pointed to by
R4:
MOV @R5,0(R4)
 Instruction code: 0x45A4
Op-code
0100
MOV
S-reg
0101
R5
Ad
1
Indexed
B/W
0
16-bit
As
10
Indirect
D-reg
0100
R4
 The instruction coding specifies that register R5
(S-reg = 0101) uses the source address (As = 10);
 The destination address is pointed to in Indexed mode
(Ad = 1) by R4 (D-reg = 0100), using a zero value offset.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
87
Indirect register mode (3/3)
UBI
 Move the word pointed to by R5 to the word pointed to
by R4 (continued):
MOV @R5,0(R4)
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
88
Indirect auto-increment mode (1/3)
UBI
 This addressing mode is similar to the previous one;
 The contents of source register is incremented according
to the data type processed;
 If the data value is byte, the source register is
incremented by 1;
 If the data value is a word, the source register is
incremented by 2;
 Note that this addressing mode can only be used to
specify the source operand in dual-operand instructions.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
89
Indirect auto-increment mode (2/3)
UBI
 Move the word pointed to by R5 to the word pointed to
by R4, and increment the source pointer:
MOV @R5+,0(R4)
 Instruction code: 0x45B4
Op-code
0100
MOV
S-reg
0101
R5
Ad
1
Indexed
B/W
0
16-bit
As
11
Ind. aut. inc.
D-reg
0100
R4
 The instruction coding specifies that the register R5
(S-reg = 0101) contains the source address (As = 11);
 The destination address is pointed to in indexed mode by R4
(D-reg = 0100), using a zero value offset;
 The execution of the instruction increments the contents of
register R5 by 2.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
90
Indirect auto-increment mode (3/3)
UBI
 Move the word pointed to by R5 to the word pointed to
by R4, and increment the source pointer (continued):
MOV @R5+,0(R4)
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
91
Immediate mode (1/2)
UBI
 The Immediate addressing mode allows values to be
loaded directly into registers or memory addresses. It
can only be used with source operands.
 Move the value 0x0200 to R5:
MOV #0x0200,R5
 Instruction code: 0x4035
Op-code
0100
MOV
S-reg
0000
PC
Ad
0
Register
B/W
0
16-bit
As
11
Immediate
D-reg
0101
R5
 The instruction coding specifies that the register PC
(S-reg = 0000) is used to define the address of the word in
memory that loads the register R5 (D-reg = 0101)
with (As = 11).
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
92
Immediate mode (2/2)
UBI
 Move the value 0x0200 to R5 (continued):
MOV 0x0200,R5
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
93
UBI
Instruction format in the MSP430X CPU
(1/2)
 There are three possibilities to choose between the
instructions of the MSP430 CPU and MSP430X CPU:
• Use only the MSP430 CPU instructions. The following
rules must be followed, with the exception of the
instructions CALLA/RETA, BRA:
– Put all the data in memory below 64 kB and access
the 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 an
increase in the memory space occupied by the program;
• Use an appropriate selection of the instruction types.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
94
Instruction format in the MSP430X CPU (2/2)
UBI
 The MSP430X CPU supports all functions of the MSP430
CPU;
 It also offers a set of instructions that provide full access
to the 20-bit addressing space;
 An additional op-code word is added to some of the
instructions. Therefore all addresses, indexes and
immediate numbers have 20 bits.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
95
UBI
Extension word for register addressing
mode (1/2)
 In register mode, the
extension word of an
instruction of format type I
(two operands) or format
type II (single operand) is
coded as:
 The description of each field:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
96
UBI
Extension word for register addressing
mode (1/2)
 Unlike the MSP430, the MSP430X CPU supports the
repeated execution of the same instruction, provided
that the operands are of the register type;
 The repetition is set by placing the repeat RPT instruction
before the instruction to be executed;
 The assembler incorporates information in the extension
word in the fields # (bit 7) and in the repetition counter
(bits 3:0);
 An example of this feature will be provided later.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
97
UBI
Extension word for the other addressing
modes
 In a non-register
addressing mode, the
extension word of an
instruction, whether
format I (double
operands) or format II
(single operand), is
coded as:
 The description of each
field:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
98
UBI
Extended format I -Double operandinstructions
 There are twelve extended instructions that use two
operands:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
99
Examples: Extended double operand
instructions (1/7)
UBI
 Move the contents of register R5 to register R4:
MOVX R5,R4
 Instruction code: 0x1840 – 0x4504
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
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
0
0
00
0100
MOVX
R5
Register
16-bit
Register
R4
 This instruction uses 2 words;
 The instruction coding specifies that the CPU must perform
the 16-bit data function MOVX, using the contents of the
source register R5 and the destination register R4.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
100
Examples: Extended double operand
instructions (2/7)
UBI
 Move the contents of the register R5 to the memory
address TONI:
MOVX R5,TONI
 Instruction code: 0x184F – 0x4580
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
1
0
0
1111
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
00
0000
MOVX
R5
Symbolic
16-bits
Register
PC
 This instruction uses 3 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
101
Examples: Extended double operand
instructions (3/7)
UBI
 Move the contents of the register R5 to the memory
address TONI (continued):
MOVX R5,TONI
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
1
0
0
1111
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
00
0000
MOVX
R5
Symbolic
16-bits
Register
PC
 The instruction coding specifies that the CPU must perform
the 16-bit data function MOVX, the source being the contents
of register R5 and the destination being the memory address
pointed to by (dst 19:16: X1 + PC);
 The bits dst 19:16 is stored in the extension word and the
value X1 is stored in the word following.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
102
Examples: Extended double operand
instructions (4/7)
UBI
 Move the contents of the memory address TONI to
register R5:
MOVX TONI,R5
 Instruction code: 0x1FC0 – 0x4015
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
0
0
01
0101
MOVX
PC
Register
16-bit
Symbolic
R5
 This instruction uses 3 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
103
Examples: Extended double operand
instructions (5/7)
UBI
 Move the contents of the memory address TONI to
register R5 (continued):
MOVX TONI,R5
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
0
0
01
0101
MOVX
PC
Register
16-bit
Symbolic
R5
 The coding specifies that the CPU must perform the 16-bit
data function MOVX, the source being the contents of memory
address pointed to by (src 19:16: X1 + PC) and the
destination being register R5;
 The bits dst 19:16 are stored in the extension word and the
value X1 is stored in the word following.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
104
Examples: Extended double operand
instructions (6/7)
UBI
 Move the contents of the memory address TONI to the
memory address EDEN:
MOVX TONI,EDEN
 Instruction code: 0x1FCF – 0x4090
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
1111
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
1
0
01
0000
MOVX
PC
Symbolic
16-Bit
Symbolic
PC
 This instruction uses 4 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
105
Examples: Extended double operand
instructions (7/7)
UBI
 Move the contents of the memory address TONI to the
address memory EDEN:
MOVX TONI,EDEN
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
1111
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
1
0
01
0000
MOVX
PC
Symbolic
16-Bit
Symbolic
PC
 The coding specifies that the CPU must perform the 16-bit
data function MOVX, the source being the contents of the
memory address pointed to by (src 19:16: X1 + PC) and
the destination being the contents of the memory address
pointed to by (dst 19:16: X2 + PC);
 The bits src 19:16 and dst 19:16 are stored in the
extension word and the words X1 and X2 are stored in the
words following.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
106
UBI
Extended format II - single operandinstructions (1/2)
 Extended instructions using format II are:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
107
Extended format II - single operandinstructions (2/2)
UBI
 The MSP430X CPU has some additional capabilities in
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 times
during the execution of a single instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
108
Examples: Extended single operand
instructions (1/4)
UBI
 Rotate right the 20-bit contents of register R5 with the
carry flag:
RRCX.A R5
 Instruction code: 0x1800 – 0x1045
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
0000
Op-code
B/W
Ad
D/S-reg
000100000
1
00
0101
RRCX
20-bit
Register
R5
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
109
Examples: Extended single operand
instructions (2/4)
UBI
 Rotate right the 20-bit contents of the memory address
TONI with carry flag:
RRCX.A TONI
 Instruction code: 0x180F – 0x1050
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
0
0
0
1111
Op-code
B/W
Ad
D/S-reg
000100000
1
01
0000
RRCX
20-bit
Symbolic
PC
 This instruction uses 3 words;
 The coding specifies that the CPU must perform the function
RRCX using the 20-bit data contents of the memory address
pointed to by (dst 19:16: X1 + PC);
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
110
Examples: Extended single operand
instructions (3/4)
UBI
 Rotate right the 20-bit contents of the memory address
TONI with carry flag (continued):
RRCX.A TONI
 Instruction code: 0x180F – 0x1050
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
0
0
0
1111
Op-code
B/W
Ad
D/S-reg
000100000
1
01
0000
RRCX
20-bit
Symbolic
PC
 The bits dst 19:16 are stored in the extension word and the
value X1 is stored in the word following;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
111
Examples: Extended single operand
instructions (4/4)
UBI
 Rotate right the 20-bit contents of the memory address
TONI with carry flag (continued):
RRCX.A TONI
 Because the instruction operand is located in memory rather
than in a CPU register, two words are used to store the
operand. The format is shown in the figure below:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
112
Exceptions to the representation of the
extended Format II instructions (1/7)
UBI
 Store the 20-bit registers R10, R9, R8:
PUSHM.A #3,R10
 The instructions PUSHM and POPM are coded according to the
structure given in the figure below:
 Instruction code: 0x142A
Op-code
n-1
D-reg
00010100
0010
1010
PUSHM.A
#3
R10
 This instruction uses 1 word;
 The coding specifies that the CPU must perform the function
PUSHM of the 20-bit registers R10 to R8.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
113
Exceptions to the representation of the
extended Format II instructions (2/7)
UBI
 Rotate right three times the contents of the 20-bit register
R5 with the carry flag:
RRCM.A
#3,R5
 The instructions RRCM, RRAM, RRUM and RLAM are coded
according to the structure given in the figure below:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
114
Exceptions to the representation of the
extended Format II instructions (3/7)
UBI
 Rotate right three times the content of the 20-bit register
R5 with the carry flag (continued):
RRCM.A
#3,R5
 Instruction code: 0x0845
C
n-1
Op-code
R-reg
0000
10
000100
0101
#3
RRCM
R5
 This instruction uses 1 word;
 The coding specifies that the CPU must perform the function
RRCM using the contents of the 20-bit register R5 a total of 3
times.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
115
Exceptions to the representation of the
extended Format II instructions (4/7)
UBI
 Perform a branch in the program flow:
BRA R5
 This type of instruction can be coded in three different
formats, as shown in the figure below:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
116
Exceptions to the representation of the
extended Format II instructions (5/7)
UBI
 Perform a branch in the program flow (continued):
BRA R5
 Instruction code: 0x05C0
C
R-reg
Op-code
0(PC)
0000
0101
1100
0000
R5
BRA
PC
 This instruction uses 1 word;
 The coding specifies that the PC must be loaded with the
value in register R5.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
117
Exceptions to the representation of the
extended Format II instructions (6/7)
UBI
 Call a routine:
CALLA
R5
 This type of instruction can be coded in three different
formats, as shown in the figure below:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
118
Exceptions to the representation of the
extended Format II instructions (7/7)
UBI
 Call a routine (continued):
CALLA
R5
 Instruction code: 0x1345
Op-code
D-reg
000100110100
0101
CALLA
R5
 This instruction uses 1 word;
 The coding specifies that the PC must be loaded with the
value in register R5;
 The execution of this instruction saves the PC on the data
stack, so the function can return at the end of execution of
the routine.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
119
Extended emulated instructions
UBI
 The constant generator provide a set of extended
emulated instructions, as shown in the following table:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
120
MSP430X address instructions
UBI
 Address instructions support 20-bit operands, but they
have restrictions on the addressing modes they can use;
 List of extended address instructions:
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
121
MSP430X CPU addressing modes
UBI
 As with the MSP430 CPU, the MSP430X CPU supports
seven addressing modes for the source operand and four
addressing modes for the destination operand;
 Both the MSP430 CPU and MSP430X CPU instructions can
be used throughout the 1 MB address space;
 In the following sections we will explore the different
addressing modes available to the MSP430X CPU.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
122
Register mode (1/3)
UBI
 This addressing mode is identical to that of the MSP430
CPU;
 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 of
the value is extended to the other bits of the register.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
123
Register mode (2/3)
UBI
 Move the 20-bit contents of register R5 to register R4:
MOVX.A R5,R4
 Instruction code: 0x1800 – 0x4544
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
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
0
1
00
0100
MOVX
R5
Register
20-bit
Register
R4
 The instruction uses 2 words.
 The 20-bit contents (B/W = 1 and A/L = 0) of register R5
(S-reg = 0101) is transferred to register R4
(D-reg = 0100);
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
124
Register mode (3/3)
UBI
 Move the 20-bit contents of register R5 to register R4
(continued):
MOVX.A R5,R4
 After the execution of the instruction, the PC is incremented
by 4 and pointed to the next instruction;
 The addressing mode used for the source and destination
operands is specified by Ad = 0 (Register mode) and
As = 00 (Register mode).
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
125
Indexed mode
UBI
 Indexed mode can be used in three different situations:
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
126
Indexed mode: below 64 kB (1/4)
UBI
 Indexed mode in the memory address space below 64 kB:
 If the CPU register Rn points to a memory address located
below 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 memory
below 64 kB.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
127
Indexed mode: below 64 kB (2/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2):
MOV 0XFFD0(R5),2(R4)
 Instruction code: 0x4594
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
01
0100
MOV
R5
Indexed
16-bit
Indexed
R4
 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-reg = 0101)
and the word X1 should be moved to the memory address
pointed to by the sum of the register R4 contents
(D-reg = 0100) and the word X2;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
128
Indexed mode: below 64 kB (3/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2) (continued):
MOV 0XFFD0(R5),2(R4)
 The words X1 and X2 are located in the memory addresses
following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Indexed mode) and
As = 01 (Indexed mode), because D-reg = 0100 and
S-reg = 0101 respectively;
 In this example, bits 19:16 are set to zero when the operand
addresses are calculated.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
129
Indexed mode: below 64 kB (4/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2) (continued):
MOV 0XFFD0(R5),2(R4)
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
130
Indexed mode: above 64 kB (1/2)
UBI
 Indexed mode in the memory address space above 64 kB:
 If the CPU register Rn points to a memory address above 64
kB, bits 19:16 are used to calculate the operand of the
address;
 A prerequisite is that the operand must be located in the
range Rn  32KB, because the index is a signed 16-bit value;
 Outside this range, the operand address can overflow or
underflow the memory address space below or above the
64 kB.
 If the registers now point to a memory address space above
64 kB, bits 19:16 are used to determine the address in the
operands.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
131
Indexed mode: above 64 kB (2/2)
UBI
 Indexed mode in the memory address space above 64 kB
(continued):
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
132
Indexed mode: MSP430X CPU (1/4)
UBI
 Indexed mode using a MSP430X CPU instruction:
 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-bit
contents of the register Rn and the signed 20-bit index.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
133
Indexed mode: MSP430X (2/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2):
MOVX 0xFFFD0(R5),2(R4)
 Instruction code: 0x1FC0 – 0x4594
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
1000
0101
1
0
01
0100
MOVX
R5
Indexed
16-bit
Indexed
R4
 This instruction uses 4 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
134
Indexed mode: MSP430X CPU (3/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2) (continued):
MOVX 0xFFFD0(R5),2(R4)
 The instruction coding specifies that the word (B/W = 0 and
A/L = 1) pointed to by the sum of register R5 contents
(S-reg = 0101) and the word X1 should be moved to the
memory address pointed to by the sum of the register R4
contents (D-reg = 0100) and the word X2;
 The four MSB indices are placed in the extension word of the
instruction and the other 16 bits are placed in the words
following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Indexed mode) and
As = 01 (Indexed mode), because D-reg = 0100 and
S-reg = 0101 respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
135
Indexed mode: MSP430X CPU (4/4)
UBI
 Move the word pointed to by (R5 – 0x30) to the word
pointed to by (R4 + 2) (continued):
MOVX 0xFFFD0(R5),2(R4)
CPU Registers
Address Space
Code
Before
After
R5
0x101D0
R5
0x101D0
R4
0x00200
R4
0x00200
PC
0x03110
PC
0x03118
Before
0x03118
0x03116 0x0002
0x03114 0xFFD0
0x03112 0x4594
0x03110 0x1FC0
X2
X1
PC
After
0x03118
0x03116 0x0002
0x03114 0xDDF0
0x03112 0x4594
0x03110 0x1FC0
PC
X2
X1
Data
Destination Address
0x00200
0x00002
0x00202
Source Address
0x101D0
0xFFFD0
0x101A0
>> Contents
(R4)
(X2)
(R5)
(X1)
0x00202
0xXXXX
X2(R4)
0x00202
0x1234 X2(R4)
0x101A0
0x1234
X1(R5)
0x101A0
0x1234
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
X1(R5)
136
Symbolic mode
UBI
 The symbolic addressing mode uses the register PC to
determine the location of the operand based on an index;
 Similar to the previous addressing mode, there are three
different ways to use symbolic mode with the MSP30X
CPU.
 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.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
137
Symbolic mode: below 64 kB (1/3)
UBI
 As in the indexed addressing mode, if the PC register
points to a memory address below 64 kB, the bits 19:16
of the address calculated from the sum of the PC register
and the signed 16-bit index are set to zero.
 Move the contents of the address EDEN located at
0x00200 to the address TONI located at 0x00202:
MOV EDEN,TONI
 Instruction code: 0x4090
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
1
0
01
0000
MOV
PC
Symbolic
16-bit
Symbolic
PC
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
138
Symbolic mode: below 64 kB (2/3)
UBI
 Move the contents of the address EDEN located at
0x00200 to the address TONI located at 0x00202 (cont.):
MOV EDEN,TONI
 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-reg = 0000) and the word X1 should be moved to the
memory address pointed to by the sum of the register PC
contents (D-reg = 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 destination
operands is specified by the bits Ad = 1 (Symbolic mode)
and As = 01 (Symbolic mode), because D-reg = 0000 and
S-reg = 0000, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
139
Symbolic mode: below 64 kB (3/3)
UBI
 Move the contents of address the EDEN located at
0x00200 to the address TONI located at 0x00202 (cont.):
MOV EDEN,TONI
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
140
Symbolic mode: above 64 kB (1/4)
UBI
 If the PC register points to a memory address above 64
kB, bits 19:16 of the PC are used to calculate the operand
address;
 The operand must be located in the memory range
PC  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 memory
below 64 kB.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
141
Symbolic mode: above 64 kB (2/4)
UBI
 Move the contents of the address EDEN located at
0x10200 to register R5:
MOV EDEN,R5
 Instruction code: 0x4015
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
0
0
01
0101
MOV
PC
Register
16-bit
Symbolic
R5
 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-reg = 0000) and the word X1 should be moved to the
register R5 (D-reg = 0101);
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
142
Symbolic mode: above 64 kB (3/4)
UBI
 Move the contents of the address EDEN located at
0x10200 to register R5 (continued):
MOV EDEN,R5
 The word X1 is in the memory address following the
instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 0 (Register mode) and
As = 01 (Symbolic mode), because D-reg = 0101 and
S-reg = 0000, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
143
Symbolic mode: above 64 kB (4/4)
UBI
 Move the contents of the address EDEN located at
0x10200 to register R5 (continued):
MOV EDEN,R5
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
144
Symbolic mode: MSP430X CPU (1/4)
UBI
 When a MSP430X CPU instruction is used in symbolic
mode, the operand can be located anywhere in the range
of the addresses PC  19 bits;
 The operand address is calculated from the sum of the
20-bit contents of the PC register and the signed 20-bit
index.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
145
Symbolic mode: MSP430X CPU (2/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to register R5:
MOVX EDEN,R5
 Instruction code: 0x1FC0 – 0x4015
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
1111
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
0
0
01
0101
MOVX
PC
Register
16-bit
Symbolic
R5
 This instruction uses 3 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
146
Symbolic mode: MSP430X CPU (3/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to register R5 (continued):
MOVX EDEN,R5
 The instruction coding specifies that the CPU must perform
the function MOVX of the 16-bit data (B/W = 0 and A/L = 1),
from the memory address contents pointed to by
(src 19:16:X1 + PC) to register R5;
 The bits (src 19:16) are stored in the extension word and
the word X1 is stored in the word following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 0 (Register mode) and
As = 01 (Symbolic mode), because D-reg = 0000 and
S-reg = 0101, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
147
Symbolic mode: MSP430X CPU (4/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to register R5 (continued):
MOVX EDEN,R5
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
148
Absolute mode
UBI
 Absolute mode uses the word contents following the
instruction as the operand address;
 There are two different ways to use absolute mode with
the MSP30X CPU.
 Absolute mode in the memory address space below 64 kB:
• In memory space below 64 kB, this instruction operates
in the same way as the MSP430 CPU.
 Absolute mode using a MSP430X CPU instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
149
Absolute mode: MSP430X CPU (1/4)
UBI
 If a MSP430X CPU instruction is used with an address in
absolute mode, the 20-bit absolute address of the
operand is used with an index of zero (generated by the
constant generators) to point to the operand;
 The four MSBs of the indices are placed in the extension
word of the instruction and the other 16 bits are placed
in the words following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
150
Absolute mode: MSP430X CPU (2/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to the address TONI located at 0x00202:
MOVX
&EDEN,&TONI
 Instruction code: 0x1840 – 0x4292
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0010
1
0
01
0010
MOVX
SR/CG1
Absolute
16-bit
Absolute
SR/CG1
 This instruction uses 4 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
151
Absolute mode MSP430X CPU (3/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to the address TONI located at 0x00202 (cont.):
MOVX
&EDEN,&TONI
 The instruction coding specifies that the CPU must perform
the function MOVX of 16-bit data (B/W = 0 and A/L = 1) from
the memory address contents pointed to by (src 19:16:X1)
to the memory address contents pointed to by
(dst 19:16:X2);
 The bits src 19:16 and dst 19:16 are stored in the
extension word;
 The words X1 and X2 are stored following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Absolute mode)
and As = 01 (Absolute mode), because D-reg = 0010 and
S-reg = 0010, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
152
Absolute mode: MSP430X CPU (4/4)
UBI
 Move the contents of the address EDEN located at
0x00200 to the address TONI located at 0x00202 (cont.):
MOVX
&EDEN,&TONI
CPU Registers
Address Space
Code
Before
PC
0x03110
After
PC
0x03118
0x03118
0x03116
0x03114
0x03112
0x03110
Before
After
PC
X2
X1
0x0202
0x0200
0x4292
0x1840
PC
0x03118
0x03116
0x03114
0x03112
0x03110
0x00202
0xXXXX
TONI
0x00202
0x1234
TONI
0x00200
0x1234
EDEN
0x00200
0x1234
EDEN
X2
X1
0x0202
0x0200
0x4292
0x1840
Data
Destination Address
Source Address
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
153
Indirect register mode (1/3)
UBI
 Indirect addressing mode uses the contents of register
Rn to point to the 20-bit operand;

 It can only be used to point to the source operand.
 Move the operand pointed to by the contents of register
R5 to the memory address TONI located at 0x00202:
MOVX
@R5,&TONI
 Instruction code: 0x1840 – 0x45A2
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
10
0010
MOVX
R5
Absolute
16-bit
Indirect
SR/CG1
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
154
Indirect register mode (2/3)
UBI
 Move the operand pointed to by the contents of register
R5 to the memory address TONI located at 0x00202:
MOVX
@R5,&TONI
 This instruction uses 3 words;
 The instruction coding specifies that the CPU must perform
the function MOVX of 16-bit data (B/W = 0 and A/L = 1),
from the memory address contents pointed to by the register
R5 to the memory address contents pointed to by
(dst 19:16:X1);
 The bits dst 19:16 are stored in the extension word;
 The words X1 is stored following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 1 (Absolute mode)
and As = 10 (Indirect mode), because D-reg = 0010 and
S-reg = 0101, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
155
Indirect register mode (3/3)
UBI
 Move the operand pointed to by the contents of register
R5 to the memory address TONI located at 0x00202:
MOVX
@R5,&TONI
CPU Registers
Address Space
Code
Before
R5
PC
0x00200
0x03110
After
R5
PC
Before
0x00200
0x03116
0x03116
0x03114
0x03112
0x03110
After
PC
X1
0x0202
0x45A2
0x1840
PC
0x03116
0x03114
0x03112
0x03110
0x00202
0xXXXX
TONI
0x00202
0x1234
TONI
0x00200
0x1234
@R5
EDEN
0x00200
0x1234
EDEN
@R5
X1
0x0202
0x45A2
0x1840
Data
Destination Address
Source Address
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
156
Indirect auto-increment mode (1/4)
UBI
 This addressing mode uses the contents of register Rn to
point to the 20-bit source operand;
 The register Rn is automatically incremented by 1 for a
byte operand, by 2 for a word operand and by 4 for an
address operand.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
157
Indirect auto-increment mode (2/4)
UBI
 Move the word pointed to by register R5 to the memory
address TONI located at 0x00202:
MOVX
@R5+,&TONI
 Instruction code: 0x1840 – 0x45B2
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0000
1
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0101
1
0
11
0010
MOVX
R5
Absolute
16-bit
Ind. aut. inc.
SR/CG1
 This instruction uses 3 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
158
Indirect auto-increment mode (3/4)
UBI
 Move the word pointed to by register R5 to the memory
address TONI located at 0x00202 (continued):
MOVX
@R5+,&TONI
 The instruction coding specifies that the CPU must perform
the function MOVX of the 16-bit data (B/W = 0 and A/L = 1),
from the memory address contents pointed to by the register
R5 to the memory address contents pointed to by
(dst 19:16:X1);
 The bits dst 19:16 are stored in the extension word;
 The word X1 is stored following the instruction;
 The addressing modes used for the source and destination
operands are specified by the bits Ad = 1 (Absolute mode)
and As = 11 (Indirect auto-increment mode), because
D-reg = 0010 and S-reg = 0101, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
159
Indirect auto-increment mode (4/4)
UBI
 Move the word pointed to by register R5 to the memory
address TONI located at 0x00202 (continued):
MOVX
@R5+,&TONI
@R5
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
@R5
160
Immediate mode
UBI
 The immediate addressing mode allows constants to be
placed after the instruction and use them as source
operands;
 There are two ways to use immediate mode:
 A 8-bit or 16-bit constant with a MSP430 CPU instruction:
• The operation in this situation is similar to that of the
MSP430 CPU.
 A 20-bit constant with a MSP430X CPU instruction:
• If a MSP430X CPU instruction is used in immediate
addressing mode, the constant has a 20-bit value;
• The bits 19:16 are stored in the extension word and the
remaining bits are stored following the instruction.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
161
Immediate mode: MSP430X CPU (1/3)
UBI
 Move the constant #0x12345 to register R5:
MOVX.A #0x12345,R5
 Instruction code: 0x1880 – 0x4075
0
0
0
1
1
src 19:16
A/L
0
0
dst 19:16
0
0
0
1
1
0001
0
0
0
0000
Op-code
S-reg
Ad
B/W
As
D-reg
0100
0000
0
1
11
0101
MOVX
PC
Register
20-bit
Immediate
R5
 This instruction uses 3 words;
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
162
Immediate mode: MSP430X CPU (2/3)
UBI
 Move the constant #0x12345 to register R5 (continued):
MOV.A #0x12345,R5
 The instruction coding specifies that the CPU must perform
the function MOVX using 20-bit data (B/W = 1 and A/L = 0),
from the location src 19:16:X1 to register R5;
 The bits src 19:16 are stored in the extension word;
 The word X1 is stored following the instruction;
 The addressing mode used for the source and destination
operands is specified by the bits Ad = 0 (Register mode) and
As = 11 (Immediate mode), because D-reg = 0101 and
S-reg = 0000, respectively.
>> Contents
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
163
Immediate mode: MSP430X CPU (3/3)
UBI
 Move the constant #0x12345 to register R5 (continued):
MOV #0x12345,R5
CPU Registers
Address Space
Code
Before
R5
PC
0xXXXXX
0x03110
>> Contents
After
R5
PC
0x12345
0x03116
Before
0x03116
0x03114
0x03112
0x03110
0x2345
0x4075
0x1880
Copyright 2009 Texas Instruments
All Rights Reserved
www.msp430.ubi.pt
After
X1
PC
0x03116
0x03114
0x03112
0x03110
0x2345
0x4075
0x1880
PC
X1
164