.H Copyright (c) 1988-2002, Gary D. Campbell NAME=PASS2 PASS3 CODE=0D00 0D00 NEXT ------------- LINK: PASS2 --------------------- : Code in this module fans out to a P2xx (xx=type of the .OBJ file) : which moves all Global definitions from the NEXT SymTabs into : SYMTAB, so that PASS.3 can do all the final fixups. : 0D00 PASS.2 ENTRY 0D00 AA=%(BP+DBOT) Set default DBSE computed by PASS1 0D03 %(BP+DBSE)=AA 0D06 SI,DS=%(BP+FB) Pointer to File Base (1st .OBJ) 0D09 %(BP+XPT)=@0 Pointer to .OBJ Base Entry in XPATCH 0D0E DO CALL SET.PARMS HL = @ for .OBJ type. 0D11 SWAP HL,BP Push addresses 0D13 PUSH %(BP+4) 3rd address = PASS 2 PROC function 0D16 PUSH %(BP+6) 0D19 SWAP HL,BP -- Push other parms Above -- 0D1B POP %(BP+SDEF) 0D1E POP %BP -- Pop NEXT PARMS Here -- 0D21 DI,ES=%(BP+XPT) 0D24 ES: AA=%DI 0D27 %(BP+CBSE)=AA 0D2A DI=(DI+4) 0D2D %(BP+XPT)=DI 0D30 CALL %%BP Call PROC function for .OBJ type. 0D33 CALL MIN.SI 0D36* $SI:0 0D39 LOOP UNTIL EQ 0D3B GOTO CK.UNDEF Rescan SYMTAB for undef'd symbols. 0D3E INIT.FB PUSH DS 0D3F PUSH SI 0D40 CALL SKIP.SYM Skip to end of SymTab 0D43 AA=%(SI+1) & handle 1st fixup 0D46 %(BP+TDA)=AA 0D49* $SI::0C0 0D4C IF NZ, 0D4E* $SI::080 Here, one or both CODE= or DATA= 0D51 AA=%(SI+3) is present. 0D54 IF NZ, 0D56* $SI::040 (test DATA= flag) 0D59 AA=%(SI+5) 0D5C * IF ZR,EXIT (no DATA=) 0D5E ELSE %(BP+DBSE)=AA YES: Set DATA= 0D61 POP SI 0D62 POP DS 0D63 RETURN .PAD=10 0D70 P2FB ENTRY Pass 2: filetype=FB 0D70 CALL INIT.FB Updates CBSE, DBSE, and TDA. 0D73 DO A=$SI 0D75* A:0 0D77 * IF EQ,EXIT 0D79* A:040 Globals are types 0x,1x,2, & 3x. 0D7B IF LT, (Abs, Ext, Code Rel, & Data Rel) 0D7D PUSH AA 0D7E CALL SYMDEF Enter a Global into SYMTAB 0D81 POP AA 0D82* AA=AA AND 0F 0D85* SI=SI+AA 0D87 LOOP 0D89 AA=%(BP+TDA) 0D8C* %(BP+DBSE)=%(BP+DBSE)+AA 0D8F GOTO SKIP.REM 0D92 SYMDEF DI,ES=%(BP+SYM) Lookup at %(SI+3) 0D95 A=$SI _________________ 0D97* AA=AA AND 0F / (S = Skip) \ 0D9A DO ES: C=$DI [T S][ DEF ][next] 0D9D* BC=BC AND 0F T=0 New Entry (no def) 0DA1 IF ZR, 1 Quad follow-on entry 0DA3 $DI+=A 2 Old Def (reset) 0DA4 SWAP AA,BC 3 Absolute Definition 0DA5 %DI+=AA 0DA6 PUSH SI 0DA7 PUSH BC 0DA8 SI=(SI+3) 0DAB* BC=BC-03 0DAE DO UNTIL BC=0 $DI+=$SI+ BC=BC-1 LOOP (BC>0) 0DB0 $DI+=A 0DB1+ DI=DI-1 0DB2 POP AA 0DB3 POP SI 0DB4 * EXIT Here we make a new entry. 0DB6* A:C 0DB8 IF EQ, 0DBA PUSH SI 0DBB SI=(SI+3) 0DBE DI=(DI+3) 0DC1* BC=BC-03 0DC4 DO UNTIL BC=0 * $SI+:$DI+ BC=BC-1 LOOP EQ (BC>0) 0DC6 POP SI 0DC7 * IF EQ,EXIT Here we find an old entry. 0DC9* DI=DI+BC 0DCB LOOP 0DCD* DI=DI-AA Re-point DI to Begin Entry 0DCF GOTO %%(BP+SDEF) (SI,DS must be preserved) .PAD=10 001C LST=01C NEXT Symbol Table Pointer 0DE0 GET.FB ENTRY Get TKN in the NEXT FB Symbol Table. 0DE0 SI,DS=%(BP+LST) 0DE3 FBLA DO BC=%SI Look Ahead to next instance of TKN. 0DE5* BC=BC AND 0F 0DE9 * IF ZR,EXIT 0DEB* SI=SI+BC 0DED* $SI::080 0DF0 * IF ZR,LOOP 0DF2* A:$(SI+1) 0DF5 * IF NE,LOOP 0DF7 BC=%(SI+2) 0DFA* A:0 Return NZ, BC=Definition 0DFC RETURN 0DFD DUPSYM AA=@W.2 0E00 DSPSYM ENTRY 0E00 PUSH BC 0E01 PUSH DS 0E02 PUSH SI 0E03 PUSH ES 0E04 PUSH DI 0E05 ES=CS 0E07 DI=0172 0E0A BC=%SI 0E0C* BC=BC AND 0F 0E10* BC=BC-03 0E13 SI=(SI+3) 0E16 DO UNTIL BC=0 $DI+=$SI+ BC=BC-1 LOOP (BC>0) 0E18 ES: $DI=B 0E1B SWAP AA,SI 0E1C CALL DSPLY 0E1F POP DI 0E20 POP ES 0E21 POP SI 0E22 POP DS 0E23 POP BC 0E24 RETURN 0E25 CK.UNDEF SI,DS=%(BP+SYM) 0E28 DO A=$SI 0E2A* AA=AA AND 0F 0E2D * IF ZR,EXIT 0E2F* $SI::0F0 0E32 IF ZR, 0E34 PUSH AA 0E35 AA=@W.3 0E38 CALL DSPSYM 0E3B POP AA 0E3C* SI=SI+AA 0E3E LOOP 0E40 RETURN .PAD=10 0E50 S2FB ENTRY 0E50 BC=%(SI+1) 0E53 RE.S2FB DE=@M2FB 0E56 A=$SI Here, we update a 0E58 ES: A'=$DI SYMTAB definition at $DI 0E5B* AA=AA AND 0F070 with a NEXT entry at $SI. 0E5E* LSR A,4 A = 0E61* A=A OR A' 0E63 A.FCN ENTRY 0E63 SWAP DE,BP DE = @List of [(byte),(@Function)].. 0E65* DO A:$BP Here we make a branch CALL to 0E68 * IF EQ,EXIT one of the Functions on the List. 0E6A BP=(BP+3) 0E6D* $BP:0 "A" must match a "byte" in the list 0E71 LOOP UNTIL EQ else, [ 0 ],[@error function]. 0E73 BP=%(BP+1) 0E76 SWAP DE,BP 0E78 GOTO %DE All regs unchanged except DE. 0E7A M2FB: =000,@FB00,001,@FB01,002,@FB02,003,@FB03 NEXT Type 0E86 =010,@FB10,011,@FB11,012,@FB12,013,@FB13 0=Abs 1=Ext 0E92 =020,@FB20,021,@FB21,022,@FB22,023,@FB23 2=CR 3=DR 0E9E =030,@FB30,031,@FB31,032,@FB32,033,@FB33,0,@CRASH 0EAD FB00 NEXT Global $DI=0, NEXT $SI=0 See prev page 0EAD FB20 NEXT Global $DI=2, NEXT $SI=0 for Types of 0EAD FBXX: ES: %(DI+1)=BC symbols in 0EB1* ES: $DI=$DI OR 030 SYMTAB. 0EB5 RETURN 0EB6 FB01 NEXT Global $DI=0, NEXT $SI=1 0EB6 FB21 NEXT Global $DI=2, NEXT $SI=1 0EB6 A=C 0EB8 PUSH SI 0EB9 CALL FBLA Must Look Ahead (may be a Token Equate) 0EBC IF NZ,CALL RE.S2FB (If so, define it) 0EC1 POP SI 0EC2 RETURN 0EC3 FB02 NEXT Global $DI=0, NEXT $SI=2 0EC3 FB22 NEXT Global $DI=2, NEXT $SI=2 0EC3* BC=BC+%(BP+CBSE) 0EC6 GOTO FBXX 0EC8 FB03 NEXT Global $DI=0, NEXT $SI=3 0EC8 FB23 NEXT Global $DI=2, NEXT $SI=3 0EC8* BC=BC+%(BP+DBSE) 0ECB GOTO FBXX 0ECD FB10 NEXT Global $DI=1, NEXT $SI=0 0ECD FB11 NEXT Global $DI=1, NEXT $SI=1 0ECD FB12 NEXT Global $DI=1, NEXT $SI=2 0ECD FB13 CALL CRASH Global $DI=1, NEXT $SI=3 0ED0 FB30 CALL DUPSYM Global $DI=3, NEXT $SI=0 0ED3 GOTO FB00 0ED5 FB31 GOTO FB01 Global $DI=3, NEXT $SI=1 0ED7 FB32 CALL DUPSYM Global $DI=3, NEXT $SI=2 0EDA GOTO FB02 0EDC FB33 CALL DUPSYM Global $DI=3, NEXT $SI=3 0EDF GOTO FB03 .PAD=10 0EF0 P23X ENTRY Pass 2: filetype=3X 0EF0 CALL INIT.3X Updates CBSE, DBSE, and TDA. 0EF3 DO A=$SI 0EF5* A:0 0EF7 * IF EQ,EXIT 0EF9 PUSH AA Enter a 0EFA* A=A AND 0F0 into SYMTAB 0EFC* A:040 (External) 0EFE IF NZ, 0F00* A:060 (Global) 0F02 IF EQ,CALL SYMDEF 0F07 POP AA 0F08* AA=AA AND 0F 0F0B* SI=SI+AA 0F0D LOOP 0F0F AA=%(BP+TDA) 0F12* AA:0 0F14 IF NZ, 0F16 CALL EVAL.AA 0F19 %(BP+DBSE)=HL 0F1C+SKIP.REM: SI=SI+2 0F1E DO A=$SI 0F20* AA=AA AND 3F 0F23 * IF ZR,EXIT 0F25* SI=SI+AA 0F27 LOOP 0F29+ SI=SI+2 0F2B RETURN 0F2C INIT.3X PUSH DS 0F2D PUSH SI 0F2E CALL INIT.LST Skip to end of SymTab 0F31* AA=0 & handle 1st fixup 0F33* $SI::080 0F36 IF NZ, Default TDA = 0 0F38* $SI::040 Grab an explicit TDA 0F3B AA=%(SI+1) (first position) 0F3E IF NZ, 0F40 AA=%(SI+3) (second position) 0F43 %(BP+TDA)=AA Set the TDA for post-PASS2 update 0F46 POP SI NOTE: CODE= and DATA= declarations 0F47 POP DS are handled by XPL & PASS3. 0F48 RETURN 0F49 S23X ENTRY If we're looking at LST = 6x [Token] 0F49* $SI::020 then, we need to EVAL(Token) & update the 0F4C IF NZ, Global SYMTAB with an Absolute Definition. 0F4E AA=%(SI+1) (Key=0 in