ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2.

Slides:



Advertisements
Similar presentations
UBI >> Contents Chapter 15 Advanced Laboratories MSP430 assembly language tutorial: MSP430X CPU MSP430 Teaching Materials Texas Instruments Incorporated.
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
UBI >> Contents Chapter 15 Advanced Laboratories MSP430 assembly language tutorial: Instructions MSP430 Teaching Materials Texas Instruments Incorporated.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
COE 202: Digital Logic Design Signed Numbers
Instruction Set Architecture & Design
TK 2633 Microprocessor & Interfacing
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
ARM programmer’s model and assembler Embedded Systems Programming.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2:
Architecture of the MSP430 Processor. Central Processing Unit Program Counter (PC) - Contains the address of the next instruction to be executed. The.
MICROCONTROLLER INSTRUCTION SET
The 8051 Microcontroller and Embedded Systems
Machine Instruction Characteristics
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Lecture 4 ( Assembly Language).
CSCI 136 Lab 1: 135 Review.
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
Computer Architecture and Organization
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Computer Architecture Lecture 03 Fasih ur Rehman.
COMPUTER ORGANISATION Sri.S.A.Hariprasad Sr.Lecturer R.V.C.E Bangalore.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Addition, Subtraction, Logic Operations and ALU Design
What is a program? A sequence of steps
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
Number Representation (Part 2) Computer Architecture (Fall 2006)
CPE 323 Introduction to Embedded Computer Systems: The MSP430X Architecture Instructor: Dr Aleksandar Milenkovic.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Microprocessor & Assembly Language
ECE 3430 – Intro to Microcomputer Systems
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
8086 Microprocessor.
Lecture Set 5 The 8051 Instruction Set.
Subroutines and the Stack
Introduction to 8085 Instructions
Machine control instruction
Microcomputer Programming
Data Processing Instructions
Computer Organization and Assembly Language (COAL)
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
STACK and Stack Pointer
ECE 3430 – Intro to Microcomputer Systems
ECEG-3202 Computer Architecture and Organization
ECEG-3202 Computer Architecture and Organization
Introduction to Microprocessor Programming
Subroutines and the Stack
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
COMS 361 Computer Organization
Computer Operation 6/22/2019.
Presentation transcript:

ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2

Agenda Logic Instructions Arithmetic Instructions Signed Operations Status Register Instructions Flow Control Instructions Jump Instructions

ECE447: Logic Instructions (One Operand) Invert Instruction 1’s complement of the destination. It is emulated with the xor instruction.

ECE447: Logic Instructions (Two Operands) BIC and BIS do NOT modify the status bits. XOR, AND, & BIT modify the status bits.

ECE447: Byte Order (Big/Little Endian) Endianness is the byte ordering used to represent data in a computer system. Byte order is an important consideration in network programming, since two computers with different byte orders may be communicating. Failure to account for varying endianness when writing code for mixed platforms can lead to bugs that can be difficult to detect.

ECE447: Byte Swap Instruction (swpb) Only operates on 16-bit operands.

ECE447: Rotations and Shifts MSP430 has arithmetic shift and rotation, but no logical shift right. Logical shift right was added to the MSP430X, discussed later.

ECE447: Arithmetic Instructions (One Operand) Notice all one-operand Arithmetic instructions are emulated. CLR does not affect the SR flags, including Z(ero)

ECE447: Arithmetic Instructions (Two Operands)

ECE447: Arithmetic Instructions (Decimal) Instructions to allow manipulation of operands that are in binary coded decimal (BCD) format. Value of each nibble is limited to 0 to 9, instead of 0 to F. Eg: Useful for display of a clock application on the LCD.

ECE447: Signed vs. Unsigned Unsigned number Signed number B = b 7 b 6 b 5 b 4 b 3 b 2 b 1 b weights B = b b b b b b b b =bi2ibi2i  i=0 7 B = b b b b b b b b = - b bi2ibi2i  i=0 6

ECE447: 2’s Complement Representation X k=4 X>00X<0 X+2 k = X+1 0

ECE447: Unsigned vs. Signed Addition Machine Programmer Unsigned mind Signed mind weight carry XYSXYS + = FA x0x0 y0y0 s0s0 c1c1 x1x1 y1y1 s1s1 c2c2 x2x2 y2y2 s2s2 c3c3 x3x3 y3y3 s3s3 c4c4 x4x4 y4y4 s4s4 c5c5 x5x5 y5y5 s5s5 c6c6 x6x6 y6y6 s6s6 c7c7 x7x7 y7y7 s7s7 c8c /- FA: Full Adder

ECE447: Overflow of Signed Numbers Indication of overflow Positive + Positive = Negative Negative + Negative = Positive Formulas Overflow 2’s complement = x k-1 y k-1 s k-1 + x k-1 y k-1 s k-1

ECE447: Status Register Flags V - Overflow bit, set if the result of an operations has overflowed even if a carry is not generated, typically in the case of signed values. N - Negative flag, set to the msb of the result Z - Zero flag, set if the result of an operation is zero. C - Carry flag represents that an overflow has occurred in an operation and that the bit should be “carried” into the next more significant byte/word.

ECE447: Status Register Instructions Each of the SR instructions is emulated with BIS or BIC an immediate value, supplied by either CG1 or CG2. EINT and DINT enable and disable maskable interrupts.

ECE447: Sign Extension Instruction Sign extend an 8 bit number to a word length (16 or 20 bit) number. In register mode this will be to bit 15 in the MSP430, or bit 19 in the MSP430X. In all other addressing modes it extends to bit 15.

ECE447: Branch/Call/nop Instructions BR and NOP are emulated instructions. BR is a one-way operation, since the PC is not stored. (ie: you cannot return) CALL cannot be emulated since the stack operations must be coded into the operation.

ECE447: Return, Return from Interrupt RET is emulated and uses the auto-increment addressing mode to handle the stack pointer manipulation RETI is not emulated use to its manipulation of the SR register on the stack.

PUSH places a word or byte on the stack and decrements the SP value by 2. Note: Pushing a byte on the stack still takes a word (16-bits) of space on the stack. This is done to assure alignment. POP is emulated since the autoincrement addressing mode can handle that stack pointer manipulation. ECE447: Move/Stack Instructions

Example of Push/Pop

ECE447: Jump Instructions (1) JMP, is the simplest unconditional jump. All jump instructions are relative, so the range is limited. BR is not relative and can go anywhere in the address space, but is slower, and longer

ECE447: Jump Instructions (2) Conditional jumps operate with the SR flags from the last operation that affected the bits. (ie:CMP, ADD, INC…) Some jump instructions have two names for more concise usage in programming, however they produce identical machine code.

ECE447: MSP430X Instruction Extensions MSP430X required instruction changes to support the 20 bit address space. Handling 20 bit data, typically when computing addresses. 20-bit constants are needed to compute the addresses of the operands. MSP430X extended instructions are distinguished by an ‘x’ appended to the mnemonic. (ie: add -> addx) Address specific instructions are appended with an ‘a’ (ie: add -> adda) A few new instructions were added to the MSP430X for improved performance or function. Read: Ch 11.2 in Davies p607 for details.

ECE447: MSP430X Instruction Extensions Same function as MSP430 instructions, but to support 20 bit operands. NOTE: 16 bit instructions CAN be used on the MSP430X when 20-bit modes is not necessary.

ECE447: MSP430X Instruction Extensions New instructions POPM, PUSHM, allowing multiple items to be pushed/popped from the stack. New Multiple shifts instructions, rrcm, rrum, rram, rlam. Logical shift right is added, named rotate right unsigned, rrux

Summary Logic Instructions Arithmetic Instructions Signed Operations Status Register Instructions Flow Control Instructions Jump Instructions