Blinky Lab 3: Blinky Lab Modify the blinky.asm assembly program to blink the LaunchPad red LED quickly on and off at exactly 10 second intervals. Calculate.

Slides:



Advertisements
Similar presentations
Instruction Clock Cycles Generally, 1 cycle per memory access: – 1 cycle to fetch instruction word – +1 cycle if or #Imm – +2 cycles.
Advertisements

Lecture 6 Programming the TMS320C6x Family of DSPs.
MSP430 Assembly Paul Roper
S04: MSP430 Microarchitecture
MSP430 Teaching Materials
Chapter 8 – Stacks BYU CS/ECEn 124Chapter 8 - Stacks2 Topics to Cover… The Stack Subroutines Subroutine Linkage Saving Registers.
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
1 Chapter 3 Jump, Loop, and Call Instructions. 2 Sections 3.1 Loop and Jump Instructions 3.2 Call Instructions 3.3 Time Delay Generation and Calculation.
LC-3 Computer LC-3 Instructions
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
8051 ASSEMBLY LANGUAGE PROGRAMMING
Chapter 4 The Von Neumann Model. BYU CS/ECEn 124Chapter 4 - The Von Neumann Model2 Concepts to Learn… Computer Architecture Von Neumann vs. Harvard MSP430.
2.4 Interrupts Required:PM: Ch 9.1-7, pgs PM: Ch , pgs PM: Ch , pgs PM: Ch , pgs PM: Ch 11.5, pgs
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
Lab 5b: Traffic Stoplight. BYU CS 124RBX4302 Program a pedestrian traffic light for a street with a crosswalk. Use the large red, yellow, and green LEDs.
Chapter 6 – MSP430 Micro-Architecture
Required:PM: Ch 8.1-3, pgs Recommended:Wiki: Microarchitecture Wiki: Addressing_mode Wiki: Three-state logicWiki: Microarchitecture Wiki: Addressing_mode.
MIPS Instruction Set Advantages
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
Lab 7b: Morse Code II
LAB 7: WDT+ and Low-Power Optimization
Chapter 7 – MSP430 Assembler / Linker
Chapter 8 – Stacks
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
S03: Instruction Set Architecture
Machine Instruction Characteristics
BYU CS 124Lab 0 - Warm-up Lab1 Lab 0 – Warm-up Lab 1.Acquire a Texas Instruments MSP430 LaunchPad Development Tool. 2.Setup a CS user account. 3.Install.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Today… Homework #4 due today. Lab 4 – Microarchitecture due Friday. microArch430.exe – Rev 2.1a Download from website Report any problems Questions? BYU.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
The 8051 Assembly Language Branching & Subroutines
The x86 PC Assembly Language, Design, and Interfacing By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey © 2010, 2003, 2000, 1998 Pearson.
Lab 4: MSP430 Microarchitecture
The 8051 Microcontroller and Embedded Systems
Lecture 3 – MSP430 ISA The Instruction Set Reading: Chapter 5: Architecture of the MSP430 Processor.
S06: Assembler / Linker Required: PM: Ch 7, pgs Assembler Directives
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
JUMP, LOOP, AND CALL INSTRUCTIONS
Chapter 3 – Instruction Set Architecture. Instruction Length and Cycles.
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.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
8 085Microprocessor Temp Reg (8) Accumulator (A reg) Flag flip flops(8) Instruction Register (8) Arithmetic Logic Unit ALU Instruction Decoder and Machine.
Chapter 8 String Operations. 8.1 Using String Instructions.
ECE 382 Lesson 22 Readings Lesson Outline Writing Clean Code
Assembly language.
ECE 3430 – Intro to Microcomputer Systems
MIPS Instruction Set Advantages
Lesson Outline Interrupts Admin Assignment #9 due next lesson
Assembly Language Programming of 8085
S04: MSP430 Microarchitecture
Lecture Set 5 The 8051 Instruction Set.
Quiz 4.1 Four LEDs are attached to Port 4, bits 0 thru 3. Indicate which LEDs are ON/OFF after each instruction is executed. P4.7 P4.6 P4.5 P4.4 P4.3.
Instruksi Set Prosesor 8088
Subroutines and the Stack
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
CS 301 Fall 2002 Control Structures
ECE 3430 – Intro to Microcomputer Systems
Branching Instructions
Subroutines and the Stack
Subroutines and the Stack
Computer Operation 6/22/2019.
Computer Architecture and System Programming Laboratory
Presentation transcript:

Blinky Lab 3: Blinky Lab Modify the blinky.asm assembly program to blink the LaunchPad red LED quickly on and off at exactly 10 second intervals. Calculate the number of instructions and instruction cycles used by the processor during the 10 second interval. Use these numbers to determine: the Main System Clock frequency (MCLK), the average number of clock cycles required by the MSP430 to execute an instruction (CPI), and the resulting power of the processor as measured in millions of instructions per second (MIPS). BYU CS 224 Blinky Lab

1. Start with blinky.asm... .cdecls inserts MSP430 symbols ;******************************************************************************* ; CS/ECEn 124 Lab 3 - blinky.asm ; MCLK = _______ cycles / _______ interval = _______ Mhz ; CPI = _______ cycles/ _______ instructions = _______ Cycles/Instruction ; MIPS = MCLK / CPI / 1000000 = _______ MIPS .cdecls C,"msp430.h" ; MSP430 COUNT .equ 0 ; delay count ;------------------------------------------------------------------------------ .text ; beginning of executable code start: mov.w #0x0280,SP ; init stack pointer mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT bis.b #0x01,&P1DIR ; set P1.0 as output mainloop: xor.b #0x01,&P1OUT ; toggle P1.0 mov.w #COUNT,r15 ; use R15 as delay counter delayloop: sub.w #1,r15 ; delay over? jne delayloop ; n jmp mainloop ; y, toggle led ; Interrupt Vectors .sect ".reset" ; MSP430 RESET Vector .word start ; start address .end .cdecls inserts MSP430 symbols into your program .equ creates a symbolic name for a constant xor.b toggles the red LED on or off BYU CS 224 Blinky Lab

Blinky Assembler Directives Lab 3 may require the following assembly directives: Mnemonic and Syntax Description .bss symbol, size in bytes Reserves size bytes in the uninitialized data section .sect "section name" Assembles into a named section .text Assembles into the executable code section .byte value1[, ..., valuen] Initializes one or more bytes in current section .word value1[, ... , valuen] Initializes one or more 16-bit integers symbol .equ value Equates value with symbol symbol .set value .cdecls C,"filename" Include C header in assembly code .end Ends program BYU CS 224 Blinky Lab

Instructions You Need to Know Blinky Instructions You Need to Know Lab 3 may require the following assembly instructions: Instruction Description mov.w #<value>,<register> Replace contents of <register> with <value> bis.b #0x01,&P1DIR Enable LED (set pin 2 as output). bis.b #0x01,&P1OUT bic.b #0x01,&P1OUT xor.b #0x01,&P1OUT Turn LED on (set pin 2 high, 3.3v). Turn LED off (set pin 2 low, 0v). Toggle LED on / off. sub.w #1,<register> Decrement <register> by 1 and set Z status. jne <label> jmp <label> Jump to <label> if Z bit is 0. Jump to <label>. call #<label> push <register> pop <register> ret Call subroutine (place return on stack). Save <register> on stack. Restore <register> from stack. Return from subroutine (pop stack). BYU CS 224 Blinky Lab

2. Add code to blink LED... Add code here to Quickly blink LED Blinky 2. Add code to blink LED... ;******************************************************************************* ; CS/ECEn 124 Lab 3 - blinky.asm ; MCLK = _______ cycles / _______ interval = _______ Mhz ; CPI = _______ cycles/ _______ instructions = _______ Cycles/Instruction ; MIPS = MCLK / CPI / 1000000 = _______ MIPS .cdecls C,"msp430.h" ; MSP430 COUNT .equ 0 ; delay count ;------------------------------------------------------------------------------ .text ; beginning of executable code start: mov.w #0x0280,SP ; init stack pointer mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT bis.b #0x01,&P1DIR ; set P1.0 as output mainloop: bis.b #0x01,&P1OUT ; turn LED on ; put some delay here... bic.b #0x01,&P1OUT ; turn LED off mov.w #COUNT,r15 ; use R15 as delay counter delayloop: sub.w #1,r15 ; delay over? jne delayloop ; n jmp mainloop ; y, toggle led ; Interrupt Vectors .sect ".reset" ; MSP430 RESET Vector .word start ; start address .end Add code here to Quickly blink LED (Needs short delay) Add enough instructions Here to delay 10 seconds BYU CS 224 Blinky Lab

3. Include Instruction Cycles... Blinky 3. Include Instruction Cycles... ;******************************************************************************* ; CS/ECEn 124 Lab 3 - blinky.asm ; MCLK = _______ cycles / _______ interval = _______ Mhz ; CPI = _______ cycles/ _______ instructions = _______ Cycles/Instruction ; MIPS = MCLK / CPI / 1000000 = _______ MIPS .cdecls C,LIST, "msp430.h“ ; MSP430 COUNT .equ 0 ; delay count ;------------------------------------------------------------------------------ .text ; beginning of executable code start: mov.w #0x0280,SP ; init stack pointer mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT bis.b #0x01,&P1DIR ; set P1.0 as output mainloop: xor.b #0x01,&P1OUT ; toggle P1.0 mov.w #COUNT,r15 ; use R15 as delay counter delayloop: sub.w #1,r15 ; delay over? jne delayloop ; n jmp mainloop ; y, toggle led ; Interrupt Vectors .sect ".reset" ; MSP430 RESET Vector .word start ; start address .end List cycles for each instruction in the comments field (After semi-colon) 2 5 4 1 Count the number of instructions executed in 10 sec interval BYU CS 224 Blinky Lab

Cycles Per Instruction... Blinky Cycles Per Instruction... Generally, 1 cycle per memory access: 1 cycle to fetch instruction word +1 cycle if source is @Rn, @Rn+, or #Imm +2 cycles if source uses indexed mode 1st to fetch base address 2nd to fetch source Includes absolute and symbolic modes +2 cycles if destination uses indexed mode +1 cycle if writing destination back to memory +1 cycle if writing to PC (R0) Jump instructions are always 2 cycles BYU CS 224 Blinky Lab

Example Cycles Per Instruction... Instruction Clock Cycles Example Cycles Per Instruction... Example Src Dst Cycles Length add R5,R8 Rn Rm 1 1 add @R5,R6 @Rn Rm 2 1 mov @R5+,R0 @Rn+ PC 3 1 add R5,4(R6) Rn x(Rm) 4 2 add R8,EDE Rn EDE 4 2 add R5,&EDE Rn &EDE 4 2 add #100,TAB(R8) #n x(Rm) 5 3 add &TONI,&EDE &TONI &EDE 6 3 add #1,&EDE #1 &EDE 4 2 BYU CS 224 Blinky Lab

4. Calculate MCLK, CPI, MIPS... Blinky 4. Calculate MCLK, CPI, MIPS... List total number of instruction cycles here Calculate the Master Clock speed: MCLK = cycles / 10 ;******************************************************************************* ; CS/ECEn 124 Lab 3 - blinky.asm ; MCLK = _______ cycles / _______ interval = _______ Mhz ; CPI = _______ cycles/ _______ instructions = _______ Cycles/Instruction ; MIPS = MCLK / CPI / 1000000 = _______ MIPS .cdecls C,LIST, "msp430.h" ; MSP430 COUNT .equ 0 ; delay count ;------------------------------------------------------------------------------ .text ; beginning of executable code Calculate the average cycles per instruction: CPI = cycles / instructions Finally, calculate the raw speed of the processor (in MIPS) by MIPS = MCLK / CPI / 1,000,000 BYU CS 224 Blinky Lab

Blinky Lab Requirements 2 points Your blinky program quickly blinks the red LED on and off every 10 seconds (accurate to plus or minus 1 second per minute). 1 point The assembler directive .equ is used to define all delay counts and constants. 2 points The correct number of clock cycles for every assembly instruction is found in the comment field of each instruction. 2 points The clock speed (MCLK) of your LaunchPad processor is determined by dividing the number of instruction cycles in the timing interval (both the inner and outer loops must be used in your calculations) by the time of the interval. The speed of the processor is accurate to at least 4 significant digits. All calculations and resulting MCLK value are included in the comments at the beginning of your program. 2 points The average cycles per instruction (CPI) is determined by dividing the total number of cycles in the timing interval by the number of instructions executed in the interval. All CPI calculations and result are included in the comments at the beginning of your program. 1 point The raw speed of the processor (as measured in MIPS) is determined by dividing the processor clock frequency (MCLK) by the average cycles per instruction (CPI), divided by 1 million. All processor MIPS calculations and result are included in the comments at the beginning of your program. +1 point A 1/10 of a second "inner" loop is programmed as a subroutine and "called" 100 times for each 10 second timing interval BYU CS 224 Blinky Lab

5. BONUS: Delay subroutine... Blinky 5. BONUS: Delay subroutine... ;******************************************************************************* ; CS/ECEn 124 Lab 3 - blinky.asm ; MCLK = _______ cycles / _______ interval = _______ Mhz ; CPI = _______ cycles/ _______ instructions = _______ Cycles/Instruction ; MIPS = MCLK / CPI / 1000000 = _______ MIPS .cdecls C,"msp430.h" ; MSP430 COUNT .equ 0 ; delay count ;------------------------------------------------------------------------------ .text ; beginning of executable code start: mov.w #0x0280,SP ; init stack pointer mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT bis.b #0x01,&P1DIR ; set P1.0 as output mainloop: bis.b #0x01,&P1OUT ; turn LED on ; put some delay here... bic.b #0x01,&P1OUT ; turn LED off call #myDelay jmp mainloop ; y, toggle led myDelay: mov.w #COUNT,r15 ; use R15 as delay counter delayloop: sub.w #1,r15 ; delay over? jne delayloop ; n ret ; y, return from subroutine Use call instruction to "call" 1/10 second delay subroutine. Call subroutine 100 times. Use ret instruction to return from subroutine BYU CS 224 Blinky Lab

BYU CS 224 Blinky Lab

Supplement Material

Cycles Per Instruction... Instruction Clock Cycles Cycles Per Instruction... Jump instructions are always 2 cycles. BYU CS 224 Blinky Lab

Assembler Coding Style Assembler Primer Assembler Coding Style Instructions / DIRECTIVES start in column 12. No line should exceed 80 characters. Operands start in column 21. Comments start in column 45. ;************************************************************************* ; CS/ECEn 124 Lab 1 - blinky.asm: Software Toggle P1.0 ; ; Description: Toggle P1.0 by xor'ing P1.0 inside of a software loop. DELAY .equ 0 .cdecls C,"msp430.h" ; MSP430 .text ; beginning of executable code start: mov.w #0x0280,SP ; init stack pointer mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop WDT bis.b #0x01,&P1DIR ; set P1.0 as output mainloop: xor.b #0x01,&P1OUT ; toggle P1.0 mov.w #DELAY,r15 ; use R15 as delay counter delayloop: sub.w #1,r15 ; delay over? jnz delayloop ; n jmp mainloop ; y, toggle led .sect ".reset" ; MSP430 RESET Vector .word start ; start address .end Labels start in column 1 and are 10 characters or fewer. Use macros provided in the MSP430 header file. The ".cdecls" directive inserts a header file into your program. Begin writing your assembly code after the ".text" directive. Instructions are lower case and macros are UPPER CASE. Assembler directives begin with a period (.) The ".end" directive is the last line of your program. BYU CS 224 Blinky Lab

Assembly Subroutines Subroutines Instruction Description call ret push pop BYU CS 224 Blinky Lab

CCS Breakpoints/Single Step Blinky CCS Breakpoints/Single Step BYU CS 224 Blinky Lab

Instructions You Need to Know Blinky Instructions You Need to Know Lab 3 may require the following assembly instructions: Instruction Description mov.w #<value>,<register> Replace contents of <register> with <value> (no status bits change). bis.b #0x01,&P1DIR Set pin 2 of MSPG2553 as output. bis.b #0x01,&P1OUT Turn LED on (set pin 2 high, 3.3v). bic.b #0x01,&P1OUT Turn LED off (set pin 2 low, 0v). sub.w #1,<register> Decrement <register> by 1 and set Z status bit to 1 if result is zero, else 0. jne <label> Jump to <label> if Z bit is 0. jmp <label> Jump to <label>. xor.b #0x01,&P1OUT Toggles pin 2 – turns LED off if on, and on if off. BYU CS 224 Blinky Lab

Blinky Assembler Directives Lab 3 may require the following assembly directives: Directive Description <symbol> .equ <value> <symbol> .set <value> Create symbol .text Start code section .cdecls Include C header file .end End assembly process .sect <symbol> Start <symbol> section <symbol> .byte <size> <symbol> .word <size> .bss <symbol>,<size> BYU CS 224 Blinky Lab