Introduction to Programming

Similar documents
EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Exam I Review February 2017

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

HC11 Instruction Set Architecture

HC11 Instruction Set Architecture

What is an Addressing Mode?

Most of the HC12 s instructions access data in memory There are several ways for the HC12 to determine which address to access

EE 3170 Microcontroller Applications

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Introduction to Computers - Chapter 4


Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

Assembly Language Programming of 8085

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

EE 3170 Microcontroller Applications

A Simple MC9S12 Program

LECTURE #21: G-CPU & Assembly Code EEL 3701: Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Mark II Aiken Relay Calculator

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

Assembly Language Programming of 8085

Chapter 7 Central Processor Unit (S08CPUV2)

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Disassembly of MC9S12 op codes Decimal, Hexadecimal and Binary Numbers

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

Introduction to Microcontrollers II

Chapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics

0b) [2] Can you name 2 people form technical support services (stockroom)?

Introduction to Microcontrollers II

CS/ECE 5780/6780: Embedded System Design

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Cross Assembly and Program Development

Introduction to Microcontrollers

Processor design - MIPS

SECTION 6 CENTRAL PROCESSING UNIT

ECE 372 Microcontroller Design Basic Assembly Programming. ECE 372 Microcontroller Design Basic Assembly Programming

Processor Design. ELEC 418 Advanced Digital Systems Dr. Ron Hayne

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

ECE 372 Microcontroller Design Assembly Programming Arrays. ECE 372 Microcontroller Design Assembly Programming Arrays

S12CPUV2. Reference Manual HCS12. Microcontrollers. S12CPUV2/D Rev. 0 7/2003 MOTOROLA.COM/SEMICONDUCTORS

CC312: Computer Organization

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Chapter 4. MARIE: An Introduction to a Simple Computer

Introduction to Microcomputer Systems Addressing modes

Homework 12 Solutions

EMCH 367 Fundamentals of Microcontrollers Example7 EXAMPLE 7

Hardware Level Organization

the SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.

Lecture1: introduction. Outline: History overview Central processing unite Register set Special purpose address registers Datapath Control unit

Using the stack and the stack pointer

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

MOXSYN. General Description. Features. Symbol

Outcomes. Lecture 13 - Introduction to the Central Processing Unit (CPU) Central Processing UNIT (CPU) or Processor

Microcomputer Architecture and Programming

Computer Organization I. Lecture 28: Architecture of M68HC11

ECE 4510/5530 Microcontroller Applications Chapter 1

Motorola HC11. Fun with Microcontrollers and Embedded Systems

2) [ 2 marks] Both of the following statements cause the value $0300 to be stored in location $1000, but at different times. Explain the difference.

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

THE MICROPROCESSOR Von Neumann s Architecture Model

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Where Does The Cpu Store The Address Of The

EE 3170 Microcontroller Applications

Decimal, Hexadecimal and Binary Numbers Writing an assembly language program

CPU Structure and Function

Introduction to Microcontrollers

Introduction to CPU architecture using the M6800 microprocessor

MARIE: An Introduction to a Simple Computer

Wednesday, September 13, Chapter 4

MC9S12 Address Space

Chapter 2 Instruction Set Architecture

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Chapter 4. Chapter 4 Objectives. MARIE: An Introduction to a Simple Computer

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

Lecture 9 Subroutines

538 Lecture Notes Week 1

Microcontrollers. Microcontroller

SISTEMI EMBEDDED. Computer Organization Central Processing Unit (CPU) Federico Baronti Last version:

Lecture #3 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Wednesday, 20-Jan-2015

ECE L A B 1 Introduction ASSEMBLY PROGRAMMING WITH MINIIDE

Y = (A + C) (A + B) (B + C)

538 Lecture Notes Week 2

Wednesday, February 4, Chapter 4

2.2 THE MARIE Instruction Set Architecture

Computer Organization Question Bank

MARIE: An Introduction to a Simple Computer

538 Lecture Notes Week 5

ELEG3924 Microprocessor

538 Lecture Notes Week 5

ECE372 CodeWarrior Simulator Andreou/Michaelides

Lecture 5: Computer Organization Instruction Execution. Computer Organization Block Diagram. Components. General Purpose Registers.

Transcription:

Introduction to Programming Chapter 2 Microcontrollers

Objectives Describe the difference between source code and machine code. Define opcode, operand, and address of an operand. Explain the purpose of memory addressing modes

Objectives Show how memory addressing modes work in the HC11 Explain how an instruction is fetched from memory and executed ecuted by the processor. Use flowcharts to show the flow/function of a program.

Programming the Computer Types of Computers Dedicated computers designed to run only one program computers in your car microcontroller General-purpose computers designed to run multiple programs desktop computer running word processor spreadsheet, etc.

Levels of Program Languages Lowest Level Machine Code Highest Level Basic

Source Code Written in a programming language English like words that communicate instructions to the computer. Levels of programming g languages g

Relative Level of Programming Highest Level Lowest Level BASIC C Assembler Machine Code

Programming Levels English if X is equal to Y, then set tz equal lto X, otherwise set Z equal to Y BASIC if (X==Y) then Z=X else Z=Y end if C if (x==y) Z=X; else Z=Y; Assembler LDAA X CMPA Y BEQ PAST LDAA Y PAST STAA Y MACHINE 96 00 91 01 27 02 96 01 97 02

Advantage of High-Level Source code is portable Must be compiled

Assembler Language Close to actual machine code Portability limited to processors within the same family. Advantage is tends to be smaller and run faster

Machine Code Only language that computer hardware understands Referred to as object code In binary Consists of operational codes operands (data) address of the operands

OPCODES Multi-bit code that identifies the instruction Contains information about the instruction and how to execute ecute the instruction Single instruction will be implemented with one or more opcodes

Operand Data that is required by the instruction addition instruction adds operands load instruction reads an operand from an address and loads it into a processor register. Operand field is a group of up to three bytes following the opcode.

Address Pointer into memory. Each memory address is an unique address by which it is identified. Address points to a byte of memory

Address Types Absolute A complete address or an address that contains all the address bits Offset commonly used to allow addressing of memory without specific reference to the entire address.

HC11 Machine Code Made up of OPCODES, operands, and addresses. Uses an 8-bit OPCODE and supports various ways of accessing operands in memory. 256 unique OPCODES can be generated. WHY?

Prefix for Number Representation binary % octal @ decimal nothing or & hexadecimal $

Immediate Mode Machine Code Source Code 86 10 LDAA #$10 opcode immediate data mnemonic

Extend Mode Machine Code Source Code B7 01 9B STAA $019B extended mode effective address

Inherent Mode Machine Code Source Code 1B ABA

Memory Addressing Modes Immediate operand immediately follows the opcode in memory Absolute used to access operand directly from memory Implied location of the date implied by the instruction

Memory Addressing Modes Indexed uses an address in an index register combined with an address offset Relative used to change the flow of the program

HC11 Addressing Modes Immediate (IMM) LDAA #$29 # indicates IMM mode

Extended (EXT) Motorola s name for Absolute Addressing LDAA $000B

Direct (DIR) A form of absolute addressing LDAA $0B 8-bit address becomes the low-order byte of the effective address.

Inherent (INN) Used when the operand is inherent or implied. The operands are already contained in the processor registers. ABA INX

Indexed (INDX, INDY) used when the operand may be at varying addresses with the 64k memory map. LDAA $02,X $02 is an offset X is used for the effective address calculation

Relative (REL) Used only for branch instructions. relative mode instructions do not process data, but control the flow of the epoga program.

Processing Instructions Machine cycles a short set of steps that are performed during a single clock cycle. HC11 performs a four step process during each machine cycle.

Four Step Process Phase One Controls steps one and two Deal with the program counter Phase Two Controls the last two steps Deals with memory access and processing

Fetch Cycle reads the instruction OPCODE from the memory. instruction OPCODE is always located in memory at the address that is contained in the program counter. first machine cycle for each instruction.

Machine cycles 1. Move contents of the PC to the MAR 2. Increment the PC. MAR to address bus 3. Enable memory OPCODE put on data bus 4. OPCODE to the IR where it is decoded.

Execute Cycle requires one or more machine cycles built-in in sequence of events that completes the operation of the instruction. instruction execution is unique for each instruction

Example LDAA #$A8 Fetch 1 machine cycle Execute 1 machine cycle 1. PC to MAR 2. Increment PC 3. Enable memory location, operand put on data bus 4. Operand loaded in AccA

LDAB $019B Fetch 1 machine cycle Execute 3 machine cycles

Example ABA Fetch 1 machine cycle Execute 1 machine cycle STAA $20 Fetch 1 machine cycle Execute 2 machine cycles

Program Flow First document what the program is going to do. Defects, undesirable behavior, BUGS

Flowcharting A means of organizing the flow of a program.

Symbols Terminator used to show start or end of program subroutine used to show a subroutine process Process used to show a process shows flowchart continues on same page input/output used to show any data input/output operations shows flowchart continues to another page direction of flow decision used to show process decisions i