ELN5622 Embedded Systems Class 2 Spring, 2003 Kent Orthner

Slides:



Advertisements
Similar presentations
CH10 Instruction Sets: Characteristics and Functions
Advertisements

Microprocessors.
INSTRUCTION SET ARCHITECTURES
Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
Instruction Set Architecture
Processor Function Topic 3.
Instruction Set Architecture & Design
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
By Tien Phung CS 147 Dr. Sin-Min Lee. High-level Languages Assembly Languages Machine Languages.
1 Lab Session-IV CSIT-120 Spring 2001 Lab 3 Revision and Exercises Rev: Precedence Rules Lab Exercise 4-A Machine Language Programming The “Micro” Machine.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
What is an instruction set?
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
Rabel Talpur:12BME#025.  40-pin chip  Developed by Motorola in 1975  16 address lines and 8 data lines  Used only +5V.
Assembly Language Programming for the MC68HC11. Assembly language programming  Recall the 4 design levels for software development: – Application – High.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Machine Instruction Characteristics
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Computer Systems Organization CS 1428 Foundations of Computer Science.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
CS 147 June 13, 2001 Levels of Programming Languages Svetlana Velyutina.
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
Execution of an instruction
ECE 447: Lecture 12 Logic, Arithmetic, Data Test and Control Instructions of MC68HC11.
Computer Architecture and Organization
Computer Architecture EKT 422
1 Introduction to Microcontroller Microcontroller Fundamentals & Programming.
Ch.2 Intro. To Assembly Language Programming
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
Topics covered: Instruction Set Architecture CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Ch.2 Intro. To Assembly Language Programming From Introduction to Embedded Systems: Interfacing to the Freescale 9s12 by Valvano, published by CENGAGE.
What is a program? A sequence of steps
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
Group # 3 Jorge Chavez Henry Diaz Janty Ghazi German Montenegro.
ECE 447: Lecture 11 Introduction to Programming in Assembly Language.
Instruction Sets: Characteristics and Functions  Software and Hardware interface Machine Instruction Characteristics Types of Operands Types of Operations.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Overview of Instruction Set Architectures
Addressing Modes in Microprocessors
Assembly Language Programming of 8085
ECE 3430 – Intro to Microcomputer Systems
Microprocessor T. Y. B. Sc..
Microprocessor Systems Design I
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Introduction to 8085 Instructions
Microcomputer Programming
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
CS170 Computer Organization and Architecture I
ECEG-3202 Computer Architecture and Organization
Chapter 9 Instruction Sets: Characteristics and Functions
ECEG-3202 Computer Architecture and Organization
Introduction to Microprocessor Programming
ECE511: Digital System & Microprocessor
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

ELN5622 Embedded Systems Class 2 Spring, 2003 Kent Orthner

 Course Page –  Other Resources – Resources

Programming Model & Instruction Set Architecture

 The set of instructions that the microprocessor can execute.  Defines registers that a programmer can access –Some registers in the microprocessor are not directly accessible by the programmer Instruction Set Architecture

 Fixed vs. variable Length Instructions –68HC11: INX = 0x08 LDX #$C100 = 0xce c1 00  Addressing modes –R1  R2 + #$C100 –R1  R3 + M(R3 + X)  Supported Operands –FMUL/FDIV, INC/DEC Instruction Set Characteristics

 Successful architectures have several implementations: –varying clock speeds; –different bus widths; –different cache sizes; –etc. –Ie: 8086 Architecture has not changed greatly through 8088, 80286, 80386, 80486, Pentium, etc … Multiple Implementations

 Intended to illustrate algorithms.  Simple to understand  Assignments AccA  #1234 AccB  M(#5678)  Functions Putchar (char) Newchar  getchar () Pseudo-code

 Loops While () … Endwhile Repeat … Until () Pseudo-code  Conditionals If () then … Elsif () then … Endif

 Describes the microprocessor registers that are accessible by the programmer –Includes information about the register width and the type of data element it may contain –Indicate how the instructions access and manipulate the registers  Some registers are not visible (IR). Programmer’s Model

 Local memory bits inside the processor.  Instructions use the registers to accomplish tasks.  Some are general purpose –R0 through R7  Some are function specific. –Program Counter –Stack Pointer –Condition Code Registers

Motorola 68HC11 Programmers Model

 Accumulator: –8-bit:A, B(ACCA, ACCB) –16-bit:D(ACCD) –Two 8-bit accumulator registers. Each may be a source or destination operand for 8-bit instructions. –Some instructions use D as a single 16-bit accumulator, with A as the most significant Byte. –Examples: ACCA  #$64 ACCB  ACCB + M($0074) ACCD  ACCD + (M:M+1)

Motorola 68HC11 Programmers Model  Index Registers: –X, Y(IX, IY) –Two 16-bit registers X & Y used primarily for indexed addressing. –Examples: IX  #$0064 ACCD  M(IX+64):M(IX+65)

Motorola 68HC11 Programmers Model  Stack Pointer: –SP –16-bit registers pointing to the next available memory location for a push operation. –Automatically decremented during a push operation, incremented during a pull operation. –Must be initialized before use.

Motorola 68HC11 Programmers Model  Program Counter: –PC –16-bit register pointing to the beginning fot he next instruction to be executed. –Automatically incremented after each instruction. –Programmer has no control over, other than branch & jump instructions.

Motorola 68HC11 Programmers Model  Condition Code Register: –CCR –4-bit register whose bits are set or reset during arithmetic or other operations. –Used for branch operations. –Bits include: C: Carry V: Two’s complements overflow Z : Zero N : Negative I : Interrupt Mask H : Half-carry X : External Interrupt Mask S : Stop Disable

Motorola 68HC11 Programmers Model  Condition Code Register Example ACCA  $#F0 ACCA  ACCA + #$F C  1 Z  0 N  1 V  0

 Immediate Addressing ACCA  #$64  Direct / Extended Addressing –Direct: Addr <= 0xFF –Extended: Addr >= 0x0100 ADDA  M($0064) (Direct) ADDA  M($1234) (Extended) Addressing Modes

 Indexed Addressing ACCA  M(IX + 64)  Inherent Addressing ADDA  ACCA + ACCB  Relative Addressing PC  (PC – 15) Addressing Modes

Motorola 68HC11 Instruction Types  Load & Store Instructions –8-bit Load/Store –16-bit Load/Store –Stack Push/Pull  Transfer Register Instructions  Decrement & Increment Instructions

Motorola 68HC11 Instruction Types  Clear & Set Instructions –CLRA, CLRB, BCLR, BSET  Shift & Rotate Instructions –Logical Shift –Arithmetic Shift –Rotate

Motorola 68HC11 Instruction Types  Arithmetic Instructions –Add & Subtract –Decimal Instructions (BCD) –Negating Instructions –Multiplications –Fractional Number Arithmetic –Division

Motorola 68HC11 Instruction Types  Logic Instructions –ANDA, ANDB, EORA, ORAA, COM  Data Test Instructions –BITA, BITB, CBA, CMPA, TST, TSTA  Conditional Branch Instructions –Signed & Unsigned Conditional Branches –BMI, BPL, BVS, GLT, BGT, BEQ, BNE  Unconditional Jump & Branch Instructions –JMP, JSR, BSR, RTS BRA, BRN

Motorola 68HC11 Instruction Types  Condition Code Register Instructions –CLC, SEC, CLV, CEV, TAP, TPA  Interrupt Instructions –CLI, SEI, RTI, SWI, WAI  Miscellaneous Instructions –NOP, STOP, TEST

Assembly Language Overview

 Machine Language  Assembly Language  Compiled Languages –C, C++, Pascal,  Interpreted Languages –Perl, TCL, UNIX shells  Higher level Languages –SQL, Etc Language Spectrum

 The lowest level of programming languages  Binary encodings of the machine’s instructions  Specific to the microprocessors  Programmers do not write machine language programs (anymore)  Machine language (or machine code) is automatically generated from the assembly or compilation processes Machine Language

X  #$1234(Immediate) LDX#$1234 ce X  $1234(Direct) LDX$1234 fe Machine Language: Example

 One-to-one with Machine Language instructions (more or less)  More legible  Basic features: –One instruction per line. –Labels provide names for addresses (usually in first column). –Instructions often start in later columns. –Columns run to end of line. Assembly Language

 Assembly languages are unique to each microprocessor.  They are categorized at a much lower level than the High-Level Languages (HLLs)  May not be executed on other computer systems with different microprocessors (unless the microprocessors are designed to be compatible) Assembly Language

 Intel 8085, 8086, 80286,…80486  Intel Pentium  Motorola 6800, 6805, and 6809  Motorola 68000, &  Motorola PowerPC  SUN Sparc processor Assembly Language Examples

 When a programmer writes a program in assembly language, a specific assembler must be used to create the object code for that specific microprocessor  The final executable file produced from this process can only be executed on a computer containing that specific type of microprocessor Assembling Process

 Major tasks: –generate binary for assembly instructions –translate labels into addresses –handle assembler directives  Generally one-to-one translation.  We are using a cross assembler: –Runs on a PC, but assembles for a 68HC11  The assembler we’re using is an absolute assembler: –All source code must be in one file or group of files assembled together. Assembling Process

 Converts from a high level language to machine-executable machine language.  Output format is called “object code”. –Still needs to be linked before it can really be machine code.  Some compilers provide a post-compilation assembly file or list file for debugging. Compilation Process

 Numeric Data –Integers –Fixed Point –Floating Point  Boolean Data –TRUE = 0  Character Data –American Standard Code for Information Interchange (ASCII) –Extended Binary Coded Decimal Interchange Code (EBCDIC) –UNICODE (Used extensively by Java) Data Types

Programming in Assembly Language

Assembly Fields * * This is a Comment! * Label:OPCODE OP1,OP2Comment OPCODE OP1 OPCODEAnother Comment

Labels  A-Z a-z 0-9. $ _  Up to 15 characters  1 st character can not be ‘0-9’ or ‘$’  Case sensitive  May end with “:”  May be on a line by itself.  Examples: Test _Test JumpToHere:LDX#$1234 Label1

Op-Codes  Processor Instruction or  Assembler Directive (pseudo-op)  Must be preceded by at least one whitespace. JumpToHere:LDX#$1234 JMPJumpToHere

Operand Field  Defines the operand for the instruction or directive.  Depends on the instructions.  Determines the addressing mode  Can be expressions to be evaluated by the assembler. JumpToHere:LDX#$ JMPJumpToHere

Operand Field: Addressing Modes  Inherent INX  Direct, Extended, Relative LDX $1234  Immediate LDX #$1234  Indexed CLR $1234,X

Comments  Complete Line Comments: First chararcter is an asterisk. * * This is a Comment * Kent Orthner, May 22, 2003 *  After the Operand JumpHere:LDX #$ JMP JumpHere Also a Comment

Hello World Example * Hello World * Kent Orthner, May 22, 2003 * Definitions OUTSTR: EQU $FFCA Define ‘OUTSTR’ Function EOT: EQU 04 Define ‘EndOfText’ Char PROG: EQU $C000 Define Program Location STACK: EQU $DFFF Define Stack Location

Hello World Example * Program ORG PROG Locate program in mem lds #STACK Init stack pointer ldx #HELLO Point to start of message jsr OUTSTR Jump to print subroutine swi Returns to the debugger * String Definition HELLO: FCC /Hello World!/ FCB EOT

Assembler Output: Machine Language Addr Value c000 8e df ff ce c004 c0 0a bd ff c008 ca 3f c00c 6c 6c 6f 20 c f 72 6c c

Assembler Output: List Files Line Addr Code Label Opcode 0001 * Hello World 0002 * Kent Orthner, May 22, * Definitions 0005 ffca OUTSTR: EQU $FFCA Define ‘OUTSTR’ EOT: EQU 04 Define ‘EndOfTex 0007 c000 PROG:EQU $C000 Define Program L 0008 dfff STACK: EQU $DFFF Define Stack Lo

Assembler Output: List Files Line Addr Code Label Opcode 0009 * Program 0010 c000 ORG PROG Locate program 0011 c000 8e df ff lds #STACK Init stack po 0012 c003 ce c0 0a ldx #HELLO Point to start 0013 c006 bd ff ca jsr OUTSTR Jump to print 0014 c009 3f swi Returns to the * String Definition 0017 c00a c HELLO: FCC /Hello World!/ 6c 6f f 72 6c c FCB EOT

Instructions

Assembler Directives

 ORG: Set the Program Counter ORG $E000  EQU: Define Constants RAM:EQU $E000  RMB: Reserve Memory Bytes TABLE:RMB 100

Assembler Directives  BSZ/ZMB: Block Storage Zeroes ZeroSpace:BSZ 100  FCB: Form Constant Byte CountSpace:FCB 1,2,3,4,5,6  FCC: Form Constant Character String StringSpace:FCC ’Hello World!’

Assembler Directives  FDB: Form Double Byte FDB $1234  FILL: Fill Memory AASpace:$aa,100  OPT: Assembler Output Options OPT c,l,cre

Assembler Exercise

Lab 1: Simple Menu

 Purpose: –Program assembly & execution. –Serial Input and Output. –Polling-based timing. –Parallel I/O  Assignment –Menu-based system. –Control something with the Parallel I/O block.

 Criteria –Serial output to display menu. –Key entry causes menu change. –2-Level menu –Pressing a key at the second level menu causes an external effect. –Idiot-proof (Doesn’t do anything when a wrong key is pressed.) Lab 1: Simple Menu

 Criteria –Serial output to display menu. –Key entry causes menu change. –2-Level menu –Pressing a key at the second level menu causes an external effect. –Idiot-proof (Doesn’t do anything when a wrong key is pressed.) Lab 1: Simple Menu

 Use Putchar(), Putstr(), getchar() –We’ll cover how to create them next week.  Suggested program flow: Top:Print Menu Wait for input Go to SubMenu1, submenu2, or top. Submenu1:Print submenu1 wait for input Dosomething1, submenu1, or top. Dosomething1:Do the action. Go to Submenu1 Submenu2:… Lab 1: Simple Menu Implementation Hints