SlideShare a Scribd company logo
ASSEMBLY BASICS
SUBMITTED BY :
SHILPA B G
ASSEMBLY LANGUAGE : BASIC SYNTAX
 In assembler code, the following instruction formatting is
commonly used:
label
opcode operand1, operand2, ...; Comments
 The label is optional. Some of the instructions might have a label in
front of them so that the address of the instructions can be
determined using the label.
 Then, we will find the opcode (the instruction) followed by a
number of operands. Normally, the first operand is the destination
of the operation.
 The number of operands in an instruction depends on the type
of instruction.
 The syntax format of the operand can also be different. For
example, immediate data are usually in the form #number, as
shown here:
MOV R0, #0x12 ; Set R0 = 0x12 (hexadecimal)
MOV R1, #'A' ; Set R1 = ASCII character A
 The text after each semicolon (;) is a comment. These
comments do not affect the program operation, but they can
make programs easier for humans to understand.
 We can define constants using EQU, and then use them inside your
program code. For example,
NVIC_IRQ_SETEN0 EQU 0xE000E100
NVIC_IRQ0_ENABLE EQU 0x1
...
LDR R0,=NVIC_IRQ_SETEN0; ; LDR here is a pseudo-instruction that
; convert to a PC relative load by
; assembler.
MOV R1,#NVIC_IRQ0_ENABLE ; Move immediate data to register
STR R1,[R0] ; Enable IRQ 0 by writing R1 to address
; in R0
 A number of data definition directives are available for insertion of
constants inside assembly code.
 For example, DCI (Define Constant Instruction) can be used to code
an instruction if your assembler cannot generate the exact instruction
that we want and if we know the binary code for the instruction.
DCI 0xBE00 ; Breakpoint (BKPT 0), a 16-bit instruction
 We can use DCB (Define Constant Byte) for byte size constant values,
such as characters, and Define Constant Data (DCD) for word size
constant values to define binary data in your code.
LDR R3,=MY_NUMBER ; Get the memory address value of MY_NUMBER
LDR R4,[R3] ; Get the value code 0x12345678 in R4
...
LDR R0,=HELLO_TXT ; Get the starting memory address of
; HELLO_TXT
BL PrintText ; Call a function called PrintText to
; display string
...
MY_NUMBER
DCD 0x12345678
HELLO_TXT
DCB "Hellon",0 ; null terminated string
ASSEMBLER LANGUAGE : USE OF SUFFIXES
 For the Cortex-M3, the conditional execution suffixes are usually
used for branch instructions.
 However, other instructions can also be used with the conditional
execution suffixes if they are inside an IF-THEN instruction
block.
 In this cases, the S suffix and the conditional execution
suffixes can be used at the same time.
ASSEMBLER LANGUAGE : UNIFIED
ASSEMBLER LANGUAGE
 To support and get the best out of the Thumb®-2 instruction set, the
Unified Assembler Language (UAL) was developed to allow selection
of 16-bit and 32-bit instructions and to make it easier to port
applications between ARM code and Thumb code by using the same
syntax for both. (With UAL, the syntax of Thumb instructions is now
the same as for ARM instructions.)
ADD R0, R1 ; R0 = R0 + R1, using Traditional Thumb syntax
ADD R0, R0, R1 ; Equivalent instruction using UAL syntax
 The traditional Thumb syntax can still be used. The choice between
whether the instructions are interpreted as traditional Thumb code or
the new UAL syntax is normally defined by the directive in the
assembly file.
 For example, with ARM assembler tool, a program code header with
“CODE16” directive implies the code is in the traditional Thumb
syntax, and “THUMB” directive implies the code is in the new UAL
syntax.
 One thing you need to be careful with reusing traditional Thumb is
that some instructions change the flags in APSR, even if the S suffix
is not used. However, when the UAL syntax is used, whether
the instruction changes the flag depends on the S suffix. For
example,
AND R0, R1 ; Traditional Thumb syntax
AND R0, R0, R1 ; Equivalent UAL syntax (S suffix is added)
 With the new instructions in Thumb-2 technology, some of the
operations can be handled by either a Thumb instruction or a
Thumb-2 instruction.
 For example, R0 = R0 + 1 can be implemented as a 16-bit Thumb
instruction or a 32-bit Thumb-2 instruction.
 With UAL, you can specify which instruction you want by adding
suffixes:
ADDS R0, #1 ; Use 16-bit Thumb instruction by default
; for smaller size
ADDS.N R0, #1 ; Use 16-bit Thumb instruction (N=Narrow)
ADDS.W R0, #1 ; Use 32-bit Thumb-2 instruction (W=wide)
 The .W (wide) suffix specifies a 32-bit instruction. If no suffix is
given, the assembler tool can choose either instruction but usually
defaults to 16-bit Thumb code to get a smaller size.
 Depending on tool support, you may also use the .N (narrow)
suffix to specify a 16-bit Thumb instruction.
 Again, this syntax is for ARM assembler tools. Other assemblers
might have slightly different syntax.
 If no suffix is given, the assembler might choose the instruction for
you, with the minimum code size In most cases, applications will be
coded in C, and the C compilers will use 16-bit instructions if
possible due to smaller code size. However, when the immediate
data exceed a certain range or when the operation can be better
handled with a 32-bit Thumb-2 instruction, the 32-bit instruction
will be used.
 The 32-bit Thumb-2 instructions can be half word aligned. For
example, you can have a 32-bit instruction located in a half word
location.
0x1000 : LDR r0,[r1] ;a 16-bit instructions (occupy 0x10000x1001)
0x1002 : RBIT.W r0 ;a 32-bit Thumb-2 instruction (occupy
; 0x1002-0x1005)
 Most of the 16-bit instructions can only access registers R0–R7;
32-bit Thumb-2 instructions do not have this limitation.
 However, use of PC (R15) might not be allowed in some of the
instructions. Refer to the ARM v7-M Architecture Application
Level Reference Manual [Ref. 2] (section A4.6) if you need to
find out more detail in this area.
Assembly basics

More Related Content

What's hot

Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
Chapter 5 programming concepts iv
Chapter 5  programming concepts ivChapter 5  programming concepts iv
Chapter 5 programming concepts iv
SHREEHARI WADAWADAGI
 
Chapter 3 programming concepts-ii
Chapter 3  programming concepts-iiChapter 3  programming concepts-ii
Chapter 3 programming concepts-ii
SHREEHARI WADAWADAGI
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
Mohammed A. Imran
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
Muhammad Sikandar Mustafa
 
Msp430 assembly language instructions &addressing modes
Msp430 assembly language instructions &addressing modesMsp430 assembly language instructions &addressing modes
Msp430 assembly language instructions &addressing modes
Harsha herle
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
Nora Youssef
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
United International University
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediateJohn Cutajar
 
Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086
SHREEHARI WADAWADAGI
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086
Urvashi Singh
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
Kartik Sharma
 
8086 alp
8086 alp8086 alp
Orca share media1492336349924
Orca share media1492336349924Orca share media1492336349924
Orca share media1492336349924
Sudip Simkhada
 
ARM Architecture Subroutine and Flags
ARM Architecture Subroutine and FlagsARM Architecture Subroutine and Flags
ARM Architecture Subroutine and Flags
COMSATS Institute of Information Technology Abbottabad
 

What's hot (20)

Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
Lecture6
Lecture6Lecture6
Lecture6
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
Chapter 5 programming concepts iv
Chapter 5  programming concepts ivChapter 5  programming concepts iv
Chapter 5 programming concepts iv
 
Chapter 3 programming concepts-ii
Chapter 3  programming concepts-iiChapter 3  programming concepts-ii
Chapter 3 programming concepts-ii
 
Computer design
Computer designComputer design
Computer design
 
Assembly language part I
Assembly language part IAssembly language part I
Assembly language part I
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Advanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter pptAdvanced procedures in assembly language Full chapter ppt
Advanced procedures in assembly language Full chapter ppt
 
Msp430 assembly language instructions &addressing modes
Msp430 assembly language instructions &addressing modesMsp430 assembly language instructions &addressing modes
Msp430 assembly language instructions &addressing modes
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086Chapter 1 archietecture of 8086
Chapter 1 archietecture of 8086
 
Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086Assembler directives and basic steps ALP of 8086
Assembler directives and basic steps ALP of 8086
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
8086 alp
8086 alp8086 alp
8086 alp
 
Orca share media1492336349924
Orca share media1492336349924Orca share media1492336349924
Orca share media1492336349924
 
ARM Architecture Subroutine and Flags
ARM Architecture Subroutine and FlagsARM Architecture Subroutine and Flags
ARM Architecture Subroutine and Flags
 

Similar to Assembly basics

armcortexinsructionsetupdated (2).pptx
armcortexinsructionsetupdated (2).pptxarmcortexinsructionsetupdated (2).pptx
armcortexinsructionsetupdated (2).pptx
ssuserda88a7
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
Manju Badiger
 
Module 2 PPT of ES.pptx
Module 2 PPT of ES.pptxModule 2 PPT of ES.pptx
Module 2 PPT of ES.pptx
shruthi810379
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directives
Manoj Harsule
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
Dr. Pankaj Zope
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Shrishail Bhat
 
Intel µp instruction encoding and decoding
Intel µp instruction encoding and decodingIntel µp instruction encoding and decoding
Intel µp instruction encoding and decoding
yocirem
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 p
rsamurti
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
Education Front
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructions
hepzijustin
 
Computer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docxComputer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docx
brownliecarmella
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
Stefan Oprea
 
Unit ii arm7 thumb
Unit ii arm7 thumbUnit ii arm7 thumb
Unit ii arm7 thumb
Dr. Pankaj Zope
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb Instruction
Dr. Pankaj Zope
 
arm-intro.ppt
arm-intro.pptarm-intro.ppt
arm-intro.ppt
MostafaParvin1
 
Unit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptxUnit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptx
VijayKumar201823
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
Bellaj Badr
 

Similar to Assembly basics (20)

armcortexinsructionsetupdated (2).pptx
armcortexinsructionsetupdated (2).pptxarmcortexinsructionsetupdated (2).pptx
armcortexinsructionsetupdated (2).pptx
 
Arm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.pptArm Cortex material Arm Cortex material3222886.ppt
Arm Cortex material Arm Cortex material3222886.ppt
 
Module 2 PPT of ES.pptx
Module 2 PPT of ES.pptxModule 2 PPT of ES.pptx
Module 2 PPT of ES.pptx
 
Microcontroller directives
Microcontroller directivesMicrocontroller directives
Microcontroller directives
 
Arm
ArmArm
Arm
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
 
Lecture8
Lecture8Lecture8
Lecture8
 
Alp 05
Alp 05Alp 05
Alp 05
 
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
Embedded Systems (18EC62) - ARM Cortex-M3 Instruction Set and Programming (Mo...
 
Intel µp instruction encoding and decoding
Intel µp instruction encoding and decodingIntel µp instruction encoding and decoding
Intel µp instruction encoding and decoding
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 p
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Microprocessor instructions
Microprocessor instructionsMicroprocessor instructions
Microprocessor instructions
 
Computer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docxComputer architecture is made up of two main components the Instruct.docx
Computer architecture is made up of two main components the Instruct.docx
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Unit ii arm7 thumb
Unit ii arm7 thumbUnit ii arm7 thumb
Unit ii arm7 thumb
 
Unit II Arm7 Thumb Instruction
Unit II Arm7 Thumb InstructionUnit II Arm7 Thumb Instruction
Unit II Arm7 Thumb Instruction
 
arm-intro.ppt
arm-intro.pptarm-intro.ppt
arm-intro.ppt
 
Unit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptxUnit 4 _ ARM Processors .pptx
Unit 4 _ ARM Processors .pptx
 
C from hello world to 010101
C from hello world to 010101C from hello world to 010101
C from hello world to 010101
 

Recently uploaded

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 

Recently uploaded (20)

NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 

Assembly basics

  • 2. ASSEMBLY LANGUAGE : BASIC SYNTAX  In assembler code, the following instruction formatting is commonly used: label opcode operand1, operand2, ...; Comments  The label is optional. Some of the instructions might have a label in front of them so that the address of the instructions can be determined using the label.  Then, we will find the opcode (the instruction) followed by a number of operands. Normally, the first operand is the destination of the operation.
  • 3.  The number of operands in an instruction depends on the type of instruction.  The syntax format of the operand can also be different. For example, immediate data are usually in the form #number, as shown here: MOV R0, #0x12 ; Set R0 = 0x12 (hexadecimal) MOV R1, #'A' ; Set R1 = ASCII character A  The text after each semicolon (;) is a comment. These comments do not affect the program operation, but they can make programs easier for humans to understand.
  • 4.  We can define constants using EQU, and then use them inside your program code. For example, NVIC_IRQ_SETEN0 EQU 0xE000E100 NVIC_IRQ0_ENABLE EQU 0x1 ... LDR R0,=NVIC_IRQ_SETEN0; ; LDR here is a pseudo-instruction that ; convert to a PC relative load by ; assembler. MOV R1,#NVIC_IRQ0_ENABLE ; Move immediate data to register STR R1,[R0] ; Enable IRQ 0 by writing R1 to address ; in R0  A number of data definition directives are available for insertion of constants inside assembly code.  For example, DCI (Define Constant Instruction) can be used to code an instruction if your assembler cannot generate the exact instruction that we want and if we know the binary code for the instruction. DCI 0xBE00 ; Breakpoint (BKPT 0), a 16-bit instruction
  • 5.  We can use DCB (Define Constant Byte) for byte size constant values, such as characters, and Define Constant Data (DCD) for word size constant values to define binary data in your code. LDR R3,=MY_NUMBER ; Get the memory address value of MY_NUMBER LDR R4,[R3] ; Get the value code 0x12345678 in R4 ... LDR R0,=HELLO_TXT ; Get the starting memory address of ; HELLO_TXT BL PrintText ; Call a function called PrintText to ; display string ... MY_NUMBER DCD 0x12345678 HELLO_TXT DCB "Hellon",0 ; null terminated string
  • 6. ASSEMBLER LANGUAGE : USE OF SUFFIXES  For the Cortex-M3, the conditional execution suffixes are usually used for branch instructions.  However, other instructions can also be used with the conditional execution suffixes if they are inside an IF-THEN instruction block.  In this cases, the S suffix and the conditional execution suffixes can be used at the same time.
  • 7.
  • 8. ASSEMBLER LANGUAGE : UNIFIED ASSEMBLER LANGUAGE  To support and get the best out of the Thumb®-2 instruction set, the Unified Assembler Language (UAL) was developed to allow selection of 16-bit and 32-bit instructions and to make it easier to port applications between ARM code and Thumb code by using the same syntax for both. (With UAL, the syntax of Thumb instructions is now the same as for ARM instructions.) ADD R0, R1 ; R0 = R0 + R1, using Traditional Thumb syntax ADD R0, R0, R1 ; Equivalent instruction using UAL syntax
  • 9.  The traditional Thumb syntax can still be used. The choice between whether the instructions are interpreted as traditional Thumb code or the new UAL syntax is normally defined by the directive in the assembly file.  For example, with ARM assembler tool, a program code header with “CODE16” directive implies the code is in the traditional Thumb syntax, and “THUMB” directive implies the code is in the new UAL syntax.  One thing you need to be careful with reusing traditional Thumb is that some instructions change the flags in APSR, even if the S suffix is not used. However, when the UAL syntax is used, whether the instruction changes the flag depends on the S suffix. For example, AND R0, R1 ; Traditional Thumb syntax AND R0, R0, R1 ; Equivalent UAL syntax (S suffix is added)
  • 10.  With the new instructions in Thumb-2 technology, some of the operations can be handled by either a Thumb instruction or a Thumb-2 instruction.  For example, R0 = R0 + 1 can be implemented as a 16-bit Thumb instruction or a 32-bit Thumb-2 instruction.  With UAL, you can specify which instruction you want by adding suffixes: ADDS R0, #1 ; Use 16-bit Thumb instruction by default ; for smaller size ADDS.N R0, #1 ; Use 16-bit Thumb instruction (N=Narrow) ADDS.W R0, #1 ; Use 32-bit Thumb-2 instruction (W=wide)
  • 11.  The .W (wide) suffix specifies a 32-bit instruction. If no suffix is given, the assembler tool can choose either instruction but usually defaults to 16-bit Thumb code to get a smaller size.  Depending on tool support, you may also use the .N (narrow) suffix to specify a 16-bit Thumb instruction.  Again, this syntax is for ARM assembler tools. Other assemblers might have slightly different syntax.  If no suffix is given, the assembler might choose the instruction for you, with the minimum code size In most cases, applications will be coded in C, and the C compilers will use 16-bit instructions if possible due to smaller code size. However, when the immediate data exceed a certain range or when the operation can be better handled with a 32-bit Thumb-2 instruction, the 32-bit instruction will be used.
  • 12.  The 32-bit Thumb-2 instructions can be half word aligned. For example, you can have a 32-bit instruction located in a half word location. 0x1000 : LDR r0,[r1] ;a 16-bit instructions (occupy 0x10000x1001) 0x1002 : RBIT.W r0 ;a 32-bit Thumb-2 instruction (occupy ; 0x1002-0x1005)  Most of the 16-bit instructions can only access registers R0–R7; 32-bit Thumb-2 instructions do not have this limitation.  However, use of PC (R15) might not be allowed in some of the instructions. Refer to the ARM v7-M Architecture Application Level Reference Manual [Ref. 2] (section A4.6) if you need to find out more detail in this area.