Sunteți pe pagina 1din 7

Alexandria University Faculty of Engineering Computer and Systems Engineering Department Systems Programming

Term Project Report

SIC/XE Assembler Phase (1)

Amr Mohamed Nabil Aly Sharaf (40) Mohammad Ibrahim Ahmad Ali Kotb (43) Moustafa Mahmoud Aly Meshry (57) Mohamed Salah Abd Alatty (71)
Under supervision of: Prof. Dr. Ahmed El-Nahas Dr. Nagia Ghanem Eng. Bassem Victor

1. Problem Statement
It is required to implement Pass 1 of the SIC/XE assembler. The output of this phase should be used as an input for the next phase. It is required to support the following specification in the assembler: It is required to build a parser that is capable of handling source lines that are instructions, storage declaratives, comments, and assembler directives (a directive that is not implemented should be ignored possibly with a warning) For instructions, the parser is to minimally be capable of decoding 2, 3 and 4-byte instructions as follows: 2-byte with 1 or 2 symbolic register reference (e.g., TIXR A, ADDR S,A). RSUB (ignoring any operand or perhaps issuing a warning). 3-byte PC-relative with symbolic operand to include immediate, indirect, and indexed addressing. 4-byte absolute with symbolic or non-symbolic operand to include immediate, indirect, and indexed addressing. The parser is to handle all storage directives (BYTE, WORD, RESW, and RESB). The output of this phase should contain: The symbol table. The source program in a format similar to the listing file described in the text book except that the object code is not generated.

2. Object Diagrams:

3. Classes:
Source_program Contents The program to be translated. Includes the current location counter value. And includes one object of class Source_line for each line of the program. Methods Assemble Translate the source program, producing and object program and an assembly listing update_locctr Assign a location counter value to the line; return an updated location counter value to the invoker. Enter the label on the line (if any) into the symbol table Source_line Contents A line of the source program. Indicates errors detected for the line. Methods Create Create and initialize a new instance of Source_line Translate Translate the instruction or data definition on the line into machine language. Make entries in the object program and assembly listing

Record_error Record an error detected for the line Record_warning Record a warning detected for the line Symbol_table Contents Labels defined in the source program, with the location counter value assigned to each, containing hash table to store these data. Methods Enter Enter a label and location counter value into the table. Return an error indication if the label is already defined Search Search the table for a specified label. Return the location counter value associated with the label, or an error indication if the label is not defined SymbolRecord Contents Data handler used in the Symbol_table hash table. Methods Constructor Used to create a new Symbol_record with specified data

Operation_table Contents Mnemonic instructions to be recognized by the assembler. Includes the machine instruction format and opcode to be used in assembling each instruction, and a description of requirements for operands. Methods Search Search the table for a specified mnemonic instruction. Return information about the instruction format and operands required, or an error indication if the mnemonic instruction is not defined

OperationRecord Contents Data handler used in the Operation_table hash table. Methods Constructor Used to create a new Operation_record with specified data

4. Algorithm
Pass1(): //handling first line alone to handle START //directive that should only appear as the first //instruction or don't appear at all line get_line() while(line is a comment line): line read next line line to_lower_case() src_line create() if(error in src_line): set_error_flag(true) record_error(error_msg) locctr 0 else: if(opcode == 'START'): //locctr #operand if(has operand): locctr read operand in hexa decimal else: set_error_flag(true) record_error() else: locctr 0 process this src_line normally as in the while loop while(there is a line): line get_line() line to_lower_case() src_line create() if(error in src_line): set_error_flag(true) record_error(error_msg) sym_record NIL

if(src_line has a label): sym_reocrd new symbol_record(label,locctr) write to intermediate file update_locctr(src_line, sym_record) push src_line into the queue if(src_line has a label): insert label in the symtab if(src_line.opcode = 'end'): if(has_next): warning end of program before end of file record_warning() break END

5. Additional Features:
Handle input free format code.

S-ar putea să vă placă și