SlideShare una empresa de Scribd logo
1 de 23
Assembly Language


   Prakash Khaire
        UTU
Assembly Language
 A programming language that is one step away from machine
  language.

 Each assembly language statement is translated into one
  machine instruction by the assembler.

 Programmers must be well versed in the computer's
  architecture, and, undocumented assembly language
  programs are difficult to maintain.

 It is hardware dependent; there is a different assembly
  language for each CPU series.
Assembly Language
 It was introduced in 1952
 Helped to overcome machine language
 programming
Definition : “A language that allows
 instructions and storage locations to be
 represented by letters and symbols instead of
 numbers is called assembly language or
 symbolic language”
Assembly Language Model


       …
       add r1,r2
       sub r2,r3
PC     cmp r3,r4
                    ALU
       bne I1             Registers   Memory
       sub r4,1
       I1: jmp I3
       …
Assembly Language Instructions
Built from two pieces
         Add R1, R3, 3



    Opcode            Operands
 What to do with     Where to get
    the data         data and put
 (ALU operation)      the results
Types of Opcodes
Arithmetic, logical
  add, sub, mult
  and, or
  Cmp
Memory load/store
  ld, st
Control transfer
  jmp
  bne
Operands
Each operand taken from a particular
  addressing mode:
Examples:
Register       add r1, r2, r3
Immediate      add r1, r2, 10
Indirect       mov r1, (r2)
Offset              mov r1, 10(r3)
PC Relative         beq 100

Reflect processor data pathways
Advantages over Machine Language

Easier to understand and use
Easier to locate and correct errors.
Easier to modify
No worry about addresses
Easily relocatable
Efficiency of machine language
Limitations of Assembly Language

Machine Dependent
Knowledge of hardware required
Machine level coding
Architecture of 8086
Registers in 8086 CPU
 There are four general purpose registers
    AX [divided into AH/AL] – the accumulator register
    BX [divided into BH/BL] – the base address register
    CX [divided into CH/CL] – the count register
    DX [divided into DH/DL] – the data register
Other registers
    SI – source index register
    DI – destination index register
    BP – Base pointer
    SP – Stack pointer
Registers in 8086 CPU
 This registers are of 16 bits and divided into two 8 bit registers
    For Example
      If AX = 0011000000111001b then AH = 00110000b and AL=001111001b
    Registers are located in CPU,
 Segment Registers
    Used for special purpose pointing at accessible blocks of memory
    It stores any data
    Four segment registers during execution
        CS – Points the segment storing the current program
        DS – Points the segment where variable are defined
        ES – Extra Segment register, depends on the usage of coder
        SS – Points to the segment containing the stack

 Along with general purpose registers, segment registers work
  to access any memory value.
Flags
 FLAG : The FLAG register is the status register in the Intel 8086
  microprocessor that contains the current state of the microprocessor. This
  register is 16 bits wide.
     carry flag (CF)- indicates a carry after addition or a borrow after subtraction, also
      indicates error conditions.
     parity flag (PF)- is a logic “0” for odd parity and a logic “1” for even parity.
     auxiliary carry flag (AF)- important for BCD addition and subtraction; holds a carry
      (borrow) after addition (subtraction) between bits position 3 and 4. Only used for
      DAA and DAS instructions to adjust the value of AL after a BCD addition
      (subtraction).
     zero flag (ZF)- indicates that the result of an arithmetic or logic operation is zero.
     sign flag (SF)- indicates arithmetic sign of the result after an arithmetic operation.
     overflow flag (OF)- a condition that occurs when signed numbers are added or
      subtracted. An overflow indicates that the result has exceeded the capacity of the
      machine.
Offset
 The offset address in an 8086/8088 is the logical address that
  the program "thinks about" when it addresses a location in
  memory.
 The Execution Unit (EU or CPU) is responsible for generating
  the offset address.
 The Bus Interface Unit (BIU), on the other hand, takes the
  offset address and adds it to four times the selected segment
  register value in order to determine a real address, which is
  now 20-bits in length.
Registers in 8086 CPU
 Programmers access various memory locations on combining
  BX, SI, DI and BP registers.
    The value in segment registers[CS, DS, SS,ES] is called “segment”
    The value in purpose registers [BX, SI, DI, BP] is called “offset”

    For Example
        DS contains value 1234h and SI contains the value 7890h it can also be recorded as
         1234:7890
 Two special purpose registers
    IP – Instruction Register
    Flags Register – determines the current state of the processor
Registers in 8086 CPU
 IP works along with CS register and points to the currently
  executing instruction
 Flags register is modified by CPU, while performing
  mathematical operations
Assembler Design Approach
Assembler generates object code.
Role of assembler – Translates the source
 code into target code
During this translation process it uses various
 table like
  Machine Opcode Table
  Symbol table
  Literal table
Assembler Design Approach
Machine Opcode Table
   It holds opcode used by the processor for
   different instructions mnemonics

          Mnemonic                    size                  Opcode



  Holds various instructions                     Size of instructions in bytes


                         Size of instructions in bytes
Symbol Table
 It is data structure used by assmebler
 It keeps into account attributes of the identifier and other
  information.
    Attributes : type, value, scope and address
 It also performs the function of book keeping.
 It is composed of multiple word entries in fixed format
             Name                Value             Type
One Pass Assembler
Does everything in one pass
Problem: How do we handle forward references?
Could eliminate forward references
  easy for data – just define the data areas before they are
   referenced
  not easy in code – how do we handle selection or loop
   statements which have forward jumps?
Two types of one pass assemblers:
  produce object code directly in memory
  produce object program for later execution
One Pass Assembler
 Assembler generates object code instructions as it scans source
  program
 If an operand symbol has not yet been defined
    operand address is set to 0 in instruction
    symbol is entered into the symbol table (unless it is already
      present)
    entry is flagged to indicate the symbol is undefined
    address of instruction is added to list of forward references
      associated with this symbol
 When symbol definition is encountered
    forward reference list is scanned, and proper address is inserted
      in any instructions previously generated (in memory)
One pass assembler that produces object programs


 Use the same procedure
 When the definition of a symbol is encountered
    if instruction which made the forward reference is still in
     memory, then fix it
    if not, the instruction has already been written out in a
     Text record, so generate a new Text record with the
     correct operand address
    (could also use a modification record)
    The loader will fix up the address field
One pass assembler that produces object programs

 Problem : Forward Reference
    It be eliminated by declaring variable before using them
    However, elimination can’t be done easily because sometimes
     program needs a forward jump.

Más contenido relacionado

La actualidad más candente

Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Khaja Dileef
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programmingWondeson Emeye
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2satyabrataDash18
 
MASM -UNIT-III
MASM -UNIT-IIIMASM -UNIT-III
MASM -UNIT-IIIDr.YNM
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programmingMakerere university
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assemblyAbdul Khan
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Tish997
 
Assembly language progarmming
Assembly language progarmmingAssembly language progarmming
Assembly language progarmmingAzmeyer
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compileradilmehmood93
 
Computer Architecture and organization ppt.
Computer Architecture and organization ppt.Computer Architecture and organization ppt.
Computer Architecture and organization ppt.mali yogesh kumar
 
Part II: Assembly Fundamentals
Part II: Assembly FundamentalsPart II: Assembly Fundamentals
Part II: Assembly FundamentalsAhmed M. Abed
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marksvvcetit
 
Assembler design option
Assembler design optionAssembler design option
Assembler design optionMohd Arif
 

La actualidad más candente (20)

Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2Systemsoftwarenotes 100929171256-phpapp02 2
Systemsoftwarenotes 100929171256-phpapp02 2
 
Microprocessor chapter 9 - assembly language programming
Microprocessor  chapter 9 - assembly language programmingMicroprocessor  chapter 9 - assembly language programming
Microprocessor chapter 9 - assembly language programming
 
Two pass Assembler
Two pass AssemblerTwo pass Assembler
Two pass Assembler
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Assembler
AssemblerAssembler
Assembler
 
Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 
MASM -UNIT-III
MASM -UNIT-IIIMASM -UNIT-III
MASM -UNIT-III
 
Spr ch-02
Spr ch-02Spr ch-02
Spr ch-02
 
Examinable Question and answer system programming
Examinable Question and answer system programmingExaminable Question and answer system programming
Examinable Question and answer system programming
 
Lec 04 intro assembly
Lec 04 intro assemblyLec 04 intro assembly
Lec 04 intro assembly
 
Assembler
AssemblerAssembler
Assembler
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)
 
Assembly language progarmming
Assembly language progarmmingAssembly language progarmming
Assembly language progarmming
 
Design of a two pass assembler
Design of a two pass assemblerDesign of a two pass assembler
Design of a two pass assembler
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Computer Architecture and organization ppt.
Computer Architecture and organization ppt.Computer Architecture and organization ppt.
Computer Architecture and organization ppt.
 
Part II: Assembly Fundamentals
Part II: Assembly FundamentalsPart II: Assembly Fundamentals
Part II: Assembly Fundamentals
 
system software 16 marks
system software 16 markssystem software 16 marks
system software 16 marks
 
Assembler design option
Assembler design optionAssembler design option
Assembler design option
 

Destacado

Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution beginSeongJae Park
 
Use case diagrams
Use case diagramsUse case diagrams
Use case diagramsMir Majid
 
Lessons from life_2
Lessons from life_2Lessons from life_2
Lessons from life_2Mir Majid
 
Let the contribution begin (EST futures)
Let the contribution begin  (EST futures)Let the contribution begin  (EST futures)
Let the contribution begin (EST futures)SeongJae Park
 
Porting golang development environment developed with golang
Porting golang development environment developed with golangPorting golang development environment developed with golang
Porting golang development environment developed with golangSeongJae Park
 
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기   dev festx korea 2012 presentationAOSP에 컨트리뷰션 하기   dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentationSeongJae Park
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.aviSeongJae Park
 
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSDO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSSeongJae Park
 
Deep dark side of git - prologue
Deep dark side of git - prologueDeep dark side of git - prologue
Deep dark side of git - prologueSeongJae Park
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot publicSeongJae Park
 
gcma: guaranteed contiguous memory allocator
gcma:  guaranteed contiguous memory allocatorgcma:  guaranteed contiguous memory allocator
gcma: guaranteed contiguous memory allocatorSeongJae Park
 
An introduction to_golang.avi
An introduction to_golang.aviAn introduction to_golang.avi
An introduction to_golang.aviSeongJae Park
 
Class Outlier Mining
Class Outlier MiningClass Outlier Mining
Class Outlier MiningMotaz Saad
 

Destacado (20)

Let the contribution begin
Let the contribution beginLet the contribution begin
Let the contribution begin
 
Use case diagrams
Use case diagramsUse case diagrams
Use case diagrams
 
Patterns
PatternsPatterns
Patterns
 
Lessons from life_2
Lessons from life_2Lessons from life_2
Lessons from life_2
 
Nested micro
Nested microNested micro
Nested micro
 
Assembler
AssemblerAssembler
Assembler
 
Let the contribution begin (EST futures)
Let the contribution begin  (EST futures)Let the contribution begin  (EST futures)
Let the contribution begin (EST futures)
 
Linker
LinkerLinker
Linker
 
sCode optimization
sCode optimizationsCode optimization
sCode optimization
 
Porting golang development environment developed with golang
Porting golang development environment developed with golangPorting golang development environment developed with golang
Porting golang development environment developed with golang
 
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기   dev festx korea 2012 presentationAOSP에 컨트리뷰션 하기   dev festx korea 2012 presentation
AOSP에 컨트리뷰션 하기 dev festx korea 2012 presentation
 
ash
ashash
ash
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
 
Keyword Presentation
Keyword PresentationKeyword Presentation
Keyword Presentation
 
DO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCSDO YOU WANT TO USE A VCS
DO YOU WANT TO USE A VCS
 
Deep dark side of git - prologue
Deep dark side of git - prologueDeep dark side of git - prologue
Deep dark side of git - prologue
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot public
 
gcma: guaranteed contiguous memory allocator
gcma:  guaranteed contiguous memory allocatorgcma:  guaranteed contiguous memory allocator
gcma: guaranteed contiguous memory allocator
 
An introduction to_golang.avi
An introduction to_golang.aviAn introduction to_golang.avi
An introduction to_golang.avi
 
Class Outlier Mining
Class Outlier MiningClass Outlier Mining
Class Outlier Mining
 

Similar a Unit 3 assembler and processor

Similar a Unit 3 assembler and processor (20)

microprocessor
 microprocessor microprocessor
microprocessor
 
Assembly language programming(unit 4)
Assembly language programming(unit 4)Assembly language programming(unit 4)
Assembly language programming(unit 4)
 
Advanced micro -processor
Advanced micro -processorAdvanced micro -processor
Advanced micro -processor
 
N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)N_Asm Assembly registers (sol)
N_Asm Assembly registers (sol)
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Cao 2012
Cao 2012Cao 2012
Cao 2012
 
Amp
AmpAmp
Amp
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
intro to assembly language.pptx
intro to assembly language.pptxintro to assembly language.pptx
intro to assembly language.pptx
 
Intel 8086
Intel 8086 Intel 8086
Intel 8086
 
Module 1-ppt System programming
Module 1-ppt System programmingModule 1-ppt System programming
Module 1-ppt System programming
 
Registers
RegistersRegisters
Registers
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Micro 2
Micro 2Micro 2
Micro 2
 
Assembler Programming
Assembler ProgrammingAssembler Programming
Assembler Programming
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
 
8086 MICROPROCESSOR
8086 MICROPROCESSOR8086 MICROPROCESSOR
8086 MICROPROCESSOR
 
SS-assemblers 1.pptx
SS-assemblers 1.pptxSS-assemblers 1.pptx
SS-assemblers 1.pptx
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 

Más de Abha Damani (20)

Unit2
Unit2Unit2
Unit2
 
Unit6
Unit6Unit6
Unit6
 
Unit5
Unit5Unit5
Unit5
 
Unit4
Unit4Unit4
Unit4
 
Unit3
Unit3Unit3
Unit3
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Ch14
Ch14Ch14
Ch14
 
Ch12
Ch12Ch12
Ch12
 
Ch11
Ch11Ch11
Ch11
 
Ch10
Ch10Ch10
Ch10
 
Ch08
Ch08Ch08
Ch08
 
Ch01 enterprise
Ch01 enterpriseCh01 enterprise
Ch01 enterprise
 
3 data mgmt
3 data mgmt3 data mgmt
3 data mgmt
 
2 it supp_sys
2 it supp_sys2 it supp_sys
2 it supp_sys
 
1 org.perf it supp_appl
1 org.perf it supp_appl1 org.perf it supp_appl
1 org.perf it supp_appl
 
Managing and securing the enterprise
Managing and securing the enterpriseManaging and securing the enterprise
Managing and securing the enterprise
 
Ch6
Ch6Ch6
Ch6
 
Unit2
Unit2Unit2
Unit2
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 4
Unit 4Unit 4
Unit 4
 

Último

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 

Último (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 

Unit 3 assembler and processor

  • 1. Assembly Language Prakash Khaire UTU
  • 2. Assembly Language  A programming language that is one step away from machine language.  Each assembly language statement is translated into one machine instruction by the assembler.  Programmers must be well versed in the computer's architecture, and, undocumented assembly language programs are difficult to maintain.  It is hardware dependent; there is a different assembly language for each CPU series.
  • 3. Assembly Language  It was introduced in 1952  Helped to overcome machine language programming Definition : “A language that allows instructions and storage locations to be represented by letters and symbols instead of numbers is called assembly language or symbolic language”
  • 4. Assembly Language Model … add r1,r2 sub r2,r3 PC cmp r3,r4 ALU bne I1 Registers Memory sub r4,1 I1: jmp I3 …
  • 5. Assembly Language Instructions Built from two pieces Add R1, R3, 3 Opcode Operands What to do with Where to get the data data and put (ALU operation) the results
  • 6. Types of Opcodes Arithmetic, logical add, sub, mult and, or Cmp Memory load/store ld, st Control transfer jmp bne
  • 7. Operands Each operand taken from a particular addressing mode: Examples: Register add r1, r2, r3 Immediate add r1, r2, 10 Indirect mov r1, (r2) Offset mov r1, 10(r3) PC Relative beq 100 Reflect processor data pathways
  • 8. Advantages over Machine Language Easier to understand and use Easier to locate and correct errors. Easier to modify No worry about addresses Easily relocatable Efficiency of machine language
  • 9. Limitations of Assembly Language Machine Dependent Knowledge of hardware required Machine level coding
  • 11. Registers in 8086 CPU  There are four general purpose registers  AX [divided into AH/AL] – the accumulator register  BX [divided into BH/BL] – the base address register  CX [divided into CH/CL] – the count register  DX [divided into DH/DL] – the data register Other registers  SI – source index register  DI – destination index register  BP – Base pointer  SP – Stack pointer
  • 12. Registers in 8086 CPU  This registers are of 16 bits and divided into two 8 bit registers  For Example If AX = 0011000000111001b then AH = 00110000b and AL=001111001b  Registers are located in CPU,  Segment Registers  Used for special purpose pointing at accessible blocks of memory  It stores any data  Four segment registers during execution  CS – Points the segment storing the current program  DS – Points the segment where variable are defined  ES – Extra Segment register, depends on the usage of coder  SS – Points to the segment containing the stack  Along with general purpose registers, segment registers work to access any memory value.
  • 13. Flags  FLAG : The FLAG register is the status register in the Intel 8086 microprocessor that contains the current state of the microprocessor. This register is 16 bits wide.  carry flag (CF)- indicates a carry after addition or a borrow after subtraction, also indicates error conditions.  parity flag (PF)- is a logic “0” for odd parity and a logic “1” for even parity.  auxiliary carry flag (AF)- important for BCD addition and subtraction; holds a carry (borrow) after addition (subtraction) between bits position 3 and 4. Only used for DAA and DAS instructions to adjust the value of AL after a BCD addition (subtraction).  zero flag (ZF)- indicates that the result of an arithmetic or logic operation is zero.  sign flag (SF)- indicates arithmetic sign of the result after an arithmetic operation.  overflow flag (OF)- a condition that occurs when signed numbers are added or subtracted. An overflow indicates that the result has exceeded the capacity of the machine.
  • 14. Offset  The offset address in an 8086/8088 is the logical address that the program "thinks about" when it addresses a location in memory.  The Execution Unit (EU or CPU) is responsible for generating the offset address.  The Bus Interface Unit (BIU), on the other hand, takes the offset address and adds it to four times the selected segment register value in order to determine a real address, which is now 20-bits in length.
  • 15. Registers in 8086 CPU  Programmers access various memory locations on combining BX, SI, DI and BP registers.  The value in segment registers[CS, DS, SS,ES] is called “segment”  The value in purpose registers [BX, SI, DI, BP] is called “offset”  For Example  DS contains value 1234h and SI contains the value 7890h it can also be recorded as 1234:7890  Two special purpose registers  IP – Instruction Register  Flags Register – determines the current state of the processor
  • 16. Registers in 8086 CPU  IP works along with CS register and points to the currently executing instruction  Flags register is modified by CPU, while performing mathematical operations
  • 17. Assembler Design Approach Assembler generates object code. Role of assembler – Translates the source code into target code During this translation process it uses various table like Machine Opcode Table Symbol table Literal table
  • 18. Assembler Design Approach Machine Opcode Table  It holds opcode used by the processor for different instructions mnemonics Mnemonic size Opcode Holds various instructions Size of instructions in bytes Size of instructions in bytes
  • 19. Symbol Table  It is data structure used by assmebler  It keeps into account attributes of the identifier and other information.  Attributes : type, value, scope and address  It also performs the function of book keeping.  It is composed of multiple word entries in fixed format Name Value Type
  • 20. One Pass Assembler Does everything in one pass Problem: How do we handle forward references? Could eliminate forward references easy for data – just define the data areas before they are referenced not easy in code – how do we handle selection or loop statements which have forward jumps? Two types of one pass assemblers: produce object code directly in memory produce object program for later execution
  • 21. One Pass Assembler  Assembler generates object code instructions as it scans source program  If an operand symbol has not yet been defined  operand address is set to 0 in instruction  symbol is entered into the symbol table (unless it is already present)  entry is flagged to indicate the symbol is undefined  address of instruction is added to list of forward references associated with this symbol  When symbol definition is encountered  forward reference list is scanned, and proper address is inserted in any instructions previously generated (in memory)
  • 22. One pass assembler that produces object programs  Use the same procedure  When the definition of a symbol is encountered  if instruction which made the forward reference is still in memory, then fix it  if not, the instruction has already been written out in a Text record, so generate a new Text record with the correct operand address  (could also use a modification record)  The loader will fix up the address field
  • 23. One pass assembler that produces object programs  Problem : Forward Reference  It be eliminated by declaring variable before using them  However, elimination can’t be done easily because sometimes program needs a forward jump.

Notas del editor

  1. Forward References : When one pass assembler constructing the object code, if it finds usage of the variables before the declaration then forward reference problem will occur. To avoid forward reference problem: i) Declare the symbols before using it ii) Use more than one pass assembler(multi pass assembler)