Assembler

A short Overview




1
Content

   Language Levels
     High Level  micro code
     Machinecode language

   Assembler languages
     Structure
     Commands




2
Language Levels
    High Level Language




    Assembler Language




    Machine Language      Normally deepest free
                          accessible Level


           Micro             „Firmware“
       -programming


        Hardware
3
High Level  Micro Code
   High Level language
       Formulating program for certain application
        areas
       Hardware independent

   Assembler languages
       Machine oriented language
       Programs orient on special hardware
        properties
       More comfortable than machine code
        (e.g. by using symbolic notations)
4
High Level  Micro Code

   Machine code:

     Set of commands directly executable
      via CPU
     Commands in numeric code
     Lowest semantic level
     Generally 2 executing oportunities:
        • Interpretiv via micro code
        • Directly processing via hardware
5
High Level  Micro Code
   Micro programming:
     Implementing of executing of machine
      commands (Control unit - controller)
     Machine command executed/shown
      as sequence of micro code
      commands
     Micro code commands:
        • Simpliest process controlling
           • Moving of data
           • Opening of grids
6
           • Tests
Machinecode language

   Machinecode command:
       Binary word (fix length, causes
        elementary operations within CPU)

   Machinecode program
       sequence of machinecode commands



7
Machinecode language

   Structure:           OpCode    OpAddress

       Operationcode
         • Defining executable operation
       Operandaddress
         • Spezification of operands
            • Constants/register addresses/storage
              addresses
       Difference between 1/2/3 address
        machines
8
Machinecode language

 Data transport commands
 Arithmetic and logical commands

 Process controlling commands

 In-/output commands

 Special commands

 Disadvantage:
       Difficultly readable
       No symbolic names(Mnemomics)
9
Assembler languages

    Translated into machinecode
     language(Interpreter)
    Each operation code(opcode) owns one
     symbolic command
    Assignments of operand addresses are
     possible
    Labels for command addresses


10
Assembler languages
    Usage of pseudo commands
        Commands for assembler
        Assigment of values/addresses(variables)
        Definition of the programstart addresses
        Allocating of memory for variables




11
Assembler languages-structure
<Label> <Mnemomic> <Operand> Comments
     Label
             symbolic labeling of an assembler address
              (command address at Machine level)
     Mnemomic
             Symbolic description of an operation
     Operands
             Contains of variables or addresse if necessary
     Comments

     12
Assembler Languages
    - Machine Instructions
   Bitpatterns are created, executed as
    commands by CPU
   Classes:
        Arithmetic/logical Operations(ADD,SUB,XOR,
         administrative commands - EQU,
         shifting&rotation commands)
        Data transfer(load/save operations,
         speicher<>register, register<>register)
        Control commands(jump op. [un-]conditional
         /relativ,control op. – STOP)
        In-/output commands
    13
Assembler – Assembler Instructiuons
(Pseudo Commands)

    Instructions to assembler
        Controlling translation process
        No creation of machine code
        Affect creation of machine instructions
    Types:
        Program organisation
        equations and symbolic Addresses
        Definition of Constants and Memory
        Addressing
14
Assembler – All purpose Register

   Arithmetic example:
        Source and Destination Data width has to
         euqal
        AX , BX, CX, DX, SI, DI, BP, SP
    ; arithmetic operations
                                                All purpose
    ADD AX, BX           ; AX := AX+BX          Register
    SUB AH,AL            ; AH := AH - AL
    MOV AL, CL           ; AL := CL        AX   AH   AL
    INC CX               ; CX := CX+1
    DEC CL               ; CL := CL-1      BX   BH   BL
    NEG CX               ; CX := -CX
                                           CX CH     CL

    15
Assembler – Special Register



    Unless to all-purpose registers
        Special register(SS, DS, CS, ES, IP)
          • Never ever are
             • Destination/Source of a „mov“ command
             • Destination of arithmetic operations




16
Assembler – Flag Register

     O   D   I      T   S     Z       A      P          C




                               Zero
                            Sign                            Carry
                     Trap                     Parity
                 Interrupt enable     Auxiliary carry
         Direction

     Overflow
17
Assembler – Flag Register
   FLAG-Bits:
        C Carry            Area crossing of unsigned numbers
        A Aux. Carry       Area crossing at BCD-design
        O Overflow         Area crossing at arithmetic
                            operation with signed numbers
        S Sign             True if result = negativ
        Z Zero             Result = Null
        P Parity           Result has an even number of 1 Bits
        D Direction flag   Defines direction of string-
                            commands
        I Interrupt        Global Interrupt Enable/Disable Flag
        T Trap Flag        Used by debugger, allows single-step-
                            modus




    18
Assembler – Flag Register
    Missing flags:
        • V: Two’s complement overflow indicator
        • H: Half Carry Flag

    Operations and flags
     ADD, SUB, NEG    affects     O, S, Z, A, P, C
     INC, DEC          -“-        O, S, Z, A, P
     MUL, DIV          -“-        O, C
     AND, OR , XOR     -“-        S, Z, P, C



19
Assembler – Jump Operations


 Un-/conditioned        jumps
      Example:
            Mov AX, 0
            CMP CX, 0
     again: JZ end       (jumpzero, conditioned j.)
            ADD AX, CX
            DEC CX
            JMP again    (unconditioned jumped)
     end: NOP


20
Sources
http://www.informatik.ku-eichstaett.de
   /studium/skripte/ws0203/einf2/Vorlesung12.ppt

http://www-ist.massey.ac.nz
/GMoretti/159704/Lectures/1-Languages-Translation-&-Assemblers.pdf

http://www.mathematik.uni-marburg.de
/~priebe/lehre/ws0001/ti1/Skript/TechInf1Lo08.ppt

E:temp4.SemesterIntro into Dig.ComputingDokuBefehlssatz.pdf




        21
Thanks 4 ur Attention




          Any further
           questions
              ??


22

Assembler

  • 1.
  • 2.
    Content  Language Levels  High Level  micro code  Machinecode language  Assembler languages  Structure  Commands 2
  • 3.
    Language Levels High Level Language Assembler Language Machine Language Normally deepest free accessible Level Micro „Firmware“ -programming Hardware 3
  • 4.
    High Level Micro Code  High Level language  Formulating program for certain application areas  Hardware independent  Assembler languages  Machine oriented language  Programs orient on special hardware properties  More comfortable than machine code (e.g. by using symbolic notations) 4
  • 5.
    High Level Micro Code  Machine code:  Set of commands directly executable via CPU  Commands in numeric code  Lowest semantic level  Generally 2 executing oportunities: • Interpretiv via micro code • Directly processing via hardware 5
  • 6.
    High Level Micro Code  Micro programming:  Implementing of executing of machine commands (Control unit - controller)  Machine command executed/shown as sequence of micro code commands  Micro code commands: • Simpliest process controlling • Moving of data • Opening of grids 6 • Tests
  • 7.
    Machinecode language  Machinecode command:  Binary word (fix length, causes elementary operations within CPU)  Machinecode program  sequence of machinecode commands 7
  • 8.
    Machinecode language  Structure: OpCode OpAddress  Operationcode • Defining executable operation  Operandaddress • Spezification of operands • Constants/register addresses/storage addresses  Difference between 1/2/3 address machines 8
  • 9.
    Machinecode language  Datatransport commands  Arithmetic and logical commands  Process controlling commands  In-/output commands  Special commands  Disadvantage:  Difficultly readable  No symbolic names(Mnemomics) 9
  • 10.
    Assembler languages  Translated into machinecode language(Interpreter)  Each operation code(opcode) owns one symbolic command  Assignments of operand addresses are possible  Labels for command addresses 10
  • 11.
    Assembler languages  Usage of pseudo commands  Commands for assembler  Assigment of values/addresses(variables)  Definition of the programstart addresses  Allocating of memory for variables 11
  • 12.
    Assembler languages-structure <Label> <Mnemomic><Operand> Comments  Label  symbolic labeling of an assembler address (command address at Machine level)  Mnemomic  Symbolic description of an operation  Operands  Contains of variables or addresse if necessary  Comments 12
  • 13.
    Assembler Languages - Machine Instructions  Bitpatterns are created, executed as commands by CPU  Classes:  Arithmetic/logical Operations(ADD,SUB,XOR, administrative commands - EQU, shifting&rotation commands)  Data transfer(load/save operations, speicher<>register, register<>register)  Control commands(jump op. [un-]conditional /relativ,control op. – STOP)  In-/output commands 13
  • 14.
    Assembler – AssemblerInstructiuons (Pseudo Commands)  Instructions to assembler  Controlling translation process  No creation of machine code  Affect creation of machine instructions  Types:  Program organisation  equations and symbolic Addresses  Definition of Constants and Memory  Addressing 14
  • 15.
    Assembler – Allpurpose Register  Arithmetic example:  Source and Destination Data width has to euqal  AX , BX, CX, DX, SI, DI, BP, SP ; arithmetic operations All purpose ADD AX, BX ; AX := AX+BX Register SUB AH,AL ; AH := AH - AL MOV AL, CL ; AL := CL AX AH AL INC CX ; CX := CX+1 DEC CL ; CL := CL-1 BX BH BL NEG CX ; CX := -CX CX CH CL 15
  • 16.
    Assembler – SpecialRegister  Unless to all-purpose registers  Special register(SS, DS, CS, ES, IP) • Never ever are • Destination/Source of a „mov“ command • Destination of arithmetic operations 16
  • 17.
    Assembler – FlagRegister O D I T S Z A P C Zero Sign Carry Trap Parity Interrupt enable Auxiliary carry Direction Overflow 17
  • 18.
    Assembler – FlagRegister  FLAG-Bits:  C Carry Area crossing of unsigned numbers  A Aux. Carry Area crossing at BCD-design  O Overflow Area crossing at arithmetic operation with signed numbers  S Sign True if result = negativ  Z Zero Result = Null  P Parity Result has an even number of 1 Bits  D Direction flag Defines direction of string- commands  I Interrupt Global Interrupt Enable/Disable Flag  T Trap Flag Used by debugger, allows single-step- modus 18
  • 19.
    Assembler – FlagRegister  Missing flags: • V: Two’s complement overflow indicator • H: Half Carry Flag  Operations and flags ADD, SUB, NEG affects O, S, Z, A, P, C INC, DEC -“- O, S, Z, A, P MUL, DIV -“- O, C AND, OR , XOR -“- S, Z, P, C 19
  • 20.
    Assembler – JumpOperations  Un-/conditioned jumps  Example: Mov AX, 0 CMP CX, 0 again: JZ end (jumpzero, conditioned j.) ADD AX, CX DEC CX JMP again (unconditioned jumped) end: NOP 20
  • 21.
    Sources http://www.informatik.ku-eichstaett.de /studium/skripte/ws0203/einf2/Vorlesung12.ppt http://www-ist.massey.ac.nz /GMoretti/159704/Lectures/1-Languages-Translation-&-Assemblers.pdf http://www.mathematik.uni-marburg.de /~priebe/lehre/ws0001/ti1/Skript/TechInf1Lo08.ppt E:temp4.SemesterIntro into Dig.ComputingDokuBefehlssatz.pdf 21
  • 22.
    Thanks 4 urAttention Any further questions ?? 22