EdAsm/EDASM.SRC/LINKER/linker.aii

1 line
108 KiB
Plaintext
Raw Normal View History

2016-03-19 07:29:24 +00:00
LINK_S_P1 PROC ORG $2000 ; ### COMMENT - MACRO to create STR/.STRING directive equivalence. ; Remove this MACRO if the file M16.UTIL is ever INCLUDED. MACRO STR &string LCLC &sset &sset SETC &SETTING('STRING') STRING PASCAL DC.B &string STRING &sset MEND ; AsmIIGS directives to set equivalent 6502/65C02 mode. MACHINE M6502 LONGA OFF LONGI OFF ; This EdAsm/Asm816 source code file was converted to AsmIIGS ; by EdAsmCvtIIGS version 1.2 on 4/4/12 at 7:22:42 AM INCLUDE 'equates.aii' FileDataBufSiz EQU $2000-srcDataBuf ;20 mempages=5K ; ; Initial code disassembled with the ORCA.DisAsm ; Source files for the Linker is of type REL ; The Linker can produce BIN, REL or SYS object files ; ; Init the Linker LinkerEntry LDX #0 STX LinkerEntry ;Ensure a fresh copy is loaded PHP ;Save status reg PLA STA SaveA SEI ;Don't interrupts please LDA #0 @loop STA STACK,X ;Zero 6502 H/W stack INX BNE @loop DEX TXS ;=$FF LDA SaveA PHA ;RESTORE status reg PLP LDA #$00 STA MINIVERS ;minimum interpreter version LDA #$10 STA IVERSION ;interpreter version LDA #%00000011 ;reserve Pages 6-7 STA MemoryMap ; setup memory map LDA #%10101000 AND #%00000111 TAX ;(X)=0 LDY #0 TYA ;(A)=0 @loop1 ORA BitsTab,Y INY DEX BPL @loop1 EOR #$FF ;(A)=%01111111 LDX #$15 AND MemoryMap,X ;Mark page $A8 STA MemoryMap,X ; as free LDA #$00 DEX @zloop STA MemoryMap,X ;Pages $08-$A7 DEX ; are free BNE @zloop ; Init various flags & variables LDA #$80 ;Set the following STA MapOption ; options to ON STA SortOption STA XRefOption STA EntryRefOption LDA #$00 ;Set the following STA PageOption ; options to OFF STA Option_D ;reserved for future STA IsOptions STA WhichType STA IsNumSort STA Origin ;Zero this STA Origin+1 LDA #1 STA LineCnt STA PageCnt ; Try to open a default command (TXT) file named "EDASM.AUTOLINK" LDY AUTOLNKS @cploop LDA AUTOLNKS,Y STA pathNameBuf,Y DEY BPL @cploop JSR PRODOS8 DC.B $C8 ;OPEN DC.W OpenCmdRecP8 BEQ DoPhase0 CMP #$46 ;fileNotFound? BNE NoGood ;some other errors BEQ FnotF ShowErr JSR PrintError ;(A)=err code, don't come back FnotF LDY #$00 ;Print Banner & prompt JSR DisplayMsg ; for command filename LDA #'?'+$80 STA PROMPT JSR GetLine ;Use monitor's input rtn to get filename STX pathNameBuf ;Save len byte LDA InBuf ;Did user choose to Abort CMP #CTRLC+$80 ; the linking process? BNE @cloop2 JMP Abort ;Yes @cloop2 LDA InBuf,X ;Copy the filename AND #$7F ; typed in & ensure all STA pathNameBuf+1,X ; its chars are std ASCII DEX BPL @cloop2 JSR PRODOS8 DC.B $C8 ;OPEN DC.W OpenCmdRecP8 BEQ DoPhase0 CMP #$40 ;badPathSyntax BEQ ShowErr CMP #$44 ;pathNotFound BEQ ShowErr CMP #$45 ;volNotFound BEQ ShowErr CMP #$46 ;fileNotFound BEQ ShowErr NoGood JSR ErrHandler ;Don't come back ;================================================= ; Phase 0: Setup environment for the Linker ; Each record in the Command File is a CR-terminated text line (msb off) ; Each text line is either ; a command to the Linker or ; the pathname of a source file of type REL ; Directives/Commands to the Linker must be preceded by ; at least 1 space while pathnames have no leading space(s) ; ($20C7) DoPhase0 LDA OpenCmdRecP8+C_OUTREF ;Copy this to the fields STA MarkCmdRecP8+C_REFNUM ; of other ProDOS parameter STA NewLineRecP8+C_REFNUM ; blocks b4 we start to read STA ReadCmdRecP8+C_REFNUM ; the CMD file line by line ; Ensure that all future READ operations on the Command ; File is terminated by a CR or an EOF JSR PRODOS8 DC.B $C9 ;NEWLINE DC.W NewLineRecP8 BNE NoGood LDA #BIN_type ;Default OBJECT filetype STA TargetObjType LDY #$03 ;Display "Phase0: Commands..." JSR DisplayMsg JSR DisplayCR ; This loop only processes d