starting to program an introduction to assembler n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Starting to Program – An Introduction to Assembler PowerPoint Presentation
Download Presentation
Starting to Program – An Introduction to Assembler

Loading in 2 Seconds...

play fullscreen
1 / 24

Starting to Program – An Introduction to Assembler - PowerPoint PPT Presentation


  • 83 Views
  • Uploaded on

Starting to Program – An Introduction to Assembler. Chapter Four. Outline. Introduction The PIC 16 Series Instruction Set Byte-oriented file register operations Bit-oriented file register operations Literal and control operations Instruction Formats Operation Types MPASM Assembler

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Starting to Program – An Introduction to Assembler' - chiara


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
outline
Outline
  • Introduction
  • The PIC 16 Series Instruction Set
  • Byte-oriented file register operations
  • Bit-oriented file register operations
  • Literal and control operations
  • Instruction Formats
  • Operation Types
  • MPASM Assembler
  • Example

Dr. Gheith Abandah

introduction
Introduction

Micro-controller Programming Options:

  • Machine Code

00 0111 0001 0101

  • Assembly Language: needs an assembler

addwf NUM, w

  • High-Level Language: needs a compiler

for (i=0; i<10; i++) sum += a[i];

Dr. Gheith Abandah

development process
Development Process

Dr. Gheith Abandah

alu data flow
ALU Data Flow

Dr. Gheith Abandah

the pic 16 series instruction set
The PIC 16 Series Instruction Set
  • 35 instructions
  • Three Groups:
    • Byte-oriented file register operations
    • Bit-oriented file register operations
    • Literal and control operations
  • Operation Types:
    • Arithmetic – Logic
    • Data movement – Control
    • Misc

Dr. Gheith Abandah

1 byte oriented file register operations
1. Byte-oriented file register operations
  • Format: op f, d
    • op: operation
    • f: number of file or register
    • d: destination (0: working register, 1: file register)
  • Example:

addwf PORTA, 0

Adds the contents of the working register and register PORTA, puts the result in the working register.

Dr. Gheith Abandah

2 bit oriented file register operations
2. Bit-oriented file register operations
  • Format: op f, b
    • op: operation
    • f: number of file or register
    • b: bit number, 0 through 7
  • Example:

bsf STATUS, 5

Sets to 1 Bit 5 of register STATUS.

Dr. Gheith Abandah

3 literal and control operations
3. Literal and control operations
  • Format: op k
    • op: operation
    • k: literal, an 8-bit if data or 11-bit if address
  • Examples:

addlw 5

Adds to the working register the value 5. call 9

Calls the subroutine at address 9.

Dr. Gheith Abandah

instruction formats
Instruction Formats

Dr. Gheith Abandah

arithmetic operations
Arithmetic Operations

Dr. Gheith Abandah

logic operations
Logic Operations

Dr. Gheith Abandah

data movement operations
Data Movement Operations

Dr. Gheith Abandah

control operations
Control Operations

Dr. Gheith Abandah

miscellaneous operations
Miscellaneous Operations

Dr. Gheith Abandah

assembler format
Assembler Format

Dr. Gheith Abandah

assembler directives
Assembler Directives

Dr. Gheith Abandah

example page 1
Example – Page 1

;***************************************************

;ELECTRONIC PING-PONG DATA MOVE

;This program moves push button switch values from

;Port A to the leds on Port B

;TJW 21.2.05 Tested 22.2.05

;***************************************************

;

;Configuration Word: WDT off, power-up timer on,

; code protect off, RC oscillator

;

list p=16F84A

Dr. Gheith Abandah

example page 2
Example – Page 2

;

;specify SFRs

status equ 03

porta equ 05

trisa equ 05

portb equ 06

trisb equ 06

;

Dr. Gheith Abandah

example page 3
Example – Page 3

;

org 00

;Initialise

start bsf status,5 ;select memory bank 1

movlw B’00011000’

movwf trisa ;set port A direction

movlw 00

movwf trisb ;all port B bits output

bcf status,5 ;select bank 0

Dr. Gheith Abandah

example page 4
Example – Page 4

;

;The "main" program starts here

clrf porta ;clear all bits in ports A

loop movf porta,0 ;move port A to W register

movwf portb ;move W register to port B

goto loop

end

Dr. Gheith Abandah

summary
Summary
  • Assembler is a programming language that is part of the toolset used in embedded systems programming. It comes with its own distinct set of rules and techniques.
  • It is essential to adopt and learn an IDE when developing programs. The MPLAB IDE is an excellent tool for PIC microcontrollers, both for learners and professionals. And it can’t be beaten on price!
  • While some people are eager to get programs into the hardware immediately, it is extremely useful to learn the features of a simulator. The simulator in MPLAB allows the user to test program features with great speed, and is an invaluable learning tool.

Dr. Gheith Abandah