1 / 15

COP 3402 Systems Programming

COP 3402 Systems Programming. Dr. Ali Orooji School of EECS University of Central Florida. Section 2.3.2. Symbol-Defining Statements symbol EQU value assembler puts the symbol and value in symbol table 1000 L1 EQU 500 L2

booth
Download Presentation

COP 3402 Systems Programming

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 Systems Programming Dr. Ali Orooji School of EECSUniversity of Central Florida

  2. Section 2.3.2 • Symbol-Defining Statements • symbol EQU value • assembler puts the symbol and value in symbol table • 1000L1 EQU 500 • L2 • * • L2-L3

  3. Section 2.3.3 • Expressions • assemblers generally allow +, -, *, / • Absolute expression • either only absolute terms • or if relative terms, they occur in pairs with • opposite signs • relative terms may not enter into a multiplication or division • operation • Relative expression • relative terms occur in pairs as above; one extra • relative term (positive sign)

  4. Block 1 Block 1 Block 2 Block 2 Section 2.3.4 • Program Blocks • segments of code that are logically rearranged within a single object program unit

  5. Pass 1 • - a separate location counter for each block • - when storing a label in symbol table, store the • block number as well • At the end of pass 1, the length of each block is known; • the assembler can now assign a starting address to each • block Pass 2 the value for a label is the value in the symbol table plus the starting address for the block

  6. 0000 . . . Block 1 Block 1 0300 . . . 0150 . . . Block 2 Block 2 0450 . . . • Note that the assembler does not physically rearrange the generated code in the object program (the assembler puts the load address with object code; loader will load accordingly)

  7. Section 2.3.5 Control Sections - segments that are translated into independent object program units CSECT 1 CSECT 2 - need to link together different control sections . assembler cannot do the linking . assembler provides information for each external reference that will allow the loader to perform the required linking - need extended format (type 4) for instructions containing external references

  8. 15 0003 CLOOP +JSUB RDREC 4B 1 00000 ni=11 e = 1 bp=00 no relative addressing 160 0017 +STCH BUFFER,X 57 9 00000 ni=11 x = 1 e= 1 bp=01 190 0028 MAXLEN WORD BUFEND-BUFFER 000000

  9. main routine ------------------ shared tables and routines root segment Pass 1 tables and routines Pass1 segment Pass 2 tables and routines Pass2 segment ... ... ... ... ... Two-Pass Assembler with Overlay Structure main segment : 20K Pass 1 segment : 50K Pass 2 segment : 60K

  10. Section 2.4.1 One-Pass Assemblers Why did we need two passes? forward references - data items - labels Load-and-go one-pass assemblers generate object code in memory for immediate execution (no object program is written out, and no loader is needed)

  11. symtbl name value ref ptr RDREC 1000 101D . . . 1000 J RDREC . . 101D J RDREC . . 2000 RDREC ...

  12. If the one-pass assembler generates object program • on secondary storage, i.e., not load-and-go assembler • - put zero when address not known (and remember the references using symtbl as before) • - when address is known, generate records to fill references • 1000 J RDREC 1000 J 0000 • . • . • 101D J RDREC 101D J 0000 • . • . • 2000 RDREC • 1000 2000 • 101D 2000

  13. Section 2.4.2 • Multi-Pass Assemblers • in the two-pass assembler • symbol defining directives • MAXLEN EQU BUFEND-BUFFER • symbols on the right hand side must be • defined previously • A EQU B • B EQU C • C EQU

  14. symtbl # of undef sym name value expression ref ptr HALFSZ MAXLEN HALFSZ HALFSZ EQU MAXLEN/2

  15. MAXLEN EQU BUFEND-BUFFER symtbl # of undef sym ref ptr name value expression HALFSZ 1 MAXLEN / 2 MAXLEN 2 BUFEND-BUFFER HALFSZ BUFEND MAXLEN BUFFER MAXLEN PREVBT EQU BUFFER-1

More Related