© 2010 Kettering University, All rights reserved..

Slides:



Advertisements
Similar presentations
© 2010 Kettering University, All rights reserved..
Advertisements

Floyd, Digital Fundamentals, 10 th ed EET 2261 Unit 7 Indexed Addressing Mode Read Mazidi, Chapter 6. Homework #7 and Lab #7 due next week. Quiz next week.
© 2010 Kettering University, All rights reserved..
Goal: Write Programs in Assembly
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
© 2010 Kettering University, All rights reserved..
ME 142 Engineering Computation I Fundamentals of Procedural Computer Programming.
EET 2261 Unit 5 Tables; Decision Trees & Logic Instructions
© 2010 Kettering University, All rights reserved..
© 2010 Kettering University, All rights reserved..
Assembler Programming Chapter 6. EEL-4746 Best Practices.
The 68HC11 Microcontroller Minnesota State University, Mankato
H. Huang Transparency No.1-1 The 68HC11 Microcontroller Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
© 2010 Kettering University, All rights reserved..
COMP3221: Microprocessors and Embedded Systems--Lecture 4 1 COMP3221: Microprocessors and Embedded Systems Lecture 4: Number Systems (II)
Programming the HC12 in C. Some Key Differences – Note that in C, the starting location of the program is defined when you compile the program, not in.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Chapter 3 Planning Your Solution
© 2010 Kettering University, All rights reserved..
© 2010 Kettering University, All rights reserved..
CEG 320/520: Computer Organization and Assembly Language ProgrammingFlow Control 1 Flow Control.
© 2010 Kettering University, All rights reserved..
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
CIS Computer Programming Logic
© 2010 Kettering University, All rights reserved..
Physics 413 Chapter 1: Introduction to the HCS 12 Microcontroller.
© 2010 Kettering University, All rights reserved..
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Computer Architecture and the Fetch-Execute Cycle
Objectives Implement pointers using indexed addressing modes Use pointers to access arrays, strings, structures, tables, and matrices Present finite-state.
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
© 2010 Kettering University, All rights reserved..
© 2010 Kettering University, All rights reserved..
6-1 EE 319K Introduction to Microcontrollers Lecture 6: Indexed Addressing Mode and Variants, Functional Debugging, Arrays, Strings.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Introduction to branching.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
ECE Lecture 1 1 L8:Flowcharting a program Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
ECE 265 – LECTURE 11 Editing and the Assembler (updated 11/11/10) 12/15/ ECE265.
ECE Lecture 21 Typical Assembly Language Program Bugs.
Structured Programming (4 Credits)
Microcontroller Fundamentals & Programming Arithmetic Instructions.
Our programmer needs to do this !
© 2010 Kettering University, All rights reserved..
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Programming Model CS 333 Sam Houston State University Dr. Tim McGuire.
Lec. 10 Assembly Programming Dr. Tamer Samy Gaafar Microprocessors.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
1 Subroutines Advanced Programming. 2 Top-Down approach to problem solving Algorithm step by step description of how to solve a problem Divide and Conquer.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Addressing Modes in Microprocessors
HC11 Programming.
Microprocessor T. Y. B. Sc..
ECE 3430 – Intro to Microcomputer Systems
1. Introduction A microprocessor executes instructions given by the user Instructions should be in a language known to the microprocessor Microprocessor.
ECE 3430 – Intro to Microcomputer Systems
Programming Fundamentals
COMP3221: Microprocessors and Embedded Systems
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Computer Organization and ASSEMBLY LANGUAGE
Branching and Loops.
ME 142 Engineering Computation I
Simple Implementation
ICT Gaming Lesson 2.
Start or end of algorithm: Action/process step:
Indexing Through Memory
Computer Systems An Introducton.
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
Presentation transcript:

© 2010 Kettering University, All rights reserved.

Microcomputers I – CE 320 Electrical and Computer Engineering Kettering University Jaerock Kwon, Ph.D.

Announcements Quiz 2 today!  Starts at 10:50AM

Lecture 9: Assembly Language Example

Today’s Topics Flowcharts Practice assembly programming

Flowcharts There are other more sophisticate methods of representing programs. Flowcharts work well for software written in assembly code level. We will see logical building blocks in flowchart formats along with assembly code templates.

Flowcharts There are many more symbols other than these. Shapes may be different. In this course, those four symbols are pretty much all we need. Meaning of symbols Decision Start or End Process flow

Flowcharts Set CCR bits for decision Bxx Process A Process B code If(PillColor == RED) RealWorld Else Matrix Example: ldaaPillColor cmpa#RED bnelmatrix RealWorld bralskip lmatrix:Matrix lskip:... If-Then-Else Color of Pill is RED? Matrix RealWorld TRUE FALSE

Flowcharts Set CCR bits for decision Bxx past BRA Process code Set CCR bits for decision BRA to Bxx Example: ldaaKnowThis lloop:cmpa#YES beqlnext StudyMore ldaaKnowThis bralloop lnext:NextStep While-Do KnowThis? StudyMore TRUE FALSE

Flowcharts Process code Set CCR bits Bxx to Process code Example: loop:DoSomething ldaaResult beqldone braloop ldone: Repeat-Until Is the Job done? FALSE TRUE DoSomething

Flowcharts Set CCR bits Bxx to Process 1 Set CCR bits Bxx to Process 2 … Set CCR bits Bxx to Process N Default Process code BRA past Process N code Process 1 code BRA past process N code Process 2 code BRA past Process N code … Process N code Example: ldaanTemp cmpa#20 bhsl1 TurnOnHeater bralres l1:cmpa#70 bhil2 FlashIndicator bralres l2: cmpa#100 bhil3 TurnOnCooler bralres l3:Alarm lres: Case nTemp < 20 nTemp < 20 TurnOnHeater FALSE TRUE nTemp < 70 nTemp < 70 FlashIndicator FALSE TRUE nTemp < 100 nTemp < 100 TurnOnCooler FALSE TRUE Alarm

Flowchart Guidelines Do not refer to registers in the flowchart Arrows should never cross  They will not need to if the flowchart represents a structured program The purpose is to remove any questions about how to program and understand the algorithm, and this usually determines when the flowchart contains enough detail.

Assembly Example Convert an array of 4-byte Big-Endian values to an array of Little-Endian values. Let  $1000 hold the address of the array of Big-Endian values,  $1002 hold the address of the array for the Little-Endian values,  $1004 hold the two-byte length of numbers to convert. Write an assembly program to implement these requirements.

4. There are no more elements TRUE FALSE Start End 1: Point to the first BE item 2: Point to the first LE item 3: Make a copy of the length 5: Copy 1st BE byte to 4th LE byte 6: Copy 2 nd BE byte to 3 rd LE byte 7: Copy 3 rd BE byte to 2 nd LE byte 8: Copy 4 th BE byte to 1 st LE byte 9: Point to next elements & dec length

org $1000 Bendds.w 1 LEnd ds.w 1 Lengthds.w 1 TmpLends.w1 org $2000 ldx BEnd ldy Lend ldd Length Loopstd TmpLen; 3 beq Done ldaa 0,x; 3 staa 3,y; 2 ldaa 1,x; 3 staa 2,y; 2 ldaa 2,x; 3 staa 1,y; 2 ldaa 3,x; 3 staa 0,y; 2 inx; 1 inx iny; 1 iny ldd TmpLen; 3 subd#$0001 bra Loop Doneswi 4. There are no more elements TRUE FALSE Start End 1: Point to the first BE item 2: Point to the first LE item 3: Make a copy of the length 5: Copy 1st BE byte to 4th LE byte 6: Copy 2 nd BE byte to 3 rd LE byte 7: Copy 3 rd BE byte to 2 nd LE byte 8: Copy 4 th BE byte to 1 st LE byte 9: Point to next elements & dec length

org $1000 Bendds.w 1 LEnd ds.w 1 Lengthds.w 1 org $2000 ldx BEnd ldy Lend ldd Length Loopbeq Done movb 0,x,3,y; 5 movb 1,x,2,y movb 2,x,1,y movb 3,x,0,y leax 4,x; 2 leay 4,y subd #1; 2 bra Loop Doneswi 4. There are no more elements TRUE FALSE Start End 1: Point to the first BE item 2: Point to the first LE item 3: Make a copy of the length 5: Copy 1st BE byte to 4th LE byte 6: Copy 2 nd BE byte to 3 rd LE byte 7: Copy 3 rd BE byte to 2 nd LE byte 8: Copy 4 th BE byte to 1 st LE byte 9: Point to next elements & dec length Note: You can save 10 (= 3 + 2x2 + 3) cycles.

Questions?

Wrap-up Flowcharts  Templates will be greatly helpful. Assembly program example What we’ve learned

What to Come Arithmetic instructions Logic instructions