How Stuff Works: Processors

Similar documents
Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

PIC Discussion. By Eng. Tamar Jomaa

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

ECE Test #1: Name

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Chapter 13. PIC Family Microcontroller

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

SOLUTIONS!! DO NOT DISTRIBUTE!!

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Assembly Language Instructions

16.317: Microprocessor-Based Systems I Spring 2012

Instuction set

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

EE 367 Introduction to Microprocessors Homework 6

Laboratory Exercise 5 - Analog to Digital Conversion

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

CONNECT TO THE PIC. A Simple Development Board

16.317: Microprocessor-Based Systems I Summer 2012

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Professor E. Ambikairajah UNSW Sydney

An Introduction to Python (TEJ3M & TEJ4M)

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

ECE 354 Introduction to Lab 2. February 23 rd, 2003

EEE111A/B Microprocessors

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Lecture (04) PIC16F84A (3)

CSC 101: Lab Manual#9 Machine Language and the CPU (largely based on the work of Prof. William Turkett) Lab due date: 5:00pm, day after lab session

PIC 16F84A programming (II)

Binary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example

Microprocessors & Assembly Language Lab 1 (Introduction to 8086 Programming)

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP

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

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

Arithmetic,logic Instruction and Programs

CSC 220: Computer Organization Unit 12 CPU programming

COMPUTER ORGANIZATION & ARCHITECTURE

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Reversing. Time to get with the program

Hardware Level Organization

GUIDE TO USE OF PIC 16F690 EEProm. The 16F690 PIC has a 256 byte EEProm (mapped to 0x x21FF).

ECE Homework #3

Principles of Compiler Design

Experiment 0: Introduction to MPLAB and QL200 development kit

Binary Outputs and Timing

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

6.096 Introduction to C++ January (IAP) 2009

COS 140: Foundations of Computer Science

4.5.1) The Label Field ) The Mnemonic Field. 4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements:

COMPILER DESIGN LECTURE NOTES

Assembly Language. Instructor: Dmitri A. Gusev. Spring Lecture 10, February 27, CSC : Introduction to Computer Science

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Physics 335 Intro to MicroControllers and the PIC Microcontroller

THE MICROPROCESSOR Von Neumann s Architecture Model

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

What is This Course About? CS 356 Unit 0. Today's Digital Environment. Why is System Knowledge Important?

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

Basic Von Neumann Designs

CHAPTER 4. PIC Microcontrollers. Assembly Language Programming. on-line FREE! Index Development systems Contact us

Discrete Logic Replacement Message Dispatch Engine

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

Information Science 1

ME 515 Mechatronics. A microprocessor

Interrupts. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Images Courtesy of Ramesh Gaonkar and Delmar Learning

ALU and Arithmetic Operations

The University of Texas at Arlington Lecture 3

Section 31. Instruction Set

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

An Introduction & Guide to JALV2

DISCONTINUED. SPI Communication with AMT bit Absolute Encoder

Practical Malware Analysis

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

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

Lesson 7 Multiple Precision Arithmetic

2/15/2008. Announcements. Programming. Instruction Execution Engines. Following Instructions. Instruction Execution Engines. Anatomy of a Computer

PIC Discussion By Eng. Tamar Jomaa

COS 140: Foundations of Computer Science

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

Beacon Keyers Using PIC s. Dave Powis, DL/G4HUP

Flow Charts and Assembler Programs

Introduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

reply db y prompt db Enter your favourite colour:, 0 colour db 80 dup(?) i db 20 k db? num dw 4000 large dd 50000

Announcements! P1 part 1 due next Tuesday P1 part 2 due next Friday

16.1. Unit 16. Computer Organization Design of a Simple Processor

Multicycle conclusion

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Transcription:

How Stuff Works: Processors Principles and Examples Joe Finney joe@comp.lancs.ac.uk

Aims Today we re going to Discuss the purpose for Assembly Language Review the common principles on which Assembly Languages are based Study a REAL assembly language Read and write simple assembly programs

Computer Processors Execute machine code instructions. Every clock tick, the next instruction is executed* Machine code is essentially a processor specific, binary representation of a simple instruction. Provide the smallest building block we use to create computer programs. All higher level languages (C, Python, Java ) are ultimately translated one way or another into machine code. Abstract Reality Java / Python / C#... Assembly Language Machine Code Assembly Language is a textual, humanly readable* programming language 1:1 mapping between an ASSEMBLY instruction and a MACHINE CODE instruction.

Why? Sometimes (but rarely) we want to write code at this very low level Programs with extremely tight timing constraints times to execute line of code are deterministic. Abstract Java / Python / C... Assembly Language Machine Code May need access to processor in a way not supported by high level languages. E.g. If you were writing a scheduler. Reality If you were stuck on an alien planet with no software. You could write the first compiler in assembler.

Principles One assembler instruction per line One assembler instruction matches one machine instruction. An assembler instruction has one operator and zero or more comma separated operands. Operators are instructions (things to do) Include instructions like ADD, SUB, GOTO, BZ Defined by the processor s capabilities. e.g. ADD R0, 1 Operands are parameters (data to work on) Use on of four addressing modes.

Addressing Modes Operands can be immediate Operand contains a literal value. Typically denoted by a # ADD R0, #1 Operands can be direct Operand contains memory address of the value Typically the default. ADD R0, 1 Operands can be indexed Operand contains memory address of the value plus and offset Typically uses a + sign ADD R0, 1+16 Operands can be indirect Operand contains the memory address of the memory address that holds the value ADD R0, [1]

Example Worlds smallest commercial 8 bit computer Size is 3mm x 2mm x 0.9 mm Cost is around 30 pence per unit (retail) Weighs considerably less than one gram Capable of one million operations /sec Highly reliable designed to benefit in situ for decades at a time (40 years data retention) Consumes less than 15uW at low speeds

PIC Assembler Syntax PIC Assembler has strict formatting [Label:] [<opcode> [<operand>][, <destination>]] Everything is TAB separated. (one or more) At most one opcode per line (instruction to execute) Depending on the opcode, may also have an operand and a destination. Operand is opcode specific, either a RAM address or literal a value. Destination (if present) is always either W or F. W = Working Register F = File (the one specified in the operand) Let s Review its Instruction set

Write a program to Add together two numbers, which are stored in memory addresses 0x40 and 0x41. The result should be stored in memory location 0x42. MOVF ADDWF MOVWF 0x40, W 0x41, W 0x42 END

Write a program to Determine if the number stored in memory location 0x40 is odd or even. Write the ASCII value for the letter E or O to memory location 0x41 to store the result. MOVLW 69 BTFSC 0x40, 0 MOVLW 79 MOVWF 0x41 END

Write a program to Perform a countdown from the value five to the value one. Write each number to memory location 0x41 in turn. MOVLW 5 MOVWF 0x40 COUNTDOWN: MOVF MOVWF DECFSZ GOTO 0x40, W 0x41 0x40, F COUNTDOWN END

References

References

References

References http://www.microchip.com/mplab/mplab-x-ide