ECE 382 Lesson 8 Lesson Outline Miniquiz Assignment 3

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

ECE 447 Fall 2009 Lecture 2: TI MSP430 Software Development C and MSP430 Assembly.
MSP430 Teaching Materials
The 8051 Microcontroller and Embedded Systems
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
Procedures and Stacks. Outline Stack organization PUSH and POP instructions Defining and Calling procedures.
CS2422 Assembly Language & System Programming September 19, 2006.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
Flow Control Instructions
CS 300 – Lecture 19 Intro to Computer Architecture / Assembly Language C Coding & The Simulator Caches.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
8051 ASSEMBLY LANGUAGE PROGRAMMING
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
ARM Core Architecture. Common ARM Cortex Core In the case of ARM-based microcontrollers a company named ARM Holdings designs the core and licenses it.
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
CIS Computer Programming Logic
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.
1/2002JNM1 Basic Elements of Assembly Language Integer Constants –If no radix is given, the integer is assumed to be decimal. Int 21h  Int 21 –A hexadecimal.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
1 ICS 51 Introductory Computer Organization Fall 2009.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
Assembly language programming
Chapter 1.2 Introduction to C++ Programming
ECE 382 Lesson 22 Readings Lesson Outline Writing Clean Code
ECE 3430 – Intro to Microcomputer Systems
Format of Assembly language
Chapter 1.2 Introduction to C++ Programming
Assembly Language (continue)
ECE 382 Lesson 6 Lesson Outline Status Register Flow of Control
Microprocessor Systems Design I
Homework Reading Labs PAL, pp
ECE 382 Lesson 7 Lesson Outline Miniquiz Instruction Execution Time
Microprocessor Systems Design I
Objectives Identify the built-in data types in C++
The 8051 Microcontroller and Embedded Systems
Wed. Sept 6 Announcements
ECE 382 Lesson 4 Lesson Outline Readings
Microprocessor and Assembly Language
L7 – Assembler Directives
Defining Types of data expression Dn [name] expression Dn [name]
Symbolic Instruction and Addressing
Roller Coaster Design Project
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Chapter 11 Introduction to Programming in C
ECE 3430 – Intro to Microcomputer Systems
Chapter 4 –Requirements for coding in Assembly Language
Symbolic Instruction and Addressing
Chapter 4 –Requirements for coding in Assembly Language
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
3.
Chapter 11 Introduction to Programming in C
COMS 361 Computer Organization
Instructions in Machine Language
8051 ASSEMBLY LANGUAGE PROGRAMMING
Computer Architecture and System Programming Laboratory
Chapter 6 –Symbolic Instruction and Addressing
Computer Architecture and Assembly Language
Getting Started With Coding
Presentation transcript:

ECE 382 Lesson 8 Lesson Outline Miniquiz Assignment 3 Assembler Directives Structured Design and Test Assembly Code Style Testing Lab Guidance Lab 1 Introduction Admin Assignment 3 (due today) Lab#1 Prelab due BOC next lesson ***Meet in 2E48 for Lesson 9 / all Labs***

Assignment 3 Assignment 3

Software Flow Chart / Algorithm Ex: Assignment 3

Basic Flow Chart Symbols https://www.smartdraw.com/flowchart/flowchart-symbols.htm

Status register and Jumps 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Reserved V SCG1 SCG0 OSCOFF CPUOFF GIE N Z C Condition Code Assembly Instruction Description 000 JNE/JNZ Jump if Z==0 (if !=) 001 JEQ/JZ Jump if Z==1 (if ==) 010 JNC/JLO Jump if C==0 (if unsigned <) 011 JC/JHS Jump if C==1 (if unsigned >) 100 JN Jump if N==1 - Note there is no jump if N==0 101 JGE Jump if N==V (if signed >=) 110 JL Jump if N!=V (if signed <) 111 JMP Jump unconditionally

Assembler Directives .cdecls C,LIST,"msp430.h" .text ;put code in the text section - maps to FLASH (ROM) StopWDT mov.w #WDTPW|WDTHOLD .data ;put code into the data section - maps to RAM .sect ".reset" ;put this at the reset vector .sect .stack ;make this the location of the stack MY_RESULTS: .space 20 ; reserves 20 bytes ----------------- To use: mov #MY_RESULTS, r5 ; pointer address into r5 mov #0xfefe, &MY_RESULT ; put fefe into 1st two bytes

Assembler Directives ; Can initialize ROM; cannot initialize RAM ;initialize sequence of bytes bytes: .byte 9,8,7,6,5,4,3,2,1 ;initialize sequence of words words: .word 0x1111,0x2222,0x3333,0x4444 ;initialize strings myStr: .string "hello, world!" ;initialize characters Chars: .char 'a','b','c','d‘ ; see in CCS

Assembler Directives ; .equ  assign a label to a particular value SEVENTEEN: .equ 0x11 ;align a variable with a particular multiple of bytes (useful to ensure word on even address) .align 2 ;probably won't use these often, but they're available .float ;floating point value .int ;16-bit int .short ;16-bit int .long ;32-bit int

Structured Design and Test Guiding Principle: Get one small thing working Don't write the entire program in one go, then press go, and hope it works. When the entire program is the space you're looking for a bug, it makes debugging really hard. Modularity Modularity is the practice of breaking down a larger program into smaller tasks. Makes code more reusable Makes code more readable Make individual taks more manageable Focus on simpler tasks Tough to hold a big problem in your brain

Example Design Concurrent Processes Process#1 Process#2 Process#3 Init Process#1 Process#2 Process#3 Process#4 Init Init Init Init New = 1 image No Write Image Memory Msg#1 Got msg? Send Msg No New = 1 New image? Yes Do math image No Got Ack? Ack#1 Send Ack Yes FIFO count New data? No New = 0 Read Image Yes count++ Data#2 Write data No Do math Data#2 Yes Process image Memory Yes Locked? locked? Yes locked? Locked? count-- Read data Done? No No No Do math Lock Lock Lock Lock Yes Done? No Write D Read D Write Data Read Data unlock unlock Yes Done? Done? No Yes Yes

Testing How do we know when we're done with a task? Testing! You should specify the tests you'll run on the code you're going to write in advance of writing the code. It's a little more work up front, but will save you time debugging down the road. Write tests that cover all cases - particularly edge cases.

Assembly Code Style Guidelines Comments Assume the reader is a competent assembly language programmer Comment above blocks of code to convey purpose Only comment individual lines when purpose is unclear Labels Descriptive! loop or loop1 or l1 or blah - not acceptable! Constants Use .equ syntax for all constants! SEVENTEEN: .equ 0x11 Don't want to see naked values

Assembly Code Style Guidelines Instruction Choice Use the instruction that makes your code readable! JHS rather than JC INCD rather than ADD #2 Well-written code requires few comments Spacing Align your code to make it readable Put whitespace between logical blocks of code

What is good and bad about this code? Example Code What is good and bad about this code? http://ece.ninja/382/notes/L8/hw_sample.html

Write a program that will write your name in memory 6 times: Can use: Programming Exercise 1 Write a program that will write your name in memory 6 times: Can use: myname: .string "Jeff Falkinburg!" numNames: .equ 0x0006

Programming Exercise 2 Write a program that counts the number of 1s in a 16-Bit Binary number and stores it at &0x0300

Lab Notebook Expectations Lab Noteboook Standards https://github.com/jfalkinburg/ECE_382_Lab_Ex

Lab 1 Introduction The goal of this lab is to implement a simple calculator using assembly language. Lab 1 How This Lesson Applies Use assembler directives: .byte to put your test program into memory .space to reserve space for your results Where is this going to go? Labels for your program / results .equ for key constants Modularity Section to store results of ops Section for each op Testing Specify multiple testing sequences at the beginning! I'll test your code with a few of my own