SlideShare une entreprise Scribd logo
1  sur  24
ASSEMBLY FUNDAMENTALS
AHMED M. ABED
TEACHING ASSISTANT – ISLAMIC UNIVERSITY OF GAZA
AABED91@GMAIL.COM
AGENDA
• Fast Review
• Basic Elements of Assembly
INTRODUCTION
BASIC ELEMENTS OF ASSEMBLY
• Integer Constants
• Integer Expression
• Real Number Constants
• Character Constants
• String Constants

• Reserved Words
• Identifiers
• Directives
• Instructions
INTEGER CONSTANTS
• one or more digits, and an optional suffix character (called a radix)
indicating the number‟s base

[{+| −}] digits [radix]

• If no radix is given, the integer constant is assumed to be decimal
RADIX
• Radix may be one of the following (uppercase or lowercase):
Radix

Type

Radix

Type

H

Hexadecimal

R

Real

q/o

Octal

T

Decimal

D

Decimal

Y

Binary

B

Binary
INTEGER EXPRESSION
• An integer expression is a mathematical expression involving integer
values and arithmetic operators.
REAL NUMBER CONSTANTS
• Real number constants are represented as decimal reals or encoded
(hexadecimal) reals.

• A decimal real contains an optional sign followed by an integer
• A decimal point, an optional integer that expresses a fraction, and an
optional exponent
CHARACTER AND STRING CONSTANTS
• A character constant is a single character enclosed in single or double
quotes.
• „A‟
• “A”

• A string constant is a sequence of characters (including spaces)
enclosed in single or double quotes
• „Hi All‟
• “Welcome”
RESERVED WORDS
• Reserved words have special meaning Assembly and can only be
used in their correct context.
• Instruction mnemonics (MOV, ADD, SUB)
• Register names
• Directives
• Attributes, which provide size and usage information for variables and operands
• Operators, used in constant expressions
• Predefined symbols (@)
IDENTIFIERS
• An identifier is a programmer-chosen name. It might identify a
variable, a constant, a procedure, or a code label.
DIRECTIVES
• A directive is a command embedded in the source code that is
recognized and acted upon by the assembler.

• Directives do not execute at runtime.
• The .DATA directive identifies the area of a program containing variables
• The .CODE directive identifies the area of a program containing executable
instructions
INSTRUCTIONS
• An instruction is a statement that becomes executable when a
program is assembled.

• Instructions are translated by the assembler into machine language
bytes.

• Then loaded and executed by the CPU at runtime.
INSTRUCTIONS
• Instruction have four parts:
•
•
•
•

Label (optional)
Instruction mnemonic (required)
Operand(s) (usually required)
Comment (optional)

[label:] mnemonic [operands] [;comment]
INSTRUCTIONS - LABEL
• A label is an identifier that acts as a place marker for instructions and
data.

• Data Labels A data label identifies the location of a variable, providing
a convenient way to reference the variable in code.
• count DWORD 100

• The assembler assigns a numeric address to each label
INSTRUCTIONS - LABEL
• Code Labels A label in the code area of a program (where
instructions are located) must end with a colon (:) character.

• Code labels are used as targets of jumping and looping instructions.
• target:
• mov ax,bx
• ...
• jmp target
INSTRUCTION - INSTRUCTION MNEMONIC
• An instruction mnemonic is a short word that identifies an instruction.
Mnemonic

Description

MOV

Move (assign) one value to another

ADD

Add two values

SUB

Subtract one value from another

MUL

Multiply two values

JMP

Jump to a new location

CALL

Call a procedure
INSTRUCTION - OPERANDS
• Assembly language instructions can have between zero and three
operands.

• Each of which can be a register, memory operand, constant
expression, or input-output port.
INSTRUCTION - OPERANDS
• The INC instruction has one operand:
inc eax

; add 1 to EAX

• The MOV instruction has two operands:
mov count,ebx ; move EBX to count
INSTRUCTION - COMMENTS
• Comments are an important way for the writer of a program to
communicate information about the program‟s design to a person
reading the source code.

• The following information is typically included at the top of a program
listing:
• Description of the program‟s purpose
• Names of persons who created and/or revised the program
• Program creation and revision dates
• Technical notes about the program‟s implementation
INSTRUCTION - COMMENTS
• Comments can be specified in two ways:
• Single-line comments, beginning with a semicolon character (;).
• Block comments, beginning with the COMMENT directive and a user-specified
symbol
COMMENT !
This line is a comment.
This line is also a comment.
!
INSTRUCTION EXECUTION
• Fetch:
• The control unit fetches the next instruction from the instruction queue and
increments the instruction pointer (IP).

• Decode:
• The control unit decodes the instruction‟s function to determine what the
instruction will do.

• Fetch operands:
• If the instruction uses an input operand located in memory, the control unit uses
a read operation to retrieve the operand and copy it into internal registers
INSTRUCTION EXECUTION
• Execute:
• The ALU executes the instruction using the named registers and internal
registers as operands and sends the output to named registers and/or memory

• Store output operand:
• If the output operand is in memory, the control unit uses a write operation to
store the data.
INSTRUCTION EXECUTION
loop
fetch next instruction
advance the instruction pointer (IP)

decode the instruction
if memory operand needed, read value from memory
execute the instruction
if result is memory operand, write result to memory
continue loop

Contenu connexe

Tendances

Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
Abdul Khan
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Mir Majid
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
Ashim Saha
 
Chapter One
Chapter OneChapter One
Chapter One
bolovv
 

Tendances (20)

Introduction to Simplified instruction computer or SIC/XE
Introduction to Simplified instruction computer or SIC/XEIntroduction to Simplified instruction computer or SIC/XE
Introduction to Simplified instruction computer or SIC/XE
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Syntax directed-translation
Syntax directed-translationSyntax directed-translation
Syntax directed-translation
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Assembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe ProgrammersAssembler Language Tutorial for Mainframe Programmers
Assembler Language Tutorial for Mainframe Programmers
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
Presentation compiler design
Presentation compiler designPresentation compiler design
Presentation compiler design
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Pros and cons of c as a compiler language
  Pros and cons of c as a compiler language  Pros and cons of c as a compiler language
Pros and cons of c as a compiler language
 
Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Spr ch-02
Spr ch-02Spr ch-02
Spr ch-02
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly Language
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 
Chapter One
Chapter OneChapter One
Chapter One
 

Similaire à Part II: Assembly Fundamentals

Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
Ronaldo Aditya
 

Similaire à Part II: Assembly Fundamentals (20)

Assembler
AssemblerAssembler
Assembler
 
Valuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler DesignValuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler Design
 
Computer programming and utilization
Computer programming and utilizationComputer programming and utilization
Computer programming and utilization
 
Ch12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdfCh12- instruction sets- char & funct.pdf
Ch12- instruction sets- char & funct.pdf
 
EC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptxEC8691-MPMC-PPT.pptx
EC8691-MPMC-PPT.pptx
 
Introduction to Assembly Language & various basic things
Introduction to Assembly Language & various basic thingsIntroduction to Assembly Language & various basic things
Introduction to Assembly Language & various basic things
 
C language unit-1
C language unit-1C language unit-1
C language unit-1
 
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDYC LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
C LANGUAGE UNIT-1 PREPARED BY M V BRAHMANANDA REDDY
 
C languaGE UNIT-1
C languaGE UNIT-1C languaGE UNIT-1
C languaGE UNIT-1
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Unit 3 sp assembler
Unit 3 sp assemblerUnit 3 sp assembler
Unit 3 sp assembler
 
Concept of compiler in details
Concept of compiler in detailsConcept of compiler in details
Concept of compiler in details
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Embedded computing platform design
Embedded computing platform designEmbedded computing platform design
Embedded computing platform design
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Part II: Assembly Fundamentals

  • 1. ASSEMBLY FUNDAMENTALS AHMED M. ABED TEACHING ASSISTANT – ISLAMIC UNIVERSITY OF GAZA AABED91@GMAIL.COM
  • 2. AGENDA • Fast Review • Basic Elements of Assembly
  • 4. BASIC ELEMENTS OF ASSEMBLY • Integer Constants • Integer Expression • Real Number Constants • Character Constants • String Constants • Reserved Words • Identifiers • Directives • Instructions
  • 5. INTEGER CONSTANTS • one or more digits, and an optional suffix character (called a radix) indicating the number‟s base [{+| −}] digits [radix] • If no radix is given, the integer constant is assumed to be decimal
  • 6. RADIX • Radix may be one of the following (uppercase or lowercase): Radix Type Radix Type H Hexadecimal R Real q/o Octal T Decimal D Decimal Y Binary B Binary
  • 7. INTEGER EXPRESSION • An integer expression is a mathematical expression involving integer values and arithmetic operators.
  • 8. REAL NUMBER CONSTANTS • Real number constants are represented as decimal reals or encoded (hexadecimal) reals. • A decimal real contains an optional sign followed by an integer • A decimal point, an optional integer that expresses a fraction, and an optional exponent
  • 9. CHARACTER AND STRING CONSTANTS • A character constant is a single character enclosed in single or double quotes. • „A‟ • “A” • A string constant is a sequence of characters (including spaces) enclosed in single or double quotes • „Hi All‟ • “Welcome”
  • 10. RESERVED WORDS • Reserved words have special meaning Assembly and can only be used in their correct context. • Instruction mnemonics (MOV, ADD, SUB) • Register names • Directives • Attributes, which provide size and usage information for variables and operands • Operators, used in constant expressions • Predefined symbols (@)
  • 11. IDENTIFIERS • An identifier is a programmer-chosen name. It might identify a variable, a constant, a procedure, or a code label.
  • 12. DIRECTIVES • A directive is a command embedded in the source code that is recognized and acted upon by the assembler. • Directives do not execute at runtime. • The .DATA directive identifies the area of a program containing variables • The .CODE directive identifies the area of a program containing executable instructions
  • 13. INSTRUCTIONS • An instruction is a statement that becomes executable when a program is assembled. • Instructions are translated by the assembler into machine language bytes. • Then loaded and executed by the CPU at runtime.
  • 14. INSTRUCTIONS • Instruction have four parts: • • • • Label (optional) Instruction mnemonic (required) Operand(s) (usually required) Comment (optional) [label:] mnemonic [operands] [;comment]
  • 15. INSTRUCTIONS - LABEL • A label is an identifier that acts as a place marker for instructions and data. • Data Labels A data label identifies the location of a variable, providing a convenient way to reference the variable in code. • count DWORD 100 • The assembler assigns a numeric address to each label
  • 16. INSTRUCTIONS - LABEL • Code Labels A label in the code area of a program (where instructions are located) must end with a colon (:) character. • Code labels are used as targets of jumping and looping instructions. • target: • mov ax,bx • ... • jmp target
  • 17. INSTRUCTION - INSTRUCTION MNEMONIC • An instruction mnemonic is a short word that identifies an instruction. Mnemonic Description MOV Move (assign) one value to another ADD Add two values SUB Subtract one value from another MUL Multiply two values JMP Jump to a new location CALL Call a procedure
  • 18. INSTRUCTION - OPERANDS • Assembly language instructions can have between zero and three operands. • Each of which can be a register, memory operand, constant expression, or input-output port.
  • 19. INSTRUCTION - OPERANDS • The INC instruction has one operand: inc eax ; add 1 to EAX • The MOV instruction has two operands: mov count,ebx ; move EBX to count
  • 20. INSTRUCTION - COMMENTS • Comments are an important way for the writer of a program to communicate information about the program‟s design to a person reading the source code. • The following information is typically included at the top of a program listing: • Description of the program‟s purpose • Names of persons who created and/or revised the program • Program creation and revision dates • Technical notes about the program‟s implementation
  • 21. INSTRUCTION - COMMENTS • Comments can be specified in two ways: • Single-line comments, beginning with a semicolon character (;). • Block comments, beginning with the COMMENT directive and a user-specified symbol COMMENT ! This line is a comment. This line is also a comment. !
  • 22. INSTRUCTION EXECUTION • Fetch: • The control unit fetches the next instruction from the instruction queue and increments the instruction pointer (IP). • Decode: • The control unit decodes the instruction‟s function to determine what the instruction will do. • Fetch operands: • If the instruction uses an input operand located in memory, the control unit uses a read operation to retrieve the operand and copy it into internal registers
  • 23. INSTRUCTION EXECUTION • Execute: • The ALU executes the instruction using the named registers and internal registers as operands and sends the output to named registers and/or memory • Store output operand: • If the output operand is in memory, the control unit uses a write operation to store the data.
  • 24. INSTRUCTION EXECUTION loop fetch next instruction advance the instruction pointer (IP) decode the instruction if memory operand needed, read value from memory execute the instruction if result is memory operand, write result to memory continue loop