assembler shqip

Upload: edber-demiri

Post on 25-Feb-2018

255 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Assembler shqip

    1/31

    Assembler design

  • 7/25/2019 Assembler shqip

    2/31

    Hypothetical machineProcessor architecture

    Main

    memory

    Simplified

    Instructional

    Computer(SIC)Size=6!"

    Memory Address=# "ytes

  • 7/25/2019 Assembler shqip

    3/31

    $ord lengthAccumulator%&egisters '%

    Main Memory

    *

    6

    +

    ,#

    * "ytes"yte "yte "yte

    "yte "yte "yte

    Address-

    # bytes

  • 7/25/2019 Assembler shqip

    4/31

    Instruction set

    of SIC

  • 7/25/2019 Assembler shqip

    5/31

  • 7/25/2019 Assembler shqip

    6/31

  • 7/25/2019 Assembler shqip

    7/31

  • 7/25/2019 Assembler shqip

    8/31

    Instruction format

    .p code (, byte) Address (# bytes)

  • 7/25/2019 Assembler shqip

    9/31

    Sample code (data mo/ement)

    01S0 S0A&0 ,*

    2I&S0 3A 2I41

    S0A AP5AAP5A &1S$ , 7symbolic /ariable7

    2I41 $.&3 8 7symbolic constant% iteral 7

    193 2I&S0

    LABEL Instruction Operand

    Assembly language program

    Psuedo Opcode ORAssembler Directives

    S0A&0

    &1S$

    $.&3%

    193

  • 7/25/2019 Assembler shqip

    10/31

    01S0 S0A&0 ,*

    2I&S0 3A 2I41 ,,#

    S0A AP5A C,+

    AP5A &1S$ , 777777

    2I41 $.&3 8 8

    193 2I&S0

    ,*

    ,6,+

    ,,#

    ,,8

    Sample code (data mo/ement)oc LABEL Instruction Operand Object code

    Assembly language program

  • 7/25/2019 Assembler shqip

    11/31

    Sample code (Arithmetic

    operation)3A AP5A

    A33 I9C&

    S:" .91

    S0A "10A

    .91 $.&3 ,

    AP5A &1S$ ,"10A &1S$ ,

    I9C& &1S$ ,

  • 7/25/2019 Assembler shqip

    12/31

    Assembler

    AssemblerAssembly language

    code

    .b;ect code

  • 7/25/2019 Assembler shqip

    13/31

    01S0 S0A&0 ,*

    2I&S0 3A 2I41 ,,#

    S0A AP5A C,+AP5A &1S$ , 777777

    2I41 $.&3 8 8

    193 2I&S0

    ,*

    ,*

    ,6,+

    ,,#

    ,,*

    Sample code (data mo/ement)oc LABEL Instruction Operand Object code

    Assembly language program

  • 7/25/2019 Assembler shqip

    14/31

    5o< to design an Assembler

    3ata structures

    Instruction

    Op code Lengthbytes!

    A33 m , *

    3A m *

    "! OP#AB

    LABEL Address LO$value!

    2I&S0 ,*

    AP5A ,+

    2I41 ,,#

    %! &ymbol #able

    '! Location counter LO$!

    I i O d L h

  • 7/25/2019 Assembler shqip

    15/31

    3ata Structures

    > .peration Code 0able (.P0A")

    ?:sed to loo@ up mnemonic operation codes and

    translate them into machine languageeui/alents

    ?Contains the mnemonic operation code and its

    machine language eui/alent

    ?In more compleB assemblers% contains

    information li@e instruction format and length

    Instruction

    Op code Lengthbytes!

    A33 m , *

    3A m *

  • 7/25/2019 Assembler shqip

    16/31

    3ata Structures

    > Symbol 0able

    ?:sed to store /alues (addresses) assigned to

    labels?Includes the name and /alue for each label

    ?2lags to indicate error conditions% eg duplicate

    definition of labels?May contain other info li@e type or length about

    the data area or instruction labeled

    LABEL Address LO$value!

    2I&S0 ,*

    AP5A ,+

    2I41 ,,#

  • 7/25/2019 Assembler shqip

    17/31

    3ata Structures

    > .CC0&

    ?:sed to help in the assignment of addresses

    ?Initialized to the beginning address specified in

    the S0A&0 statement

    ?After each source statement is processed% the

    length of the assembled instruction or data areato be generated is added

    ?Di/es the address of a label

  • 7/25/2019 Assembler shqip

    18/31

    0

  • 7/25/2019 Assembler shqip

    19/31

    0

  • 7/25/2019 Assembler shqip

    20/31

    01S0 S0A&0 ,*

    2I&S0 3A 2I41 ,,#

    S0A AP5A C,+AP5A &1S$ , 777777

    2I41 $.&3 8 8

    193 2I&S0

    ,*

    ,*

    ,6,+

    ,,#

    ,,*

    Sample code (data mo/ement)oc LABEL Instruction Operand Object code

    Assembly language program

  • 7/25/2019 Assembler shqip

    21/31

  • 7/25/2019 Assembler shqip

    22/31

  • 7/25/2019 Assembler shqip

    23/31

  • 7/25/2019 Assembler shqip

    24/31

    5 E C.PF E , E ,GA

    0 E , E ,1 E ,,** E #*+ E ,*6 E H

    0 E ,,1 E ,8 E C,*6 E #6, E ,** E H

    H

    0 E #G* E G E *#6 E C E 8

    1 E ,

    5eader record-

    Col , 5

    Col #G Program name

    Col ,* Starting address of ob;ect program (heBadecimal)

    Col ,,+ ength of ob;ect program in bytes (heBadecimal)

    0eBt record-Col , 0

    Col #G Starting address for ob;ect code in this record (heBadecimal)

    Col + ength of ob;ect code in this record in bytes (heBadecimal)

    Col , ? 6+ .b;ect code% represented in heBadecimal (6+,J,)6=, instructions

    1nd record-

    Col , 1

    Col #G Address of first eBecutable instruction in ob;ect program (heBadecimal)

  • 7/25/2019 Assembler shqip

    25/31

  • 7/25/2019 Assembler shqip

    26/31

    begin

    read first input line

    if .PC.31 = KS0A&0K then

    begin

    sa/e L.P1&A93N as starting address

    initialized .CC0& to starting address

  • 7/25/2019 Assembler shqip

    27/31

  • 7/25/2019 Assembler shqip

    28/31

    begin

    read first input file Ofrom intermediate file

    if .PC.31 = KS0A&0K then

    begin

  • 7/25/2019 Assembler shqip

    29/31

  • 7/25/2019 Assembler shqip

    30/31

  • 7/25/2019 Assembler shqip

    31/31

    5 E C.PF E , E ,GA

    0 E , E ,1 E ,,** E #*+ E ,*6 E H

    0 E ,,1 E ,8 E C,*6 E #6, E ,** E H

    H

    0 E #G* E G E *#6 E C E 8

    1 E ,

    5eader record-

    Col , 5

    Col #G Program name

    Col ,* Starting address of ob;ect program (heBadecimal)

    Col ,,+ ength of ob;ect program in bytes (heBadecimal)

    0eBt record-Col , 0

    Col #G Starting address for ob;ect code in this record (heBadecimal)

    Col + ength of ob;ect code in this record in bytes (heBadecimal)

    Col , ? 6+ .b;ect code% represented in heBadecimal (6+,J,)6=, instructions

    1nd record-

    Col , 1

    Col #G Address of first eBecutable instruction in ob;ect program (heBadecimal)