1 / 13

COP 3402

COP 3402. Lab 8. A Simple SIC Assembler. Functions to translate source program to object code: Convert mnemonic operation codes to machine language equivalents. Example: STL to 14 Convert symbolic operands to their equivalent machine addresses. Example: RETADR to 1033

Download Presentation

COP 3402

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COP 3402 Lab 8

  2. A Simple SIC Assembler • Functions to translate source program to object code: • Convert mnemonic operation codes to machine language equivalents. Example: STL to 14 • Convert symbolic operands to their equivalent machine addresses. Example: RETADR to 1033 • Build the machine instructions in the proper format • Convert the data constants specified in the source program into their internal machine representations. Example: EOF to 454F46 • Write the object program and the assembly listing.

  3. A Simple SIC Assembler cont. • Each of the functions except the second function can be taken care of by sequential processing of the program one line at a time. • Translating addresses can present a problem.

  4. A Simple SIC Assembler cont. • Example: • 1000 FIRST STL RETADR 141033 Problem:forward reference, label is defined later in the program. Solution: Allow assembler to perform two passes over the source program. • First pass scans the source program for label definitions and assign address • Second pass performs actual translation

  5. A Simple SIC Assembler cont. • Assembler processes assembler directives, which are instructions for the assembler itself. Example: START, specifies the starting memory address for the object program

  6. Object Program Format • Contains: • Header: program name, starting address, length • Text: translated instructions, data of the program, and address where these are to be loaded • End: marks the end of the program and specifies the address in the program where execution begins

  7. Object Program Format • Header Record: Col. 1: H Col. 2-7: Program name Col. 8-13: Starting address of the object program in hexadecimal Col. 14-19: Length of the object program in bytes

  8. Object Program Format • Text Record: Col. 1: T Col. 2-7: Starting address for object code in this record Col. 8-9: Length of object code in this record in bytes Col. 10-69: Object code in hexadecimal

  9. Object Program Format • End Record: Col. 1: E Col. 2-7: Address of first executable instruction in object program

  10. Pass 1: Define symbols • Assign addresses to all statements in the program • Save the values (addresses) assigned to all labels for use in pass 2 • Perform some processing of assembler directives.

  11. Pass 2: assemble instructions and generate object program • Assemble instructions (translate operation codes and lookup addresses) • Generate data valoues defined by BYTE, WORD, etc • Perform processing of assembler directives not done during Pass 1. • Write the object program and assembly listing

  12. Algorithm and Data Structures • Operation Code Table (OPTAB): used to look up mnemonic operation codes and translate them to their machine language equivalent • Symbol Table (SYMTAB): store values (addresses) assigned to labels. • Location counter (LOCCTR): helps in assignment of addresses. Initialized with addressed specified in START statement.

  13. Algorithm and Data Structures cont. • During pass 1, OPTAB is used to look up and validate operation codes in the source program. • During pass 2, OPTAB is used to translate the operation codes to machine language. • During pass 1, labels are entered into SYMTAB as they are encountered together with their assigned addresses. • During pass 2, symbols used as operands are looked up SYMTAB to obtain addresses to be inserted in the assembled instructions.

More Related