Chapter 07 - MSP430 Assembler

Chapter 07 - MSP430 Assembler - Chapter 7 MSP430 Assembler...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 7 – MSP430 Assembler / Linker
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 2 Topics to Cover… High Level vs. Assembly MSP430 Assembler Assembly Code Assembly Process Assembly Directives Assembly Sections Linker Libraries Code Composer Essentials/Studio Device: LED’s Systematic Decomposition Assembly Instructions
Background image of page 2
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 3 Moving Up Levels of Abstraction Problems Algorithms Language Machine (ISA) Architecture Microarchitecture Circuits Devices Transistors Logic gates, multiplexers, memory, etc. MSP430 Architecture Machine code Assembly code
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 4 High Level vs. Assembly High Level Languages More programmer friendly More ISA independent Each high-level statement translates to several instructions in the ISA of the computer Assembly Languages Lower level, closer to ISA Very ISA-dependent Each instruction specifies a single ISA instruction Makes low level programming more user friendly More efficient code High Level vs. Assembly
Background image of page 4
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 5 Why Assembly Code? Allows us to work at a slightly higher level than machine language. Allows us to use symbolic names for opcodes Allows us to use symbolic names for memory locations - SUM, PRODUCT Don’t need to know every address of every storage location. Calculates addresses for us – really a big deal! Helps to allocate memory locations. Provides additional error checking High Level vs. Assembly
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 6 Assembler An assembler outputs an object file An assembly program is a text file containing assembly instructions, directives, macros, and comments An assembler translates a program into machine code MSP430 Assembler An object file is input to a linker program
Background image of page 6
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 7 Assembler Syntax Each assembly line begins with either a label, a blank (tab), an asterisk, or a semicolon Each line has four fields: {label[:]} mnemonic {operand list} {;comment} Some line examples are: .sect ".sysmem" ; data space var1 .word 2 ; variable var1 declaration .text ; program space loop: mov #COUNT,r5 ; get counter .end ; end of program MSP430 Assembler
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
BYU CS/ECEn 124 Chapter 7 - MSP430 Assembler 8 Assembly Code Example ;******************************************************************************* ; CS/ECEn 124 Lab 4 - morse.asm: Student Code ;******************************************************************************* .cdecls C,LIST, "msp430x22x4.h“ ; include C header COUNT .equ 2000 ;------------------------------------------------------------------------------ .data ; data .bss cnt,2 ; ISR counter ;------------------------------------------------------------------------------ .text ; Program reset RESET: mov.w #0x0280,SP ; Initialize stack pointer mov.w #WDT_MDLY_0_5,&WDTCTL ; Set Watchdog interval to ~0.5ms mov.b #WDTIE,&IE1 ; Enable WDT interrupt bis.b #0x01,&P1DIR ; P1.0 output bis.b #0x20,&P4DIR ; P4.0 output mov.w #COUNT,&cnt ; initialize counter bis.w #LPM0+GIE,SR; Enter LPM0 w/ interrupt jmp $ ; Loop forever; interrupts do all ; Watchdog Timer interrupt service routine ; WDT_ISR: xor.b #0x20,&P4OUT; pulse buzzer dec.w &cnt ; decrement counter jne WDT_exit mov.w #COUNT,&cnt ; initialize counter xor.b #0x01,&P1OUT; toggle P1.0 WDT_exit: reti ; return from interrupt .sect ".int10" ; MSP430 RESET Vector .word WDT_ISR
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 02/06/2012.

Page1 / 83

Chapter 07 - MSP430 Assembler - Chapter 7 MSP430 Assembler...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online