Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.

Similar presentations


Presentation on theme: "ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set."— Presentation transcript:

1 ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set

2 ECE447: MSP430 Assembly language Specific to the platform (ie: The MSP430). No data types, structures, or explicit execution control (for, while, if, switch) Define locations for and variables and program code. No complex instructions, such as long integer math, floating point. Close coupling to the hardware (registers, peripherals and input/output ports) Teaches a more in depth appreciation for the device architecture.

3 ECE 447: Levels of Software High-level language (C, C++, Pascal) Assembly language (MSP430, 8051, Z80) Machine language assembler compiler linker Object code

4 ECE 447: Levels of Software C Pascal Pseudocode MSP4308051Z80 Object code compiler assembler Machine language Object code Machine language Object code Machine language linker

5 ECE447: Assembly vs. Machine code for the MSP430 15 – 1211 – 8765 43 – 0 OpcodeS-regAdB/WAsD-reg Opcode (4 bits): Operation Code S-reg and Dreg (4 bits each): Specifies CPU registers associated with the src and dst Ad (1 bit): Gives mode of addressing for dst B/W (1 bit): chooses whether the operand is a byte (1) or a word (0) As (2 bits): gives the mode of addressing for the src mov.wR5, R6; 4506 – Machine code translation

6 ECE 447: Features of Assembly Language 1. Very hardware dependent 2. Not very portable (if at all) 3. Very detailed (responsible for all register contents) 4. No inherent data types 5. Requires programming discipline 6. Difficult to document 7. Access to all hardware intricacies of the chip 8. Fastest execution 9. Small memory usage

7 ECE447: MSP430 Register Structure PC: Program Counter Contains the address of the next instruction to be executed. SP: Stack Pointer Contain the address of the stack frame. The stack is primarily responsible for storing the return address of subroutine calls. SR: Status Register Contains a set of flags CG1/CG2: Constant Generator Provides the six most frequently used values so that they do not need to be fetched from memory.

8 ECE 447: MSP430 Status Register (SR) V - Overflow, set when a result of a signed operation has overflowed. N - Negative, set to the msb of the result which indicates a negative number if the values are signed. Z - Zero, set when the result is 0. C - Carry, set to indicate an arithmetic operation is too larger to fit in the destination space. GIE - General Interrupt Enable - Set to enable the maskable interrupts. OSCOFF, CPUOFF, SCG0, SCG1 - bits to control the mode of operation of the MCU. Will be covered in detail in discussion of Low Power Modes.

9 ECE447: Groups of Instructions (1) –Movement - general (mov) –Movement - stack (push, pop) –Arithmetic i.One Operand (clr, dec, inc, test) ii.Two Operands (add, sub, cmp) iii.Decimal Arithmetic (dadd, dadc) –Logic Instructions i.One Operand (inv(ert)) ii.Two Operands (and, xor, bis, bic)

10 ECE447: Groups of Instructions (2) –Status Register Instructions clr(c/z/n): clear specified bits set(c/z/n): set specified bits dint/eint: disable/enable interrupts –Shift and Rotates rla, rra: arithmetic shift left/right rlc, rrc: rotate through carry left/right –Byte Manipulation swpb: swap bytes (word only) sxt: sign extend (word only)

11 ECE447: Groups of Instructions (3) –Flow Control Operations br: branch (go to) call: call a subroutine ret: return from subroutine reti: return from interrupt nop: no operation (consumes one cycle) –Jumps jmp: unconditional jump conditional jmp’s: various conditional jumps

12 ECE447: MSP430 Operand width notation Most MSP430 instructions can operate on either 8 or 16 bit data. In MSP430X device the 20 bit address bus is also supported for operands. The move instruction: –mov.b - Operands will be byte wide –mov.w - Operands will be word (16-bit) wide –mov.a - Operands will be address word (20- bit) wide

13 ECE447: Move Instruction (mov) Only one mov instruction to move data Can address all of memory as either source or destination, including all registers. Note: The MSP430 mov instruction does not affect the SR register bits.

14 Addressing Modes The ways in which operands can be specified

15 Register Mode

16 Indexed Mode

17 Indexed Mode (cont.)

18 Symbolic Mode

19 Symbolic Mode (cont.)

20 Absolute Mode

21 Absolute Mode (cont.)

22 Indirect Register Mode

23 Indirect Register Mode (cont.)

24 Indirect Autoincrement Mode

25 Indirect Autoincrement Mode (cont.)

26 Immediate Mode

27 Immediate Mode (cont.)

28 Addressing Mode Summary

29 Addressing Mode Examples Register Indexed Absolute Indirect Immediate

30 ECE447: MSP430 Constant Generator and Emulated Instruction Two registers in the MSP430 allow up to 7 common constant values. R3/CG2 and R2/SR/CG1 when accessed in various addressing modes provide “0” base for absolute addressing and six immediate values 0,1,2,4,8, and 0xFFFF. The instruction that use these values are “emulated,” that is no actual machine instruction exists for the mnemonic

31 ECE447: MSP430 Constant Generator and Emulated Instruction InstructionExplanationEmulation nopNo operation commencedmov R3, R3

32 Summary Assembly Rocks! MSP430 Registers Instruction Types The mov command Addressing Modes


Download ppt "ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set."

Similar presentations


Ads by Google