micro-controller in-set, Essays (university) of Microcomputers

duins hsdyubhsjd huygfvyuediu kjsamcomx nchdsyuc skj ckxmciosjmks klxmop

Typology: Essays (university)

2016/2017

Uploaded on 11/14/2017

diaa-alzammar
diaa-alzammar ๐Ÿ‡ฏ๐Ÿ‡ด

1 document

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Embedded Systems
PIC16F84A Instruction Set
Eng. Anis Nazer
Second Semester 2016-2017
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download micro-controller in-set and more Essays (university) Microcomputers in PDF only on Docsity!

Embedded Systems

PIC16F84A Instruction Set

Eng. Anis Nazer

Second Semester 2016-

PIC mid range ALU

Instruction format

MNEMONIC operand(s)

โ— (^) Examples: ADDWF 0x21, 0 SUBLW 0x MOVWF 0x

Instruction Set โ— Three categories:

  1. Byte instructions : operate on bytes of data

Instruction Set โ— Three categories:

  1. Literal instructions: operand is in the instruction itself

Example โ— (^) Describe briefly the operation of the following instructions:

CLRW

MOVLW 0x

MOVWF 0x0C

INCF 0x0C, 1

MOVF 0x0C, 0

ADDLW 0x

MOVWF 0x0D

Example โ— Write instructions to perform the following calculation and store the result in location 0x 0x11 + 0x32 โ€“ 0x2E MOVLW 0x ADDLW 0x MOVWF 0x MOVLW 0x2E SUBWF 0x25, 1

Another Example โ— (^) Write instructions to swap (exchange) the values stored in locations 0x20 and 0x

  1. move the value in location 0x20 to a temporary location
  2. move the value in location 0x21 to location 0x
  3. move the value in the temporary location to location 0x MOVF 0x20, 0 MOVWF 0x MOVF 0x21, 0 MOVWF 0x MOVF 0x23, 0 MOVWF 0x

Assembler โ— (^) For the MCU to understand the instruction, it has to be translated to machine language โ— Example: translate the following instruction to machine language:

MOVLW 0xF

โ†’ 11 0000 1111 0011 = 0x30F

BSF 0x2E, 4

โ†’ 01 0010 0010 1110 = 0x122E

IORWF 0x3A , 1 โ†’?

Assembler โ— (^) Example: translate the following machine language instruction to

assembly: 0x19C

โ— 0x19C4 = 01 1001 1100 0100

BTFSC 0x44, 3

โ— 0x16B

BSF 0x35, 5

โ— 0x2A3C

Microchip Assembler format

LABEL MNEMONIC operand(s)

โ— (^) LABEL: any word (except mnemonics) โ— (^) The label is optional, it is a reference point in the program โ— (^) The MNEMONIC cannot start on the first character on a line โ— (^) semi-colon used for comments โ— (^) Ex. loop ADDWF 0x33, 1 Label MNEMONIC Operands

Example โ— What does the following code do?

CLRF 0x

loop INCF 0x06 , 1

BTFSS 0x06 , 3

GOTO loop

CLRF 0x

Assembler directives โ—

Assembler directives are commands to the

assembler

โ—

Directives are not part of the instruction set

โ—

So, they are not instructions for the PIC

โ—

They are not translated to machine language

โ—

They simplify writing the program

Assembler Directive: EQU โ—

EQU: is an assembler directive used to define a

constant

โ—

for example:

age EQU 0x

โ—

here the assembler will find and replace all

occurrences of 'age' with 0x

age EQU 0x0F MOVLW D'23' MOVWF age MOVLW D'23' MOVWF 0x0F equivalent instructions