Instruction set



Yüklə 454 b.
tarix08.10.2017
ölçüsü454 b.
#3558







Instruction set

  • Instruction set

  • of SIC











TEST START 1003

  • TEST START 1003

  • FIRST LDA FIVE

  • STA ALPHA

  • ALPHA RESW 1 /*symbolic variable*/

  • FIVE WORD 5 /*symbolic constant, Literal */

  • END FIRST



TEST START 1003

  • TEST START 1003

  • FIRST LDA FIVE 001012

  • STA ALPHA 0C1009

  • ALPHA RESW 1 ******

  • FIVE WORD 5 000005

  • END FIRST



LDA ALPHA

  • LDA ALPHA

  • ADD INCR

  • SUB ONE

  • STA BETA

  • ONE WORD 1

  • ALPHA RESW 1

  • BETA RESW 1

  • INCR RESW 1





TEST START 1003

  • TEST START 1003

  • FIRST LDA FIVE 001012

  • STA ALPHA 0C1009

  • ALPHA RESW 1 ******

  • FIVE WORD 5 000005

  • END FIRST



Data structures

  • Data structures



Operation Code Table (OPTAB)

  • Operation Code Table (OPTAB)

    • Used to look up mnemonic operation codes and translate them into machine language equivalents
    • Contains the mnemonic operation code and its machine language equivalent
    • In more complex assemblers, contains information like instruction format and length


Symbol Table

  • Symbol Table

    • Used to store values (addresses) assigned to labels
    • Includes the name and value for each label
    • Flags to indicate error conditions, e.g. duplicate definition of labels
    • May contain other info like type or length about the data area or instruction labeled


LOCCTR

  • LOCCTR

    • Used to help in the assignment of addresses
    • Initialized to the beginning address specified in the START statement
    • After each source statement is processed, the length of the assembled instruction or data area to be generated is added
    • Gives the address of a label


Two pass algorithm

  • Two pass algorithm

  • Pass 1 (Define symbols):

  • (a)Assign addresses to all statements (LOC)

  • (b) Save the addresses assigned to all labels in symbol table

  • (c) Perform some processing for assembler directives



Two pass algorithm

  • Two pass algorithm

  • Pass 2 (Generate object code):

  • Translate opcode and operands

  • Generate data values for WORD

  • Write object program



TEST START 1003

  • TEST START 1003

  • FIRST LDA FIVE 001012

  • STA ALPHA 0C1009

  • ALPHA RESW 1 ******

  • FIVE WORD 5 000005

  • END FIRST









H | COPY | 001000 | 00107A

  • H | COPY | 001000 | 00107A

  • T | 001000 | 1E | 141033 | 482039 | 001036 | …

  • T | 00101E | 15 | 0C1036 | 482061 | 081033 | …

  • T | 002073 | 07 | 382064 | 4C0000 | 05

  • E | 001000





begin

  • begin

  • read first input line

  • if OPCODE = 'START' then

  • begin

  • save #[OPERAND] as starting address

  • initialized LOCCTR to starting address

  • write line to intermediate file

  • read next input line

  • end {if START}

  • else

  • initialized LOCCTR to 0



while OPCODE != 'END' do

  • while OPCODE != 'END' do

  • begin

  • if this is not a comment line then

  • begin

  • if there is a symbol in the LABEL field then

  • begin

  • search SYMTAB for LABEL

  • if found then

  • set error flag (duplicate symbol)

  • else

  • insert (LABEL, LOCCTR) into SYMTAB

  • end {if symbol}

  • search OPTAB for OPCODE

  • if found then

  • add 3 {instruction lengh} to LOCCTR

  • else if OPCODE = 'WORD' then

  • add 3 to LOCCTR

  • else if OPCODE = 'RESW' then

  • add 3 * #[OPERAND] to LOCCTR

  • else if OPCODE = 'RESB' then

  • add #[OPERAND] to LOCCTR

  • else if OPCODE = 'BYTE' then

  • begin

  • find length of constant in bytes

  • add length to LOCCTR

  • end {if BYTE}

  • else

  • set error flag (invalid operation code)

  • end {if not a comment}

  • write line to intermediate file

  • read next input line

  • end {while not END}

  • write last line to intermediate file

  • save (LOCCTR - starting address) as program length

  • end



begin

  • begin

  • read first input file {from intermediate file}

  • if OPCODE = 'START' then

  • begin

  • write listing line

  • read next input line

  • end {if START}

  • write header record to object program

  • initialized first Text record



while OPCODE != 'END' do

  • while OPCODE != 'END' do

  • begin

  • if this is not a comment line then

  • begin

  • search OPTAB for OPCODE

  • if found then

  • begin

  • if there is a symbol in OPERAND field then

  • begin

  • search SYMTAB for OPERAND

  • if found then

  • store symbol value as operand address

  • else

  • begin

  • store 0 as operand address

  • set error flag (undefined symbol)

  • end

  • end {if symbol}

  • else

  • store 0 as operand address

  • assemble the object code instruction

  • end {if opcode found}

  • else if OPCODE = 'BYTE' or 'WORD' then

  • convert constant to object code

  • if object code not fit into the current Text record then

  • begin

  • write Text record to object program

  • initialized new Text record

  • end

  • add object code to Text record

  • end {if not comment}

  • write listing line

  • read next input line

  • end {while not END}



write last Text record to object program



H | COPY | 001000 | 00107A

  • H | COPY | 001000 | 00107A

  • T | 001000 | 1E | 141033 | 482039 | 001036 | …

  • T | 00101E | 15 | 0C1036 | 482061 | 081033 | …

  • T | 002073 | 07 | 382064 | 4C0000 | 05

  • E | 001000



Yüklə 454 b.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə