EE 308: Microcontrollers

Size: px
Start display at page:

Download "EE 308: Microcontrollers"

Transcription

1 EE 308: Microcontrollers Introduction to the Assmbly Language Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 25, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

2 Introduction to Assembly This lecture will introduce you to the assembly language, the compilation and downloading process. Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

3 Fields of an assembly language instruction [label:] mnemonic [operands] [;comment] label... marks lines that can be referred to by the program mnemonic... instruction and results in an opcode operands... could be registers, address to a desired memory, or constant depending on the instruction comments... comments start with a semicolon Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

4 LDI instruction LDI Rd, K ;load Rd with immediate value k K is an 8-bit value Rd can only be R16 to R31 Hex values for K can be represented using 0 Machine code for LDI 1110 kkkk dddd kkkk Examples: LDI R20,0 x3f ;load R20 with immediate hex value 0x3F E 3 4 F Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

5 ADD instruction ADD Rd, Rr ;Add Rr to Rd and store result to Rd Uses the ALU Result affects the status register Examples: ADD R16, R17 ;Add R17 to R16 and store in R16 Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

6 LDS instruction LDS Rd, K ;load Rd with the content of memory location K Loads the register directly from data space (one byte value) Examples: LDS R5,0 x400 ;load R5 with content of memory location 0x400 LDS R6,0 x1 ;load R6 with content of memory location 0x1 What is in memory locate 0x1? Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

7 STS instruction STS K, Rr ;store register into location K Store direct to data space Location could be any value in the data space Examples: STS 0 x400, R25 ;store R25 to data space location 0x230 STS 0 x27, R16 ;store R16 to memory locate 0x27 What is in memory locate 0x27? Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

8 IN instruction IN Rd, A ;load an I/O location Rd A is an I/O location 0 to 0x3F I/O locations are offset from memory addresses by 0x20 therefore they start at 0x00 Examples: IN R19,0 x10 ;load R19 with data from location 0x10 What is in memory locate 0x10? Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

9 Difference between IN and LDS IN is faster IN is a 2-byte instruction vs the 4-byte instruction LDS Can use I/O register names with IN IN as opposed to LDS it is available in all AVRs Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

10 OUT instruction OUT A, Rr ;store register Rr to I/O location A Cannot copy and immediate value to an I/O register nor to an SRAM location Examples: OUT PORTA, R0 ;load R19 with data from location 0x10 What is PORTA? Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

11 Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. INCLUDE " M1284DEF. INC " LDI R16, hi8 ( RAMEND ) OUT SPH, R16 LDI R16, lo8 ( RAMEND ) 5 OUT SPL, R16 ;initialize stack pointer SBI DDRC, 0 ;set bit 0 of DDRC HERE : SBI PORTC, 0 10 CALL DELAY ;call DELAY subroutine CBI PORTC, 0 CALL DELAY RJMP HERE 15 DELAY : LDI R20, 255 DL1 : DEC R20 BRNE DL1 RET Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

12 Assembly language Assembly language consists of, instructions referred to as mnemonics, directives and labels.. INCLUDE " M1284DEF. INC " LDI R16, hi8 ( RAMEND ) OUT SPH, R16 LDI R16, lo8 ( RAMEND ) 5 OUT SPL, R16 ;initialize stack pointer SBI DDRC, 0 ;set bit 0 of DDRC HERE : SBI PORTC, 0 10 CALL DELAY ;call DELAY subroutine CBI PORTC, 0 CALL DELAY RJMP HERE 15 DELAY : LDI R20, 255 DL1 : DEC R20 BRNE DL1 RET Directive Label Comment Instruction Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

13 Intel Hex Intel Hex : E40EBF0FEF0DBF389A409A0E940C001B : E940C00F9CF4FEF4A95F1F70895F0 : FF Start code (:) Byte count data only (2 characters) Address (4 characters) Record type (2 characters) 00 data record 01 end of file Data (2k characters) Checksum (2 characters) Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

14 Intel Hex Intel Hex : E40EBF0FEF0DBF389A409A0E940C001B : E940C00F9CF4FEF4A95F1F70895F0 : FF Start code (:) Byte count data only (2 characters) Address (4 characters) Record type (2 characters) 00 data record 01 end of file Data (2k characters) Checksum (2 characters) What is this code represent? Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

15 What to download on the microcontroller Assembler replaces mnemonics by their opcodes, resolves include directives, translates register names to addresses, removes comments, etc. avr-as -mmcu=atmega1284 -o ex.o ex.s Linker links multiple files avr-ld -mavr51 -o ex.elf ex.o Translate object files avr-objcopy -j.text -j.data -O ihex -o ex.hex ex.elf Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

16 Downloading the hex file avrdude -v -c dragon_jtag -p m1284 -Pusb -U flash:w:ex.hex Aly El-Osery (NMT) EE 308: Microcontrollers January 25, / 14

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Introduction Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 6, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Review Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA February 15, 2018 Aly El-Osery (NMT) EE 308:

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Assmbly Language Part I Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 30, 2018 Aly El-Osery (NMT)

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Timers Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA April 2, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers AVR Architecture Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA January 23, 2018 Aly El-Osery (NMT) EE 308:

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Interrupts Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA March 1, 2018 Aly El-Osery (NMT) EE 308: Microcontrollers

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation 2 Atmel AVR 8-bit RISC architecture

More information

AVR ISA & AVR Programming (I)

AVR ISA & AVR Programming (I) AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo Week 1 1 Lecture Overview AVR ISA AVR Instructions & Programming (I) Basic construct implementation Week 1 2 1 Atmel AVR 8-bit

More information

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function Module 8: Atmega32 Stack & Subroutine Stack Pointer Subroutine Call function Stack Stack o Stack is a section of RAM used by the CPU to store information temporarily (i.e. data or address). o The CPU needs

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing Interfacing Lecture 9: Program Control Instructions http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 1, 2006 Program control instructions in AVR Stacks Overview Sample AVR assembly programs

More information

Microcontroller VU

Microcontroller VU 182.694 Microcontroller VU Martin Perner SS 2017 Featuring Today: A Deep Look into the Processor Core Getting Code onto the Microcontroller Chip Weekly Training Objective This week 1.2 Board test 2.1.1

More information

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming

Review on Lecture-1. ICT 6641: Advanced Embedded System. Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming ICT 6641: Advanced Embedded System Lecture 2 Branch, Call and Delay Loops, AVR I/O port programming Prof. S. M. Lutful Kabir Session: April, 2011 Review on Lecture-1 Three parts of a computer : CPU, Memory

More information

CN310 Microprocessor Systems Design

CN310 Microprocessor Systems Design CN310 Microprocessor Systems Design Instruction Set (AVR) Nawin Somyat Department of Electrical and Computer Engineering Thammasat University Outline Course Contents 1 Introduction 2 Simple Computer 3

More information

EE 308: Microcontrollers

EE 308: Microcontrollers EE 308: Microcontrollers Serial Perpherial Interface (SPI) Aly El-Osery Electrical Engineering Department New Mexico Institute of Mining and Technology Socorro, New Mexico, USA April 9, 2018 Aly El-Osery

More information

AVR Subroutine Basics

AVR Subroutine Basics 1 P a g e AVR Subroutine Basics READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 3: Branch, Call, and Time Delay

More information

By: Dr. Hamed Saghaei

By: Dr. Hamed Saghaei By: Dr. Hamed Saghaei The AVR RISC Microcontroller supports powerful and efficient addressing modes for access to the program memory (Flash) and data memory (SRAM). This section describes the different

More information

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming Prof. Ben Lee Oregon State University School of Electrical Engineering and Computer Science Chapter Goals Understand how to program

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (II)

COMP2121: Microprocessors and Interfacing. I/O Devices (II) COMP2121: Microprocessors and Interfacing I/O Devices (II) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview Keyboard LCD (Liquid Crystal Display) 2 2 Input Switches (1/2)

More information

Addressing Modes Part II AVR Addressing Indirect READING

Addressing Modes Part II AVR Addressing Indirect READING 1 P a g e Addressing Modes Part II AVR Addressing Indirect READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 6: AVR

More information

Programming Microcontroller Assembly and C

Programming Microcontroller Assembly and C Programming Microcontroller Assembly and C Course Number CLO : 2 Week : 5-7 : TTH2D3 CLO#2 Student have the knowledge to create basic programming for microcontroller [C3] Understand how to program in Assembly

More information

COMP2121: Microprocessors and Interfacing. Instruction Formats and Addressing Modes

COMP2121: Microprocessors and Interfacing. Instruction Formats and Addressing Modes COMP2121: Microprocessors and Interfacing Instruction Formats and Addressing Modes http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Instruction format AVR instruction format

More information

APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW

APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW This appendix provides an introduction to writing flowcharts and pseudocode. 689 Flowcharts If you have taken any previous programming courses, you are probably

More information

Module 2: Introduction to AVR ATmega 32 Architecture

Module 2: Introduction to AVR ATmega 32 Architecture Module 2: Introduction to AVR ATmega 32 Architecture Definition of computer architecture processor operation CISC vs RISC von Neumann vs Harvard architecture AVR introduction AVR architecture Architecture

More information

Using SRAM in AVR assembler language

Using SRAM in AVR assembler language Using SRAM in AVR assembler language All AVR-type MCUs have static RAM (SRAM) on board. Only very simple assembler programs can avoid using this memory space by putting all info into registers. If you

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Interrupts (II) Interrupts in AVR External interrupts Internal interrupts Timers/Counters Lecturer : Dr. Annie Guo S2, 2008 COMP9032 Week7 1 S2, 2008 COMP9032

More information

Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo

Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo Interrupts (II) Lecturer: Sri Parameswaran Notes by: Annie Guo 1 External Interrupts The external interrupts are triggered by the INT7:0 pins. If enabled, the interrupts will trigger even if the INT7:0

More information

Data Transfer Instructions

Data Transfer Instructions Data Transfer Instructions (Credit: Hui Wu/COMP2121 Lecture Notes) Load Direct (ld): ld Rd, v Rd {r0, r1,..., r31} and v {x, x+, -x, y, y+, -y, z, z+, -z} (remember the X, Y, Z pointers) Load Program Memory

More information

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now)

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now) 18 100 Lecture 20: AVR Programming, Continued S 15 L20 1 James C. Hoe Dept of ECE, CMU April 2, 2015 Today s Goal: You will all be ace AVR hackers! Announcements: Midterm 2 can be picked up in lab and

More information

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017

Objectives. I/O Ports in AVR. Topics. ATmega16/mega32 pinout. AVR pin out The structure of I/O pins I/O programming Bit manipulating 22/09/2017 Objectives The AVR microcontroller and embedded systems using assembly and c I/O Ports in AVR List all the ports of the AVR microcontroller Describe the dual role of the AVR pins Code assembly language

More information

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET Other documents that are referred within this document are located at the link https://www.dropbox.com/sh/s16jri4eol3agl5/aaazn_w3p7fodjs-wi-xcenqa?dl=0 The ATmega32/ATmega2A

More information

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD A. Assembly Language Programming Programming of a computer system: Machine code direct execution Assembly language tool: assembler High level programming language tool: interpreter tool: compiler Programming

More information

AVR Assembler Examples

AVR Assembler Examples AVR Assembler Examples AVR specific examples Credit to Dr. Robucci for slide information SBR Set bits in reg Equivalent to an ORI REQUIRES MASKS, not bit number m169pdef.inc Include file detailing register

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2 ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Set #2 1- Consider the internal structure of the pseudo-cpu discussed in class augmented with a single-port register file (i.e.,

More information

Assembly Programming (III)

Assembly Programming (III) Assembly Programming (III) Lecturer: Annie Guo S2, 2006 COMP9032 Week6 1 Lecture Overview Stack and stack operations Functions and function calls Calling conventions S2, 2006 COMP9032 Week6 2 What is stack?

More information

Assembly Programming (III) Lecturer: Sri Parameswaran Notes by: Annie Guo Dr. Hui Wu

Assembly Programming (III) Lecturer: Sri Parameswaran Notes by: Annie Guo Dr. Hui Wu Assembly Programming (III) Lecturer: Sri Parameswaran Notes by: Annie Guo Dr. Hui Wu 1 Lecture overview Stack and stack operations Functions and function calls Calling conventions 2 Stack What is stack?

More information

8-bit Instruction Set

8-bit Instruction Set Instruction Set Nomenclature Status Register (SREG) SREG: Status Register C: Carry Flag Z: Zero Flag N: Negative Flag V: Two s complement overflow indicator S: N V, For signed tests H: Half Carry Flag

More information

Logic Instructions and Programs READING

Logic Instructions and Programs READING 1 P a g e Logic Instructions and Programs READING The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 5: Arithmetic, Logic

More information

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

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1 Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University What is Assembly Language? Assembly language is a programming language

More information

Digital Systems - Mini AVR 3

Digital Systems - Mini AVR 3 Digital Systems - Mini AVR 3 Pere Palà - Alexis López itic http://itic.cat April 2016 Enhancing the processor Up to now, we have a linear program flow Suitable for a pre-planned task Unable to react to

More information

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Today s Menu Methods >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory Look into my See examples on web-site: ParamPassing*asm and see Methods in Software and

More information

IAS0430 MICROPROCESSOR SYSTEMS

IAS0430 MICROPROCESSOR SYSTEMS IAS0430 MICROPROCESSOR SYSTEMS Fall 2018 Arduino and assembly language Martin Jaanus U02-308 martin.jaanus@ttu.ee 620 2110, 56 91 31 93 Learning environment : http://isc.ttu.ee Materials : http://isc.ttu.ee/martin

More information

CHAPTER 2: AVR ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING

CHAPTER 2: AVR ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING CHAPTER 2: AVR ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING SECTION 2.1: THE GENERAL PURPOSE REGISTERS IN THE AVR 1. 8 2. 8 3. 8 4. 0xFF 5. $28 in R20 6. (a), (c), (d), (e), (g) 7. (c) 8. This is an illegal

More information

AVR. (AVR Assembly Language) Assembler . ก ก

AVR. (AVR Assembly Language) Assembler . ก ก AVR (AVR Assembly Language). ก ก Assembler 2 1 ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load

More information

AVR Instruction Set Encoding

AVR Instruction Set Encoding 1 P age AVR Instruction Set Encoding READING 1. "AVR Instruction Set" document doc856 "The Program and Data Addressing Modes." 2. In this lecture I will teach you how to translate your assembly code into

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing Interfacing Lecture 6: Instruction Format http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 1, 2006 Overview Instruction format AVR instruction format examples PowerPC instruction format examples

More information

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language)

AVR. 2. (Assembler directives ) 3. ( Instruction field) 5. (Comment field) 1. (Label field) Assembler. 4. ก (Operands field) (AVR Assembly Language) 3 AVR (AVR Assembly Language). ก ก ก /* * AVRAssembler1.asm * * Created: 9/7/2554 9:40:18 * Author: xp */.org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET RESET: ldi r16, 0b11111111 ;load register

More information

Microprocessors & Interfacing

Microprocessors & Interfacing Lecture Overview Microprocessors & Interfacing Input/Output Devices Input devices Input switches Basics of switches Keypads Output devices LCD Lecturer : Dr. Annie Guo S2, 2008 COMP9032 Week8 1 S2, 2008

More information

COMP3221: Microprocessors and Embedded Systems

COMP3221: Microprocessors and Embedded Systems Embedded Systems Lecture 6: Addressing Modes http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2005 Addressing Modes Overview Instruction Examples 1 2 Operands Immediate Addressing Instructions

More information

Mark II Aiken Relay Calculator

Mark II Aiken Relay Calculator Introduction to Embedded Microcomputer Systems Lecture 6.1 Mark II Aiken Relay Calculator 2.12. Tutorial 2. Arithmetic and logical operations format descriptions examples h 8-bit unsigned hexadecimal $00

More information

COMP2121: Microprocessors and Interfacing

COMP2121: Microprocessors and Interfacing nterfacing Overview Arithmetic and Logic nstructions in AR ample AR Assembly Programs Using AL instructions Lecture 8: Arithmetic and logic nstructions http://www.cse.unsw.edu.au/~cs2121 Lecturer: ui Wu

More information

COMP3221: Microprocessors and Embedded Systems

COMP3221: Microprocessors and Embedded Systems Embedded ystems Overview Arithmetic and Logic nstructions in AR ample AR Assembly Programs Using AL instructions Lecture 7: Arithmetic and logic nstructions http://www.cse.unsw.edu.au/~cs3221 Lecturer:

More information

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo

Input/Output Devices. Lecturer: Sri Parameswaran Notes by: Annie Guo Input/Output Devices Lecturer: Sri Parameswaran Notes by: Annie Guo 1 Lecture Overview Input devices Input switches Basics of switches Keypads Output devices LCD 2 Input Switches Most basic binary input

More information

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration

AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration Features Utilizes the AVR Enhanced RISC Architecture 89 Powerful Instructions - Most Single Clock Cycle Execution 1K bytes of In-System Reprogrammable Downloadable Flash - SPI Serial Interface for Program

More information

Register-Level Programming

Register-Level Programming Introduction Register-Level Programming Programming can be considered a set a instructions that are executed in a precise order. A programming simulator can evaluate how instructions store, move and calculate

More information

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA) COMP2121: Microprocessors and Interfacing Instruction Set Architecture (ISA) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Contents Memory models Registers Data types Instructions

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Potpourri & Notes on Lab 2 Artist's concept of Mars Exploration Rover. Courtesy NASA Lab 2 Notes Slide 1 The AVR Assembler We use the AVRASM2 assembler that comes with AVR

More information

AVR Control Transfer -AVR Branching

AVR Control Transfer -AVR Branching 1 P a g e AVR Control Transfer -AVR Branching Reading The AVR Microcontroller and Embedded Systems using Assembly and C) by Muhammad Ali Mazidi, Sarmad Naimi, and Sepehr Naimi Chapter 3: Branch, Call,

More information

Introduction to Assembly language

Introduction to Assembly language Introduction to Assembly language 1 USING THE AVR MICROPROCESSOR Outline Introduction to Assembly Code The AVR Microprocessor Binary/Hex Numbers Breaking down an example microprocessor program AVR instructions

More information

ET-BASE AVR ATmega64/128

ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 ET-BASE AVR ATmega64/128 which is a Board Microcontroller AVR family from ATMEL uses MCU No.ATmega64 and ATmega128 64PIN. Board ET-BASE AVR ATmega64/128 uses MCU s resources on

More information

Embedded Systems and Software. LCD Displays

Embedded Systems and Software. LCD Displays Embedded Systems and Software LCD Displays Slide 1 Some Hardware Considerations Assume we want to drive an LED from a port. The AVRs can either source or sink current. Below is a configuration for sourcing.

More information

Building A RISC Microcontroller in an FPGA. Yap Zi He

Building A RISC Microcontroller in an FPGA. Yap Zi He Building A RISC Microcontroller in an FPGA Yap Zi He yapzihe@hotmail.com http://www.opencores.org/projects/riscmcu/ Supervisor : Muhammad Mun im Ahmad Zabidi (Assoc Prof) raden@utm.my Faculty of Electrical

More information

CHW 469 : Embedded Systems

CHW 469 : Embedded Systems CHW 469 : Embedded Systems Instructor: Dr. Ahmed Shalaby http://bu.edu.eg/staff/ahmedshalaby4# I/O Ports in AVR The AVR microcontroller and embedded systems using assembly and c Topics AVR pin out The

More information

COMP3221: Microprocessors and. and Embedded Systems. Overview. Variable Types and Memory Sections. Types of Variables in C

COMP3221: Microprocessors and. and Embedded Systems. Overview. Variable Types and Memory Sections. Types of Variables in C COMP3221: Microprocessors and Embedded Systems Lecture 12: Functions I http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2005 Overview Variable types Memory sections in C Parameter passing

More information

AVR and MeggyJr Simple

AVR and MeggyJr Simple AVR and MeggyJr Simple Today Finish AVR assembly especially for PA3ifdots.java Meggy Jr Simple run-time library CS453 Lecture AVR Assembly and Meggy Jr Simple 1 AVR Instruction Set Architecture, or Assembly

More information

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW In this appendix, we describe each intruction of the ATmega328. In many cases, a simple code example is given to clarify the instruction. Instructions are

More information

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.

More information

University of Florida EEL 4744 Dr. Eric M. Schwartz. Page 1/11 Revision 0 20-Feb-14 Mixed C and Assembly (for Atmel XMEGA)

University of Florida EEL 4744 Dr. Eric M. Schwartz. Page 1/11 Revision 0 20-Feb-14 Mixed C and Assembly (for Atmel XMEGA) Page 1/11 Revision 0 20-Feb-14 KEY WORDS Compiler, Inline Assembly, GNU Assembler, GCC, AVR-GCC RESOURCES GNU Assembler Resource - http://sourceware.org/binutils/docs-2.23.1/as/index.html AVR-LibC Inline

More information

PIC Discussion. By Eng. Tamar Jomaa

PIC Discussion. By Eng. Tamar Jomaa PIC Discussion By Eng. Tamar Jomaa Chapter#2 Programming Microcontroller Using Assembly Language Quiz#1 : Time: 10 minutes Marks: 10 Fill in spaces: 1) PIC is abbreviation for 2) Microcontroller with..architecture

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261/V ATtiny461/V ATtiny861/V. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04 AN703 Micro64/128 Accessing the 36k of SRAM 12/3/04 Introduction: Micro64/128 has a total of 36k of SRAM. 4 k of SRAM is built into the processor an additional 32k of SRAM is available inside the Micro64/128

More information

Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

More information

CPU. Objectives. Introduction to Assembly Chapter 2. Topics. AVR s CPU 12/09/2017

CPU. Objectives. Introduction to Assembly Chapter 2. Topics. AVR s CPU 12/09/2017 Students should be able to: Objectives ntroduction to Assembly Chapter 2 he AVR microcontroller and embedded systems using assembly and c List the registers of the AVR microcontroller Draw and label a

More information

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

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff CodeWarrior 1 Assembler An assembler is a program that translates assembly language into machine code. Machine code are the numbers that the CPU recognizes as instructions. $B6 $10 $00 Assembly language

More information

8-bit Microcontroller with 4K Bytes In-System Programmable Flash. ATtiny40. Preliminary

8-bit Microcontroller with 4K Bytes In-System Programmable Flash. ATtiny40. Preliminary Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 54 Powerful Instructions Most Single Clock Cycle Execution 16 x 8 General Purpose Working Registers Fully Static

More information

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

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming Laboratory: Introduction to Mechatronics Instructor TA: Edgar Martinez Soberanes (eem370@mail.usask.ca) 2015-01-12 Lab 2. PIC and Programming Lab Sessions Lab 1. Introduction Read manual and become familiar

More information

COMP2121 Experiment 4

COMP2121 Experiment 4 COMP2121 Experiment 4 1. Objectives In this lab, you will learn AVR programming on Parallel input/output; Some typical input/output devices; and Interrupts 2. Preparation Before coming to the laboratory,

More information

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary Features Utilizes the AVR RISC Architecture AVR High-performance and Low-power RISC Architecture 118 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General-purpose Working Registers Up

More information

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss Grundlagen Microcontroller Processor Core Günther Gridling Bettina Weiss 1 Processor Core Architecture Instruction Set Lecture Overview 2 Processor Core Architecture Computes things > ALU (Arithmetic Logic

More information

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER OBJECT: EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER To understand the structure and operating instruction of the microprocessor trainer. INTRODUCTION: The MKT 8085 is a single-board microcomputer,

More information

Embedded Systems and Software

Embedded Systems and Software Embedded Systems and Software Timers and Counters F-35 Lightning II Electro-optical Targeting System (EOTS Lecture 1, Slide-1 Timers and Counters Very important peripherals on microcontrollers ATtiny45

More information

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1

More information

Mitsubishi M16C Instruction Set Architecture

Mitsubishi M16C Instruction Set Architecture Mitsubishi M16C Instruction Set Architecture Lecture 2 Embedded Systems 2-1 Today Learn about Mitsubishi (Renesas) processor Lecture covers ISA, derived from Assembler Language Programming Manual (M16C_Assembler.pdf

More information

ECED 3204 Microprocessor Midterm Reference Solution

ECED 3204 Microprocessor Midterm Reference Solution ECED 3204 Microprocessor Midterm Reference Solution Date: October 26 2017 Time: 7:00pm-9:00pm Room: B225, B227, B229 Student name ID 1) Problem one has following two sub problems: a. Write an instruction

More information

Menu. The Cost of Debugging

Menu. The Cost of Debugging 12-Sep-18 330 PM ging >Why do we need to debug? >When do we need to debug? >How do we debug? Before/as we code After we code >Common bugs Menu Look into my... 1 The Cost of ging Increases exponentially

More information

Lecture 04: Machine Instructions

Lecture 04: Machine Instructions CSCI2510 Computer Organization Lecture 04: Machine Instructions Ming-Chang YANG mcyang@cse.cuhk.edu.hk Reading: Chap. 2.3~2.4, 2.10~2.11 Recall: Instructions & Program A computer is governed by instructions.

More information

COMP2121: Microprocessors and Interfacing. I/O Devices (I)

COMP2121: Microprocessors and Interfacing. I/O Devices (I) COMP2121: Microprocessors and Interfacing I/O Devices (I) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Overview I/O Ports AVR Ports 2 2 What is I/O? I/O is Input or Output (Input/Output).

More information

Computer Organization MIPS ISA

Computer Organization MIPS ISA CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization

More information

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Review Topics

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Review Topics Second Midterm Review Slides Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Review Topics LC-3 Programming /Stack Execution

More information

2.1. Basic Assembler Functions:

2.1. Basic Assembler Functions: 2.1. Basic Assembler Functions: The basic assembler functions are: Translating mnemonic language code to its equivalent object code. Assigning machine addresses to symbolic labels. SOURCE PROGRAM ASSEMBLER

More information

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive

8-bit Microcontroller with 2/4/8K Bytes In-System Programmable Flash. ATtiny261 ATtiny461 ATtiny861. Automotive Features High Performance, Low Power AVR 8-Bit Microcontroller Advanced RISC Architecture 123 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static

More information

Buses and Parallel Input/Output

Buses and Parallel Input/Output Buses and Parallel Input/Output Lecturer: Sri Parameswaran Notes by: Annie Guo Week7 1 Lecture Overview Buses Computer buses I/O Addressing Memory mapped I/O Separate I/O Parallel input/output AVR examples

More information

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. ATmega8515 ATmega8515L. Features Features High-performance, Low-power AVR 8-bit Microcontroller RISC Architecture 130 Powerful Instructions Most Single Clock Cycle Execution 32 x 8 General Purpose Working Registers Fully Static Operation

More information

8051 Microcontroller Assembly Programming

8051 Microcontroller Assembly Programming 8051 Microcontroller Assembly Programming EE4380 Fall 2002 Class 3 Pari vallal Kannan Center for Integrated Circuits and Systems University of Texas at Dallas Topics Machine code 8051 Addressing Modes

More information

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices Kostas Papagiannopoulos Aram Verstegen July 11, 2013 Papagiannopoulos and Verstegen July 11, 2013 Speed and Size-Optimized

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1 CSIS1120A 10. Instruction Set & Addressing Mode CSIS1120A 10. Instruction Set & Addressing Mode 1 Elements of a Machine Instruction Operation Code specifies the operation to be performed, e.g. ADD, SUB

More information

EE 3170 Microcontroller Applications

EE 3170 Microcontroller Applications EE 317 Microcontroller Applications Lecture 5 : Instruction Subset & Machine Language: Introduction to the Motorola 68HC11 - Miller 2.1 & 2.2 Based on slides for ECE317 by Profs. Davis, Kieckhafer, Tan,

More information

;Compiler Options.NOLIST.INCLUDE "C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc"

;Compiler Options.NOLIST.INCLUDE C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc ;* CharTest.asm ;* ;* Created: 28/06/2017 9:37 p.m. ;* Author: ob1 ;ST7820 128 x 64 graphics mode character display 8 lines x 21 characters ;Modification and redistribution under provisions of GNU general

More information