SlideShare a Scribd company logo
MICROCONTROLLER
ARCHITECTURE &
ASSEMBLY LANGUAGE
PROGRAMMING
Noriah bt Mustafa
POLITEKNIK SULTAN HAJI AHMAD SHAH
CHAPTER 2 – Part 2
EC501 EMBEDDED SYSTEM APPLICATIONS
OUTCOMES
 Know PIC Assembly Language fundamental
Overview
 PIC - "Peripheral Interface Controller”
 How to use PIC microcontroller?
 Hardware
 Software - programming
 Programming language
 Machine language – machine code
 Assembly language
 High level language  C, C++, Basic
Low level
language
Introduction
 Assembly language is programming language
use to write programs using instructions that are
the symbolic code called mnemonic.
 Assembly language programs must to be
translated into machine code by a program
called assembler.
 To program in assembly language, the
programmer must know all the registers of the
CPU and the size of each, as well as other
details.
Assembling and linking process
 First use a text editor to type program in assembly
language. In the case of PIC microcontrollers, we use the
MPLAB IDE.
 The “asm” source file is fed into PIC assembler. The
assembler converts the instructions into machine code.
 The third step is called linking. The link program takes
one or more object files and produces a hex file, a list
file, a map file, an intermediate abject file and a debug
file.
 After a successful link, the hex file is ready to be burned
into PIC’s program ROM and is downloaded into PIC
trainers.
Sample o a PIC Assembly Source Code (asm file)
Assembler Directives
 While instruction tell the CPU what to do, directives
(also called pseudo-instructions) give direction to the
assembler.
 Assembler directives are instruction used to tell the
CPU what to do.
 Examples of assembler directive :
EQU – equate (use to define value or a fixed address)
ORG – origin (use to indicate the beginning of the address for
code or data)
END – indicate the end of the source (asm) file.
Review Questions
1. What is the purpose of pseudo-instructions?
2. _____________ are translated by the assembler into
machine code, whereas _____________are not.
3. True or false. Assembly language is a high- level
language.
4. Pseudo- instruction are also called __________.
5. True or false. Assembler directives are not used by the
CPU itself. /they are simply guide to the assembler.
6. Which one the following is an assembler directive?
a) MOVLW 25H b) ADDLW 12 c) ORG 200H d) GOTO HERE
Data Format Representation
 The following are data type and data format
using for PIC microcontrollers.
Data Type Data Format
Hexadecimal 99H
0X99
h’99’
99
Decimal D’12’
Binary B’10011001’
ASCII A’2’
PIC18F instruction set.
 PIC18F2455/2550/4455/4550 devices
incorporate the standard set of 75 core instructions.
PIC18F
instruction
set.
PIC18F instruction set (cont.)
PIC18F instruction set (cont.)
MOVLW Instruction
 MOVLW Instruction moves 8-bit data into WREG
register. It has the following format:
MOVLW K ;move literal value K into WREG
 Example: Load the WREG register with value 25H.
MOVLW 25H ;move value 25H into WREG (WREG = 25H)
Operation: k → W
MOVWF Instruction
 The MOVWF instruction tells the CPU to move (in reality,
copy) the source register of WREG to a destination
register in file register (F).
 Example: Load value 66H into Port B, C and D.
MOVLW 66H ;move the value 66H to WREG (WREG = 66H)
MOVWF PORTB ; move the value in WREG to PORTB (PORTB = 66H)
MOVWF PORTC ;PORTC = 66H
MOVWF PORTD ;PORTD = 66H
MOVWF Move W to f Operation: (W) → f
Example
 Write assembly instruction to make the I/O port as
below :
a) RB4 and RB5 as input
b) PORTC as output
Solution:
a) MOVLW B’00110000’
MOVWF TRISB
b) MOVLW B’00110000’
MOVWF TRISB
Arithmetic Instruction
 Instructions for performing 8-bit addition,
subtraction and multiplication operation.
Addition
 These ADD instructions are design to perform 8-
bit addition.
 The execution result of the ADD instruction will
affect all flag bits of the STATUS register.
Operation: (W) + k → W
Addition (cont..)
Example
Write a program that add the hexadecimal numbers 0x20
and 0x30. Store the sum in data register at 0x50.
ORG 0X00
MOVLW 0X20
ADDLW 0X30
MOVWF 0X50,A
END
Example
Subtraction
• PIC18 microcontroller has two SUBTRACT
instructions. Subtract instruction will also affect all the
flag of STATUS register.
SUBLW Subtract W from Literal Operation: k – (W) → W
SUBWF Subtract W from f Operation: (f) – (W) → dest
Subtraction
Example
 Write a program to subtract 5 from 40H. Identify the
flag bit in status register.
Solution:
#include <pic18f4550>
ORG 0X00
MOVLW D’5’
SUBLW 0X40
END
Logic Instruction
 The logical instruction allow user to perform AND, OR,
exclusive-OR and complementing on 8-bit numbers.
Example
Example :
Write assembly statement for the operation 0XFF ||
0X55
MOVLW 0XFF ;move the value 0xFFin to WREG
IORLW 0X55 ;OR the value in WREG with value 0x55
Review Questions
Bit manipulation
 The bit operations set, clear and toggle
test only a single bit. The bit oriented
instructions available to PIC family are
BCF, BSF, BTFSC, BTFSS and BTG.
BCF Bit Clear f
Operation: 0 → f<b>
BSF Bit Set f Operation: 1 → f<b>
Bit manipulation
Example:
Write an assembly statement to make RB4 as
input an RC7 as output using bit addressable.
Solution:
BSF TRISB,4 ; set RB4 as input
BCF TRISC,7 ; make RC7 as output
Rotate Instruction
 PIC 18 families has four rotate instructions. Figure 2.
Illustrates this four rotate instructions.
RLCF Rotate Left f through Carry
RLNCF Rotate Left f (No Carry)
RRCF Rotate Right f through Carry
RRNCF Rotate Right f (No Carry)
Rotate
Example: RLCF
Data serialization
 One of the most widely used applications of the
rotate instructions. Data serialization is a process of
sending a byte of data, one bit at a time through a
single pin of microcontroller.
 The characteristic of data serialization are:
 Using the serial port.
 Using a programming technique to transfer data
one bit at a time and control the sequence of data
and spaces between them.
Data serialization
Example
Write a program to bring in a byte of data serially via
pin RC7 and save it in file register location 0x21. The byte
comes in with the LSB first.
Solution:
RCNT EQU 0x20
MYREG EQU 0x21
BSF TRISC,7
MOVLW 0x8
MOVWF RCNT
AGAIN BTFSC PORTC 7
BSF STATUS,C
BTFSS PORTC,7
BCF STATUS,C
RRCF MYREG,F
DECF RCNT F
BNZ AGAIN
Review Questions

More Related Content

What's hot

Design a pipeline
Design a pipelineDesign a pipeline
Design a pipeline
Farzana Aktar
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
parthi_arjun
 
Microcontroller pic 16 f877 registers memory ports
Microcontroller pic 16 f877 registers memory portsMicrocontroller pic 16 f877 registers memory ports
Microcontroller pic 16 f877 registers memory ports
Nilesh Bhaskarrao Bahadure
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
Dr.YNM
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
Abdelrahman Elewah
 
Features of 89c51,pic,avr &amp; arm processors
Features of 89c51,pic,avr &amp; arm processorsFeatures of 89c51,pic,avr &amp; arm processors
Features of 89c51,pic,avr &amp; arm processors
Vikas Dongre
 
temperature control using 8086 microprocessor by vikas arya
temperature control using 8086 microprocessor by vikas arya temperature control using 8086 microprocessor by vikas arya
temperature control using 8086 microprocessor by vikas arya
VIKAS ARYA
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
Sudhanshu Janwadkar
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
ssuser3a47cb
 
8085 microprocessor lab manual
8085 microprocessor lab manual8085 microprocessor lab manual
8085 microprocessor lab manual
Nithin Mohan
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Memory intrface and addrs modes
Memory intrface and addrs modesMemory intrface and addrs modes
Memory intrface and addrs modes
balbirvirdi
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
Ikhwan_Fakrudin
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manual
Dhaval Shukla
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
Gaurav Verma
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
THANDAIAH PRABU
 
program status word
program status wordprogram status word
program status word
sheetalverma38
 
Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"
surabhii007
 
8255 programming
8255 programming8255 programming
8255 programming
Jeyalaksmi V Professor ECE
 
Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder
Bharti Airtel Ltd.
 

What's hot (20)

Design a pipeline
Design a pipelineDesign a pipeline
Design a pipeline
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
Microcontroller pic 16 f877 registers memory ports
Microcontroller pic 16 f877 registers memory portsMicrocontroller pic 16 f877 registers memory ports
Microcontroller pic 16 f877 registers memory ports
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
Features of 89c51,pic,avr &amp; arm processors
Features of 89c51,pic,avr &amp; arm processorsFeatures of 89c51,pic,avr &amp; arm processors
Features of 89c51,pic,avr &amp; arm processors
 
temperature control using 8086 microprocessor by vikas arya
temperature control using 8086 microprocessor by vikas arya temperature control using 8086 microprocessor by vikas arya
temperature control using 8086 microprocessor by vikas arya
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
 
8085 microprocessor lab manual
8085 microprocessor lab manual8085 microprocessor lab manual
8085 microprocessor lab manual
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
Memory intrface and addrs modes
Memory intrface and addrs modesMemory intrface and addrs modes
Memory intrface and addrs modes
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
 
Microprocessor lab manual
Microprocessor lab manualMicroprocessor lab manual
Microprocessor lab manual
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
program status word
program status wordprogram status word
program status word
 
Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"
 
8255 programming
8255 programming8255 programming
8255 programming
 
Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder
 

Viewers also liked

Introduction to Embedded Systems and its Applications
Introduction to Embedded Systems and its ApplicationsIntroduction to Embedded Systems and its Applications
Introduction to Embedded Systems and its Applications
Gaurav Verma
 
Isi kandungan (latihan industri)
Isi kandungan (latihan industri)Isi kandungan (latihan industri)
Isi kandungan (latihan industri)
Ikhwan_Fakrudin
 
CMOS Topic 3 -_the_device
CMOS Topic 3 -_the_deviceCMOS Topic 3 -_the_device
CMOS Topic 3 -_the_device
Ikhwan_Fakrudin
 
Pengakuan
PengakuanPengakuan
Pengakuan
Ikhwan_Fakrudin
 
Embedded system (Chapter 5) part 1
Embedded system (Chapter 5) part 1Embedded system (Chapter 5) part 1
Embedded system (Chapter 5) part 1
Ikhwan_Fakrudin
 
CMOS Topic 6 -_designing_combinational_logic_circuits
CMOS Topic 6 -_designing_combinational_logic_circuitsCMOS Topic 6 -_designing_combinational_logic_circuits
CMOS Topic 6 -_designing_combinational_logic_circuits
Ikhwan_Fakrudin
 
Introduction To Embedded Systems
Introduction To Embedded SystemsIntroduction To Embedded Systems
Introduction To Embedded Systems
anishgoel
 
CMOS Topic 4 -_the_wire
CMOS Topic 4 -_the_wireCMOS Topic 4 -_the_wire
CMOS Topic 4 -_the_wire
Ikhwan_Fakrudin
 
report latihan industri politeknik ( Bab 1 )
report latihan industri politeknik ( Bab 1 )report latihan industri politeknik ( Bab 1 )
report latihan industri politeknik ( Bab 1 )
Ikhwan_Fakrudin
 
CMOS Topic 5 -_cmos_inverter
CMOS Topic 5 -_cmos_inverterCMOS Topic 5 -_cmos_inverter
CMOS Topic 5 -_cmos_inverter
Ikhwan_Fakrudin
 
Panduan menulis report akhir
Panduan menulis report akhirPanduan menulis report akhir
Panduan menulis report akhir
Ikhwan_Fakrudin
 
CMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodologyCMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodology
Ikhwan_Fakrudin
 
CMOS Topic 2 -manufacturing_process
CMOS Topic 2 -manufacturing_processCMOS Topic 2 -manufacturing_process
CMOS Topic 2 -manufacturing_process
Ikhwan_Fakrudin
 
INTRODUCTION_TO_IC
INTRODUCTION_TO_ICINTRODUCTION_TO_IC
INTRODUCTION_TO_IC
Ikhwan_Fakrudin
 

Viewers also liked (15)

Introduction to Embedded Systems and its Applications
Introduction to Embedded Systems and its ApplicationsIntroduction to Embedded Systems and its Applications
Introduction to Embedded Systems and its Applications
 
Isi kandungan (latihan industri)
Isi kandungan (latihan industri)Isi kandungan (latihan industri)
Isi kandungan (latihan industri)
 
CMOS Topic 3 -_the_device
CMOS Topic 3 -_the_deviceCMOS Topic 3 -_the_device
CMOS Topic 3 -_the_device
 
Pengakuan
PengakuanPengakuan
Pengakuan
 
Report latihan industri
Report latihan industriReport latihan industri
Report latihan industri
 
Embedded system (Chapter 5) part 1
Embedded system (Chapter 5) part 1Embedded system (Chapter 5) part 1
Embedded system (Chapter 5) part 1
 
CMOS Topic 6 -_designing_combinational_logic_circuits
CMOS Topic 6 -_designing_combinational_logic_circuitsCMOS Topic 6 -_designing_combinational_logic_circuits
CMOS Topic 6 -_designing_combinational_logic_circuits
 
Introduction To Embedded Systems
Introduction To Embedded SystemsIntroduction To Embedded Systems
Introduction To Embedded Systems
 
CMOS Topic 4 -_the_wire
CMOS Topic 4 -_the_wireCMOS Topic 4 -_the_wire
CMOS Topic 4 -_the_wire
 
report latihan industri politeknik ( Bab 1 )
report latihan industri politeknik ( Bab 1 )report latihan industri politeknik ( Bab 1 )
report latihan industri politeknik ( Bab 1 )
 
CMOS Topic 5 -_cmos_inverter
CMOS Topic 5 -_cmos_inverterCMOS Topic 5 -_cmos_inverter
CMOS Topic 5 -_cmos_inverter
 
Panduan menulis report akhir
Panduan menulis report akhirPanduan menulis report akhir
Panduan menulis report akhir
 
CMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodologyCMOS Topic 7 -_design_methodology
CMOS Topic 7 -_design_methodology
 
CMOS Topic 2 -manufacturing_process
CMOS Topic 2 -manufacturing_processCMOS Topic 2 -manufacturing_process
CMOS Topic 2 -manufacturing_process
 
INTRODUCTION_TO_IC
INTRODUCTION_TO_ICINTRODUCTION_TO_IC
INTRODUCTION_TO_IC
 

Similar to Embedded system (Chapter 2) part 2

Ch2 microcontroller architecture
Ch2 microcontroller architectureCh2 microcontroller architecture
Ch2 microcontroller architecture
Ahmad Sidik
 
Highridge ISA
Highridge ISAHighridge ISA
Highridge ISA
Alec Selfridge
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
sergejsvolkovs10
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
powellabril
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
powellabril
 
Picmico
PicmicoPicmico
Picmico
loges91
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
rajeshkvdn
 
CH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptxCH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptx
XyzXyz338506
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
Dilum Bandara
 
ECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.com
sholingarjosh102
 
ECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.com
santricksapiens71
 
Ecet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comEcet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.com
WilliamsTaylorzm
 
Ecet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comEcet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.com
Stephenson033
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
vijaydeepakg
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
Omar Sanchez
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
nitugatkal
 
Presentation
PresentationPresentation
Presentation
Abhijit Das
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
vijaydeepakg
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
PRADEEP
 

Similar to Embedded system (Chapter 2) part 2 (20)

Ch2 microcontroller architecture
Ch2 microcontroller architectureCh2 microcontroller architecture
Ch2 microcontroller architecture
 
Highridge ISA
Highridge ISAHighridge ISA
Highridge ISA
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
Picmico
PicmicoPicmico
Picmico
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
 
CH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptxCH-3 CO-all-about-operating-system(Update).pptx
CH-3 CO-all-about-operating-system(Update).pptx
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
ECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.comECET 330 Technology levels--snaptutorial.com
ECET 330 Technology levels--snaptutorial.com
 
ECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.comECET 330 Massive Success--snaptutorial.com
ECET 330 Massive Success--snaptutorial.com
 
Ecet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.comEcet 330 Success Begins / snaptutorial.com
Ecet 330 Success Begins / snaptutorial.com
 
Ecet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.comEcet 330 Enthusiastic Study / snaptutorial.com
Ecet 330 Enthusiastic Study / snaptutorial.com
 
Basic programming of 8085
Basic programming of 8085 Basic programming of 8085
Basic programming of 8085
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
Presentation
PresentationPresentation
Presentation
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 

Recently uploaded

Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 

Recently uploaded (20)

Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 

Embedded system (Chapter 2) part 2

  • 1. MICROCONTROLLER ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING Noriah bt Mustafa POLITEKNIK SULTAN HAJI AHMAD SHAH CHAPTER 2 – Part 2 EC501 EMBEDDED SYSTEM APPLICATIONS
  • 2. OUTCOMES  Know PIC Assembly Language fundamental
  • 3. Overview  PIC - "Peripheral Interface Controller”  How to use PIC microcontroller?  Hardware  Software - programming  Programming language  Machine language – machine code  Assembly language  High level language  C, C++, Basic Low level language
  • 4. Introduction  Assembly language is programming language use to write programs using instructions that are the symbolic code called mnemonic.  Assembly language programs must to be translated into machine code by a program called assembler.
  • 5.  To program in assembly language, the programmer must know all the registers of the CPU and the size of each, as well as other details.
  • 6. Assembling and linking process  First use a text editor to type program in assembly language. In the case of PIC microcontrollers, we use the MPLAB IDE.  The “asm” source file is fed into PIC assembler. The assembler converts the instructions into machine code.  The third step is called linking. The link program takes one or more object files and produces a hex file, a list file, a map file, an intermediate abject file and a debug file.  After a successful link, the hex file is ready to be burned into PIC’s program ROM and is downloaded into PIC trainers.
  • 7.
  • 8. Sample o a PIC Assembly Source Code (asm file)
  • 9. Assembler Directives  While instruction tell the CPU what to do, directives (also called pseudo-instructions) give direction to the assembler.  Assembler directives are instruction used to tell the CPU what to do.  Examples of assembler directive : EQU – equate (use to define value or a fixed address) ORG – origin (use to indicate the beginning of the address for code or data) END – indicate the end of the source (asm) file.
  • 10. Review Questions 1. What is the purpose of pseudo-instructions? 2. _____________ are translated by the assembler into machine code, whereas _____________are not. 3. True or false. Assembly language is a high- level language. 4. Pseudo- instruction are also called __________. 5. True or false. Assembler directives are not used by the CPU itself. /they are simply guide to the assembler. 6. Which one the following is an assembler directive? a) MOVLW 25H b) ADDLW 12 c) ORG 200H d) GOTO HERE
  • 11. Data Format Representation  The following are data type and data format using for PIC microcontrollers. Data Type Data Format Hexadecimal 99H 0X99 h’99’ 99 Decimal D’12’ Binary B’10011001’ ASCII A’2’
  • 12. PIC18F instruction set.  PIC18F2455/2550/4455/4550 devices incorporate the standard set of 75 core instructions.
  • 16. MOVLW Instruction  MOVLW Instruction moves 8-bit data into WREG register. It has the following format: MOVLW K ;move literal value K into WREG  Example: Load the WREG register with value 25H. MOVLW 25H ;move value 25H into WREG (WREG = 25H) Operation: k → W
  • 17. MOVWF Instruction  The MOVWF instruction tells the CPU to move (in reality, copy) the source register of WREG to a destination register in file register (F).  Example: Load value 66H into Port B, C and D. MOVLW 66H ;move the value 66H to WREG (WREG = 66H) MOVWF PORTB ; move the value in WREG to PORTB (PORTB = 66H) MOVWF PORTC ;PORTC = 66H MOVWF PORTD ;PORTD = 66H MOVWF Move W to f Operation: (W) → f
  • 18. Example  Write assembly instruction to make the I/O port as below : a) RB4 and RB5 as input b) PORTC as output Solution: a) MOVLW B’00110000’ MOVWF TRISB b) MOVLW B’00110000’ MOVWF TRISB
  • 19. Arithmetic Instruction  Instructions for performing 8-bit addition, subtraction and multiplication operation.
  • 20. Addition  These ADD instructions are design to perform 8- bit addition.  The execution result of the ADD instruction will affect all flag bits of the STATUS register. Operation: (W) + k → W
  • 21. Addition (cont..) Example Write a program that add the hexadecimal numbers 0x20 and 0x30. Store the sum in data register at 0x50. ORG 0X00 MOVLW 0X20 ADDLW 0X30 MOVWF 0X50,A END
  • 23. Subtraction • PIC18 microcontroller has two SUBTRACT instructions. Subtract instruction will also affect all the flag of STATUS register. SUBLW Subtract W from Literal Operation: k – (W) → W SUBWF Subtract W from f Operation: (f) – (W) → dest
  • 24. Subtraction Example  Write a program to subtract 5 from 40H. Identify the flag bit in status register. Solution: #include <pic18f4550> ORG 0X00 MOVLW D’5’ SUBLW 0X40 END
  • 25. Logic Instruction  The logical instruction allow user to perform AND, OR, exclusive-OR and complementing on 8-bit numbers.
  • 26. Example Example : Write assembly statement for the operation 0XFF || 0X55 MOVLW 0XFF ;move the value 0xFFin to WREG IORLW 0X55 ;OR the value in WREG with value 0x55
  • 28. Bit manipulation  The bit operations set, clear and toggle test only a single bit. The bit oriented instructions available to PIC family are BCF, BSF, BTFSC, BTFSS and BTG. BCF Bit Clear f Operation: 0 → f<b> BSF Bit Set f Operation: 1 → f<b>
  • 29. Bit manipulation Example: Write an assembly statement to make RB4 as input an RC7 as output using bit addressable. Solution: BSF TRISB,4 ; set RB4 as input BCF TRISC,7 ; make RC7 as output
  • 30. Rotate Instruction  PIC 18 families has four rotate instructions. Figure 2. Illustrates this four rotate instructions. RLCF Rotate Left f through Carry RLNCF Rotate Left f (No Carry) RRCF Rotate Right f through Carry RRNCF Rotate Right f (No Carry)
  • 32. Data serialization  One of the most widely used applications of the rotate instructions. Data serialization is a process of sending a byte of data, one bit at a time through a single pin of microcontroller.  The characteristic of data serialization are:  Using the serial port.  Using a programming technique to transfer data one bit at a time and control the sequence of data and spaces between them.
  • 33. Data serialization Example Write a program to bring in a byte of data serially via pin RC7 and save it in file register location 0x21. The byte comes in with the LSB first. Solution: RCNT EQU 0x20 MYREG EQU 0x21 BSF TRISC,7 MOVLW 0x8 MOVWF RCNT AGAIN BTFSC PORTC 7 BSF STATUS,C BTFSS PORTC,7 BCF STATUS,C RRCF MYREG,F DECF RCNT F BNZ AGAIN