Browse Source

added ASSEMBLER_PET_REC

pull/5/head
Michael Steil 4 years ago
parent
commit
5a9016fb91
  1. 335
      ASSEMBLER_PET_REC/asmieee
  2. 738
      ASSEMBLER_PET_REC/asmprint
  3. 308
      ASSEMBLER_PET_REC/asmtable
  4. 17
      ASSEMBLER_PET_REC/assembler
  5. 196
      ASSEMBLER_PET_REC/declare
  6. 607
      ASSEMBLER_PET_REC/directive
  7. 385
      ASSEMBLER_PET_REC/eval
  8. 508
      ASSEMBLER_PET_REC/main
  9. 221
      ASSEMBLER_PET_REC/numsyms
  10. 616
      ASSEMBLER_PET_REC/operand
  11. 10
      ASSEMBLER_PET_REC/start
  12. 4
      README.md
  13. 1
      build.sh

335
ASSEMBLER_PET_REC/asmieee

@ -0,0 +1,335 @@
.PAGE 'ASMIEEE'
; GETCHR
;
; SUBROUTINE TO GET NEXT CHARACTER OF INPUT FROM WHEREVER SOURCE IS
;
; SFILE IS SOURCE FLAG REGISTER.
; IF V=1 THEN LIBRARY
; IF MINUS THEN DISK
;
; RETURNS CHARACTER IN .A, AND A=0 IF END OF FILE.
; LCHAR HAS LAST CHAR RETURNED.
GETCHR STY SAVEY
STX SAVEX
BIT SFILE ;SOURCE?
BVS FLIBR ;FROM LIBRARY
BMI FDISK
LDY L56
CPY L027A
BNE L1BD5
LDY L56+1
CPY L027A+1
BNE L1BD5
LDA #0
PHP
BEQ GETCHX
L1BD5 LDY #0
LDA (L56),Y
STA LCHAR
PHP
INC L56
BNE L1BE3
INC L56+1
L1BE3 STA LCHAR
GETCHX LDY SAVEY
LDX SAVEX
RTS
FDISK LDX #2 ;FROM MAIN
CPX CHAN
BEQ FDISK2
JSR CLRCH
LDX #2
FDISK1 STX CHAN
JSR CHKIN
FDISK2 JSR BASIN
PHA
LDA SATUS ;CHECK FOR EOF
AND #$40 ;?EOI
BEQ FDISK3 ;NO...
LDA #0
STA LCHAR ;SET EOF
FDISK3 PLA
JMP GETCHX
FLIBR LDX #3
CPX CHAN
BEQ FDISK2
JSR CLRCH
LDX #3
JMP FDISK1
CRLF LDA #$D
OUTPUT STX SAVEX
STY SAVEY
LDX NOPRIN ;HARDCOPY?
BNE OUT15 ;NO HARDCOPY
PHA
LDA CHAN ;OUTPUT CHANNEL OPEN?
CMP #4
BEQ OUT10 ;YES...
JSR CLRCH
LDX #4
STX CHAN
JSR CKOUT
OUT10 PLA
PHA
JSR BSOUT
PLA
LDX LBOTH
BEQ OUT20
OUT15 JSR PRT
OUT20 LDX SAVEX
LDY SAVEY
RTS
DONE LDA #1
JSR CLOSE ;CLOSE DISPLAY
LDA #4
JSR CLOSE ;CLOSE PRINTER
LDA #5
JSR CLOSE ;CLOSE KEYBOARD
LDA NOBJ
BNE DONE10
JSR OBJEND
LDA #6 ;CLOSE OBJ FILE
JSR CLOSE
DONE10 LDA #7
JSR CLOSE
JSR CLRCH ;ERASE WORK FILE
JMP BREADY
CHKBRK LDA STKEY
CMP #STPVAL
BEQ CHB1
RTS
CHB1 LDA STKEY
CMP #STPVAL
BEQ CHB1
SEI
JSR CLRCH
LDA #0
STA CHAN
STA NDX ;FLUSH BUFFER
CLI
CHB2 JSR GETIN
ORA #0
BEQ CHB2 ;NO CHARACTER YET
CMP #'B' ;RETURN TO BASIC?
BEQ CHB5
CMP #'T'
BEQ L211E
RTS
CHB5 JMP DONE
L211E JSR CLRCH
JMP PRTQM
FTEST JSR CLRCH ;READ ERROR CHAN
LDX #7
STX CHAN
JSR CHKIN
JSR BASIN
PHA
JSR BASIN
CMP #'0'
BNE FTERR
PLA
CMP #'0'
BNE FTLP1
RTS
FTERR PLA
FTLP1 JSR BASIN
LDY #0
FTERR2 STY SAVEY
JSR BASIN ;COPY INTO BUFFER
CMP #','
BEQ FTERR3
LDY SAVEY
STA LTLBUF,Y
INY
BNE FTERR2
FTERR3 LDA #$8D ;PUT IN SHIFT-CR
STA LTLBUF,Y
LDA #>LTLBUF
LDY #<LTLBUF
JSR WSCRN
JMP BREADY
; MESSAGE TO LISTING ONLY
MSG STX SAVEX
MSG10 LDX SAVEX
LDA MSGS,X
PHP
AND #$7F
JSR OUTPUT
INC SAVEX
PLP
BPL MSG10
RTS
.PAGE
;
; OBJECT OUTPUT ROUTINE
;
OBJOUT PHA ;DATA BYTE
STA OBJMAP,Y ;SAVE IN MEM MAP
LDA NOBJ
BNE OBJ02
LDA PASS
BNE OB10 ;NOT PASS 1
OBJ02 PLA
OBEXIT RTS
OB10 LDA IFLAGS
AND #8 ;OBJECT FILE?
BEQ OBJ02 ;NOMEM IN EFFECT
TYA
CLC
ADC IPC
EOR LADDL
BNE OB15
ADC IPC+1
CMP LADDH
BEQ OB25
OB15 LDA BYTCNT ;IS ADDR CONSEC ?
BEQ OB20 ;YES. BYTCNT=0 MEANS RESET
JSR OBJWRT ;DUMP RECORD
OB20 JSR OBINT1 ;RESET BUFFER
OB25 LDX BYTCNT
PLA
STA OBJBUF+3,X ;PUT BYTE
INC BYTCNT ;INC COUNT
CLC
ADC CKSUML
STA CKSUML
BCC OB30
INC CKSUMH
OB30 INC LADDL ;INC LAST ADDRESS
BNE OB35
INC LADDH
OB35 CPX #MAXBYT-1
BCC OBEXIT
JSR OBJWRT ;FULL BUFFER, DUMP
JMP OBINT2
.PAGE
OBJINT LDA #0 ;INITIALIZE FOR...
STA RECNTL ;...OBJECT DUMP
STA RECNTH
OBINT1 LDA IPC ;INIT FOR...
STA LADDL ;...RECORD DUMP
LDA IPC+1
STA LADDH
OBINT2 LDA #0 ;INIT FOR CONSEC...
STA BYTCNT ;...RECORD DUMP
STA CKSUMH
LDA LADDL
STA OBJBUF+2
STA CKSUML ;INIT CHECKSUM
LDA LADDH
STA OBJBUF+1
CLC
ADC CKSUML
STA CKSUML
BCC OBINT3
INC CKSUMH
OBINT3 RTS
;
; WRITE OUT RECORD TO CHANNEL
;
OBJWRT INC RECNTL ;INC RECORD CNT
BNE OW20
INC RECNTH
OW20 LDX #0
STX SAVEX
LDA BYTCNT
CLC
ADC #3
STA SAVEY
LDA #';'
JSR OW45
OW23 LDX SAVEX
LDA OBJBUF,X
JSR OW40
INC SAVEX
LDY SAVEY
CPY SAVEX
BNE OW23
LDA BYTCNT
CLC
ADC CKSUML
PHA
LDA #0
ADC CKSUMH
JSR OW40
PLA
JSR OW40
LDA #$D ;RECORD TERMINATOR
BNE OW45
OW40 PHA
LSR A
LSR A
LSR A
LSR A
JSR ASCII
JSR OW45
PLA
AND #$0F
JSR ASCII
OW45 PHA
LDA CHAN
CMP #6
BEQ OW50
JSR CLRCH
LDX #6
STX CHAN
JSR CKOUT
OW50 PLA
JMP BSOUT
OBJEND JSR OBJWRT
OE10 LDA RECNTL ;DUMP TRAILER REC
STA LADDL
LDA RECNTH
STA LADDH
JSR OBINT2
JMP OBJWRT
ASCII CLC
ADC #$F6
BCC ASC1
ADC #6
ASC1 ADC #$3A
RTS
.END

738
ASSEMBLER_PET_REC/asmprint

@ -0,0 +1,738 @@
.PAGE 'ASMPRINT'
; MAKE AN ENTRY IN LENGTH TABLE
; X CONTAINS COL. FOR ERROR
; Y CONTAINS LENGTH
; A CONTAINS ERROR CODE
LTINS PHA
TYA
PHA
LDY #0
STA LTAB,Y
INY
TXA
STA LTAB,Y
INY
PLA
TAX
LDA IPC
STA LTAB,Y
INY
LDA IPC+1
STA LTAB,Y
INY
PLA
STA LTAB,Y
INY
LDA ICRDNO+1
STA LTAB,Y
; ADJUST RELATIVE BRANCH
CPX #$FF ;-1?
BNE L20 ;NO...
LDX #0
L20 CPX #4
BNE L30
DEY
LDA LTAB,Y ;GET ERROR CODE
CMP #201
BNE L30
LDX #2
L30 CPX #3 ;CHECK FOR DBYTE
BNE L31 ;ONLY INCREMENT
DEY
LDA LTAB,Y
CMP #202
BNE L31
LDX #2
L31 TXA
CLC
ADC IPC ;IPC + KINC
STA IPC
LDA IPC+1
ADC #0
STA IPC+1
LDA PASS ;WHICH PASS?
BNE P2PRI ;PASS2--LIST...
RTS ;DON'T LIST IN PASS1
P2PRI LDY #4
LDA LTAB,Y ;ERROR FLAG
BNE P204
JMP PRTLN
P204 CMP #203 ;.PAGE?
BNE P201
SEC
LDY #1
LDA LTAB,Y ;COLUMN FOR TITLE
JMP SKPG ;DO A PAGE...CARRY SET
P201 CMP #204 ;.SKIP ?
BNE P202
LDY #1
LDA LTAB,Y ;GET COL PTR
BNE M121
CLC
ADC #1
BNE M124
M121 TAX
JSR EVAL
LDA RETURN ;GOOD EVAL?
BNE M122 ;NO...
LDA IEXP+1
M124 CLC
JMP SKPG
M122 CMP #1 ;CORRECT ERROR CODE
BEQ P202
LDA #$13
P202 CMP #205 ;.END ?
BEQ P205
STA LEROR
JMP ERRHND
P205 LDA #0 ;PRINT .LIB, .FIL, .END
STA IERR
JMP PRXX
.PAGE
; ************************
; * *
; * SYMBOL TABLE LISTING *
; * *
; ************************
NSTAT ;PRINT SYM TABLE
LDA STSAVE
STA SYMTBL
LDA STSAVE+1
STA SYMTBL+1
LDA LNCT
CMP #LINES-6
BCS XXXH
JSR PAGEHD
JMP XXXJ
XXXH JSR PAGE ;NEXT PAGE
XXXJ LDA #1
STA TOPPNT+1
LDA #0
STA TOPPNT
STA KLEN ;CLEAR PRINT COUNTER
R20 SEC
LDA NOSYM+1
SBC TOPPNT+1
LDA NOSYM
SBC TOPPNT
BCC R50
LDA LNCT
CMP #LINES
BMI R42
JSR PAGE
R42 JSR OUTCL1
LDY #0
R41 LDA (SYMTBL),Y
JSR OUTPUT ;PRINT SYMBOL
INY
CPY #6
BNE R41
JSR OUTCL3
LDA (SYMTBL),Y
JSR NUMA ;PRINT SYMBOL VALUE
INY
LDA (SYMTBL),Y
JSR NUMA
INC KLEN
LDA KLEN
CMP #4
BEQ R44
JSR OUTCL3
JMP R43
R44 LDA #0
STA KLEN
JSR CRLF
INC LNCT
R43 LDA SYMTBL
CLC
ADC #8
STA SYMTBL
BCC L14BB
INC SYMTBL+1
L14BB INC TOPPNT+1
BNE L14C1
INC TOPPNT
L14C1 JMP R20
R50 RTS
;
; SYMBOL TABLE PAGE ROUTINE
;
PAGE JSR TOPPAG
LDA #256-3
STA LNCT
PAGEHD LDX #STTTL-MSGS
JSR MSG
LDA LNCT
CLC
ADC #5
STA LNCT
RTS
;
; HOME FEED ROUTINE
;
TOPPAG LDY LNCT
R5B CPY #LINES
BCS R5A
JSR CRLF
INY
BNE R5B
R5A JSR CR2
CR4 JSR CRLF
CR3 JSR CRLF
CR2 JSR CRLF
JMP CRLF
.PAGE
; SKIP AND PAGE ROUTINE
;
; CARRY SET TO PAGE, CLEAR TO SKIP.
; ACC IS NUMBER OF LINES TO SKIP OR PNTR TO ICRD WHERE TITLE IS
;
; IF POINTER=0 OLD HEADING USED
; 0 LINES TO SKIP-1 LINE SKIPPED
SKPG PHP
PHA
LDA #4
AND IFLAGS ;NO LIST RUN ??
BNE N11
PLA
PLP
RTS
N11 NOP
NOP
NOP
NOP
NOP
NOP
NOP
PLA
PLP
BCC N90 ;IS SKIP
; IS PAGE - DO WE HAVE A TITLE?
SKPG1 TAX
BEQ PTTTL ;NO-USE OLD ONE
LDY #0 ;Y IS TITLE LENGTH
N10 LDA ICRD+1,X
CPY #20 ;MAXIMUM TITLE LENGTH
BEQ N15
CMP #$27 ;APPOSTROPHE
BEQ N15
STA LTLBUF,Y
INY
INX
CPX IMAXCL
BMI N10
BEQ N10
N15 STY LTLLEN ;LENGTH OF TITLE
; INCREMENT PAGE NUMBER & PRINT TITLE & PAGE NUMBER
PTTTL INC LPGCT ;INC. PAGNUM
JSR TOPPAG
PTTTL0 LDY #0 ;PRINT TITLE
N40 CPY LTLLEN ;ANY TITLE ??
BEQ NCV
N50 LDA LTLBUF,Y
JSR OUTPUT
INY
CPY LTLLEN
BMI N50
NCV LDX #6 ;PRINT 6 PERIODS
N60 LDA #'.'
JSR OUTPUT
DEX
BNE N60
LDX #PG-MSGS
JSR MSG
LDA LPGCT
JSR HEXDEC
LDX #16
JSR MSG
LDA #3
STA LNCT
RTS
N90 TAY
ADC LNCT
CMP #LINES
BPL PTTTL
STA LNCT
XXXI JSR CRLF
DEY
BMI XXXK
BNE XXXI
XXXK RTS
; ========================
; = END OF ASSEMBLY CODE =
; ========================
PASS3 LDA #2
CLC ;FOR SKIP DIRECTIVE
JSR SKPG ;SKIP PAGE
LDX #LINES
DEX
CPX LNCT
BCS M8811
LDA #0
SEC ;FOR A PAGE
JSR SKPG ;SKIP PAGE
M8811 INC LBOTH
; LDX P1ERR ;ANY PASS 1 ERRORS ?
; BEQ M8810 ;NO
;
; LDX #PSERR-MSGS
; JSR MSG
M8810 LDX #NUMERR-MSGS
JSR MSG
LDA LERCT ;ERROR COUNT
JSR HEXDEC ;MAKE IT DECIMAL
DEC LBOTH
JSR CRLF
INC LNCT
LDA #$40
AND IFLAGS ;SYMBOLS NEEDED?
BEQ M8813 ;NO...
LDA NOPRIN
BNE M8813
LDA NOSYM
ORA NOSYM+1 ;ANY SYMBOL TO SORT?
BEQ M8813 ;NO...
JSR L15D1
JSR NSTAT ;PRINT SYMBOL TABLE
JSR CRLF
M8813 INC LBOTH
LDX #DNMSG-MSGS
JSR MSG
DEC LBOTH
JMP DONE
L15D1 LDX #1
L15D3 LDA NOSYM,X
STA IPC,X
LDA STSAVE,X
STA PNT1,X
DEX
BPL L15D3
L15DF LDA PNT1
CLC
ADC #8
STA PNT2
LDA PNT1+1
ADC #0
STA PNT2+1
LDY IPC
LDA IPC+1
SEC
SBC #1
BCS L15F6
DEY
L15F6 STY TBLPTR
STA TBLPTR+1
ORA TBLPTR
BNE L15FF
RTS
L15FF LDY #0
L1601 LDA (PNT1),Y
CMP (PNT2),Y
BMI L161F
BNE L1610
INY
CPY #6
BNE L1601
BEQ L161F
L1610 LDY #$07
L1612 LDA (PNT2),Y
PHA
LDA (PNT1),Y
STA (PNT2),Y
PLA
STA (PNT1),Y
DEY
BPL L1612
L161F LDA PNT2
CLC
ADC #8
STA PNT2
BCC L162A
INC PNT2+1
L162A DEC TBLPTR+1
LDA TBLPTR+1
CMP #$FF
BNE L1634
DEC TBLPTR
L1634 ORA TBLPTR
BNE L15FF
LDA PNT1
CLC
ADC #8
STA PNT1
BCC L1643
INC PNT1+1
L1643 DEC IPC+1
LDA IPC+1
CMP #$FF
BNE L15DF
DEC IPC
JMP L15DF
.PAGE
; *************************
; *
; * PRTLN - PRINT ROUTINE
; * PRINTS ONE OUTPUT LINE
; *
; *************************
PRTLN LDA LTAB+4
STA IERR
LDA #4
AND IFLAGS ;LIST OPTION?
BNE PRXX
LDA IERR
BNE PRXXA
PRX1 RTS ;DO NOT LIST THIS CARD
PRXXA LDA IFLAGS
AND #16 ;ERRORS PRINT?
BEQ PRX1 ;NO...
PRXX LDA LTAB+2
STA IPC
LDA LTAB+3
STA IPC+1
LDA LTAB
Q5 PHA
LDA LTAB+5
PHA ;SAVE ON STACK
LDA #0
STA COLCNT
LDA LNCT ;LINE COUNT
BEQ Q10 ;IF ZERO - PAGE
CMP #LINES ;OVER THE LIMIT?
BCC Q20 ;NO
Q10 LDA #0 ;NEED TO PAGE
SEC
JSR SKPG ;PAGE ROUTINE
Q20 LDA ICRDNO ;A=CARD # HI
BEQ XXXM3
TAX
LDA #0
STA TEMB
XXXM1 DEX
BMI XXXM2
SED
CLC
ADC #$56
STA TEMB+1
LDA TEMB
ADC #$02
STA TEMB
CLD
LDA TEMB+1
JMP XXXM1
XXXM2 PLA
JSR L1A27
JMP XXXM4
XXXM3 PLA
JSR HEXDEC
XXXM4 INC COLCNT
INC COLCNT
JSR OUTCL2 ;PRINT TWO BLANKS
LDY #0
PLA
TAX
LDA IPC+1
JSR NUMC2
LDA IPC
JSR NUMC2
JSR OUTCL2
TXA
BMI Q44
CMP #4
BMI Q44
LDX #2
SEC
SBC #2
.BYTE $2C
Q44 LDA #0
PHA
Q50 DEX ;DEC BYTES LEFT
BMI Q60 ;0 OR MORE-PRINT NEXT
LDA OBJMAP,Y ;GET THE BYTE
JSR NUMC2
JSR OUTCL1
INY
INC IPC
BNE Q55
INC IPC+1
Q55 JMP Q50
; PRINT CARD IF SUPPOSED TO
Q60 LDA LCDPT ;PRINT FLAG
BEQ *+5
JMP Q80A
; NEED TO PRINT THE CARD
LDY COLCNT
Q65 JSR BLANK
INY ;INCR FOR BLANK
CPY #22 ;RIGHT COLUMN FOR CARD
BMI Q65 ;NO, PRINT MORE
INC IMAXCL
LDX #0 ;X POINTS TO CARD
LDA IERR
BNE Q70 ;DON'T TAB ERRORS
LDA ICRD
CMP #';' ;DON'T TAB COMMENT
BEQ Q70
LDY #0
LDA JLABL
BEQ Q74
Q73 LDA ICRD,X
INX
CMP #' '
BNE Q72 ;NOT BLANK
CPX IMAXCL
BEQ Q80 ;RAN OUT OF CARD
BNE Q73
Q72 JSR OUTPUT ;OUTPUT LABEL
INY
CPX IMAXCL
BEQ Q80 ;RAN OUT OF CARD
LDA ICRD,X
INX
CMP #$20
BNE Q72 ;STILL LABEL
JSR OUTPUT
INY
Q74 CPY #7
BCS Q75
JSR BLANK
INY
BNE Q74
Q75 LDA ICRD,X ;DO NOT PRINT OP
CMP #$20 ;UNTIL NONBLANK
BNE Q70
INY
INX
CPX IMAXCL
BEQ Q80
BNE Q75
Q70 CPX IMAXCL
BEQ Q80 ;OUT OF CARD
LDA ICRD,X ;GET OPCODE
; TAB COMMENT FIELD
CMP #';'
BNE Q70AA
PHA
LDA ICRD-1,X ;GET PREVIOUS
CMP #' '
BNE Q70A
Q70B CPY #23
BCS Q70A
JSR BLANK
INY
BNE Q70B
Q70A PLA
Q70AA INX
JSR OUTPUT
INY
BNE Q70
Q80 DEC IMAXCL
Q80A JSR CRLF
INC LNCT ;LINE COUNT
INC LCDPT ;FLAG A 2ND LINE
PLA ;BYTES LEFT OFF STACK
BEQ Q90 ;NONE LEFT-DONE
TAX
LDA IFLAGS ;NOGEN OPTION?
BMI Q90A ;YES...
TXA
JMP Q5 ;GET NEXT LINE
; NOGEN OPTION, UPDATE PC
Q90A TXA
CLC
ADC IPC
STA IPC
BCC Q90
INC IPC+1
Q90 RTS
NUMC2 INC COLCNT
INC COLCNT
JMP NUMA
OUTCL3 JSR OUTCL1
OUTCL2 JSR OUTCL1
OUTCL1 INC COLCNT
BLANK LDA #' '
JMP OUTPUT
; ERROR HANDLER
ERRHND INC LBOTH
LDA LNCT
CMP #LINES ;END OF PAGE?
BMI P10 ;NO, SO PRINT ERROR
LDA #0 ;YES, SKIP A PAGE
SEC
JSR SKPG
P10 JSR PRTLN ;PRINT THE LINE
LDX #0 ;GET READY FOR ERROR
JSR MSG
LDA LEROR
JSR NUMA
LDX #11
L17E9 JSR BLANK
DEX
BNE L17E9
PHA
LDA LTAB+1 ;ERROR COLUMN #
TAX
PLA
P45 DEX
BMI P50
JSR OUTPUT
JMP P45
P50 LDA #$5E ;UP ARROW AT ERROR
JSR OUTPUT
JSR CRLF
INC LNCT
P60
; LDA PASS ;IS IT PASS 1 ?
; BNE P61 ;NO
;
; LDA #$FF ;SET PASS 1 ERROR FLAG
; STA P1ERR
P61 INC LERCT
DEC LBOTH
RTS
; PRINT A 5 DIGIT DEC NUMBER
;
HEXDEC LDX #0
STX TEMB
STX TEMB+1
L1A27 PHA
CLC
LSR A
LSR A
LSR A
LSR A
TAX
L1A2E LDA TEMB+1
DEX
BMI L1A4B
SED
CLC
ADC #$16
STA TEMB+1
CLD
BCC L1A2E
SED
LDA TEMB
ADC #0
STA TEMB
CLD
JMP L1A2E
L1A4B PLA
AND #$0F
CLC
SED
ADC #0
ADC TEMB+1
STA TEMB+1
CLD
BCC L1A65
LDA TEMB
SED
ADC #0
CLD
STA TEMB
L1A65 LDA TEMB
JSR NUMA
LDA TEMB+1
JMP NUMA
; PRINT HEX NUMBER IN A
NUMA PHA
LSR A
LSR A
LSR A
LSR A
JSR NOUT
PLA
AND #$0F
NOUT CLC
ADC #$30
CMP #$3A
BMI LT10
CLC
ADC #7
LT10 JMP OUTPUT
.END

308
ASSEMBLER_PET_REC/asmtable

@ -0,0 +1,308 @@
.PAGE 'ASMTABLE'
;
; IND TABLES & SEARCH TABLES
;
NUMSAV = 12
NUMASM = 21
ASMJMP
.WORD H312 ;NOLIST
.WORD H311 ;LIST
.WORD H310 ;NOMEM
.WORD H309 ;MEM
.WORD H308 ;NOERR
.WORD H307 ;ERR
.WORD H306 ;COUNT
.WORD H306 ;COUNT
.WORD H305 ;NOCOUNT
.WORD H304 ;NOSYMBOL
.WORD H303 ;SYMBOL
.WORD H302 ;NOGEN
.WORD H323 ;GEN
.WORD HLIB ;.LIB COMMAND
.WORD HFIL ;.FILE COMMAND
.WORD H301 ;.OPT COMMAND
.WORD H10 ;.END COMMAND
.WORD H12 ;.PAGE COMMAND
.WORD H26 ;.SKIP COMMAND
.WORD H506 ;.DBYT COMMAND
.WORD H113 ;.WORD COMMAND
.WORD H111 ;.BYTE COMMAND
ASMDIR
.BYTE 'BYT'
.BYTE 'WOR'
.BYTE 'DBY'
.BYTE 'SKI'
.BYTE 'PAG'
.BYTE 'END'
.BYTE 'OPT'
.BYTE 'FIL'
.BYTE 'LIB'
OPTDIR .BYTE 'GEN'
.BYTE 'NOG'
.BYTE 'SYM'
.BYTE 'NOS'
.BYTE 'NOC'
.BYTE 'CNT'
.BYTE 'COU'
.BYTE 'ERR'
.BYTE 'NOE'
.BYTE 'MEM'
.BYTE 'NOM'
.BYTE 'LIS'
.BYTE 'NOL'
OPRNDS .BYTE 'ADC'
.BYTE 'AND'
.BYTE 'ASL'
.BYTE 'BCC'
.BYTE 'BCS'
.BYTE 'BEQ'
.BYTE 'BIT'
.BYTE 'BMI'
.BYTE 'BNE'
.BYTE 'BPL'
.BYTE 'BRK'
.BYTE 'BVC'
.BYTE 'BVS'
.BYTE 'CLC'
.BYTE 'CLD'
.BYTE 'CLI'
.BYTE 'CLV'
.BYTE 'CMP'
.BYTE 'CPX'
.BYTE 'CPY'
.BYTE 'DEC'
.BYTE 'DEX'
.BYTE 'DEY'
.BYTE 'EOR'
.BYTE 'INC'
.BYTE 'INX'
.BYTE 'INY'
.BYTE 'JMP'
.BYTE 'JSR'
.BYTE 'LDA'
.BYTE 'LDX'
.BYTE 'LDY'
.BYTE 'LSR'
.BYTE 'NOP'
.BYTE 'ORA'
.BYTE 'PHA'
.BYTE 'PHP'
.BYTE 'PLA'
.BYTE 'PLP'
.BYTE 'ROL'
.BYTE 'ROR'
.BYTE 'RTI'
.BYTE 'RTS'
.BYTE 'SBC'
.BYTE 'SEC'
.BYTE 'SED'
.BYTE 'SEI'
.BYTE 'STA'
.BYTE 'STX'
.BYTE 'STY'
.BYTE 'TAX'
.BYTE 'TAY'
.BYTE 'TSX'
.BYTE 'TXA'
.BYTE 'TXS'
.BYTE 'TYA'
; CONSTANT TABLES
KLUDG .BYTE 255,13,27,41
.BYTE 55,69,83,97
.BYTE 111,125,139,153
.BYTE 167,181,195
KLTBL .BYTE 255,255,255,255
.BYTE 4,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 4,4,255,255,0,4,0
.BYTE 4,0,0,4,0,255,0
.BYTE 20,20,255,255,16
.BYTE 255,255,20,255,16
.BYTE 255,16,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 16,255,20,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 0,0,32,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255
.BYTE 255,255,255,255,16
.BYTE 16,255,255,255,255,255,255
.BYTE 255,255,255,255,255,255
.BYTE 8,255,255,255,255,0,255
.BYTE 0,255,255,0,255,255,255
.BYTE 12,12,0,0,8,12,8,12,8
.BYTE 8,12,8,255,255
.BYTE 28,28,255,255,24,255,255
.BYTE 28,255,255,255,24,255,255,24
.BYTE 24,255,255,255,255,255,255
.BYTE 255,255,$1C,255,255,255
KTMPL .BYTE 1
.BYTE 1
.BYTE 5
.BYTE 21
.BYTE 21
.BYTE 21
.BYTE 7
.BYTE 21
.BYTE 21
.BYTE 21
.BYTE 20
.BYTE 21
.BYTE 21
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 1
.BYTE 6
.BYTE 6
.BYTE 12
.BYTE 20
.BYTE 20
.BYTE 1
.BYTE 12
.BYTE 20
.BYTE 20
.BYTE 3
.BYTE 4
.BYTE 1
.BYTE 11
.BYTE 8
.BYTE 5
.BYTE 20
.BYTE 1
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 5
.BYTE 5
.BYTE 20
.BYTE 20
.BYTE 1
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 2
.BYTE 9
.BYTE 10
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 20
.BYTE 20
KCODE .BYTE 97
.BYTE 33
.BYTE 6
.BYTE 144
.BYTE 176
.BYTE 240
.BYTE 36
.BYTE 48
.BYTE 208
.BYTE 16
.BYTE 0
.BYTE 80
.BYTE 112
.BYTE 24
.BYTE 216
.BYTE 88
.BYTE 184
.BYTE 193
.BYTE 224
.BYTE 192
.BYTE 198
.BYTE 202
.BYTE 136
.BYTE 65
.BYTE 230
.BYTE 232
.BYTE 200
.BYTE 76
.BYTE 32
.BYTE 161
.BYTE 162
.BYTE 160
.BYTE 70
.BYTE 234
.BYTE 1
.BYTE 72
.BYTE 8
.BYTE 104
.BYTE 40
.BYTE 38
.BYTE $66
.BYTE 64
.BYTE 96
.BYTE 225
.BYTE 56
.BYTE 248
.BYTE 120
.BYTE 129
.BYTE 134
.BYTE 132
.BYTE 170
.BYTE 168
.BYTE 186
.BYTE 138
.BYTE 154
.BYTE 152
; MESSAGES
MSGS
ERMSG .BYTE '***ERROR #',$A0
PG .BYTE 'PAGE',$A0
HD .BYTE $D,$D,'LINE#'
.BYTE ' LOC '
.BYTE 'CODE '
.BYTE 'LINE',$D,$D,$8D
STOERR .BYTE 'SYMBOL TABLE'
.BYTE ' OVERFLOW',$8D
NUMERR .BYTE 'ERRORS =',$A0
P1MSG .BYTE $D,'PASS1'
CRMSG .BYTE $8D
P2MSG .BYTE $D,'PASS2',$8D
DNMSG .BYTE $D,'END OF ASSEMBLY'
.BYTE $8D
STTTL .BYTE $D,$D,'SYMBOL'
.BYTE ' TABLE',$D,$D
.BYTE 'SYMBOL VALUE',$8D
SRCMSG .BYTE $D,'SOURCE FILE?',$A0
FNERR .BYTE $D,'FILE NAME ERROR',$8D
LIBERR .BYTE $D,'.LIB ERROR',$8D
STTMSG .BYTE $D,'OBJECT FILE?',$A0
HCMSG .BYTE $D,'HARD COPY?',$A0
.END

17
ASSEMBLER_PET_REC/assembler

@ -0,0 +1,17 @@
.LIB DECLARE
.LIB START
.LIB MAIN
.LIB DIRECTIVE
.LIB OPERAND
.LIB EVAL
.LIB NUMSYMS
.LIB ASMPRINT
.LIB ASMTABLE
.LIB ASMIEEE
L2000 =$2000
SYTBST =$3000
L2FFF =SYTBST-1
.END

196
ASSEMBLER_PET_REC/declare

@ -0,0 +1,196 @@
.PAGE 'ASSEMBLER DECLARE'
; ********************************
; * *
; * COMMODORE VER-?.? *
; * *
; * PET 2-PASS ASSEMBLER *
; * FOR BASIC 2 *
; * *
; * COPYRIGHT ?? ????????, ???? *
; * COMMODORE BUSINESS MACHINES *
; * *
; ********************************
; LISTING DATE: ??? ??, ????
; THE ASSEMBLER OPENS AND REFERS TO SEVEN LOGICAL FILES.
; IT ASSUMES A PRINTER ATTACHED AS DEVICE 4, AND A DISK
; AS DEVICE 8. AN 'N' RESPONSE TO THE QUESTION 'HARD COPY?'
; WILL DIRECT OUTPUT TO THE SCREEN AND NO PRINTER WILL BE
; REQUIRED. A NULL RESPONSE TO WILL TERMINATE OPERATION
; AND RETURN TO BASIC.
;
;
; LOGICAL FILES USED:
;
; 1 =CRT SCREEN
; 2 =SOURCE FILE
; 3 =LIBRARY FILE
; 4 =PRINTER OUTPUT FILE
; 5 =KEYBOARD INPUT FILE
; 6 =OBJECT OUTPUT FILE
; 7 =DISK COMMAND CHANNEL
; 8 =LABEL OUTPUT FILE
; 9 =CROSS REF OUTPUT FILE
; CONSTANTS FROM PET OS
SYTBND = $30 ;END OF SYMBOL TABLE (BASIC FRETOP)
SATUS = $96 ;I/O STATUS BYTE
STKEY = $9B
TIME = $A3 ;JIFFY CLOCK
FNLEN = $D1 ;FILE NAME LENGTH
LA = $D2 ;LOGICAL ADDRESS
SA = $D3 ;SECONDARY ADDRESS
FA = $D4 ;FILE ADDRESS
FNADR = $DA ;FILE NAME ADDRESS
NDX = $9E ;NUMBER CHARS IN BUFFER
KEYD = $26F ;KEYBOARD INPUT BUFFER
USER = $01 ;SAVE AREA FOR E. C. READ
SATUS = $96 ;I/O STATUS BYTE
BREADY =$C389
PRTQM =$E7F7
PRT =$E3D8
GETIN =$F1D1
CLOSE =$F2AE
OPEN =$F524
CHKIN =$F770
CKOUT =$F7BC
CLRCH =$FFCC
BASIN =$F1E1
BSOUT =$F232
;
; CONSTANTS
;
LINES = $3A
STPVAL = $EF ;VALUE FOR CHECKING STOP KEY
STKVAL = $FF ;INITIAL STACK VALUE
; ********************
; * ZERO PAGE STORAGE
; ********************
* = $42
SYMTBL *=*+2
TOPPNT *=*+2
IPC *=*+2
TBLPTR *=*+2
PNT1 *=*+2
PNT2 *=*+2
STSAVE *=*+2 ;SYMBOL TABLE BEGIN
*=*+4
ISYEND *=*+2
L56 *=*+2
;
; NON ZERO PAGE STORAGE
;
*=$027A
L027A *=*+2
CHAN *=*+1 ;CURRENT I/O CHANNEL
ISRC *=*+16 ;ORIGINAL SOURCE FILE
ISRCLN *=*+1 ;SOURCE NAME LENGTH
LCHAR *=*+1 ;LAST CHARACTER GOT
*=*+1
NOSYM *=*+2 ;# SYMBOLS IN SYMTBL
LPGCT *=*+2
JOPBAS *=*+1 ;BASE OPCODE (PASS 1)
JOPTEM *=*+1 ;OPCODE TEMPLATE
KNVAL *=*+2 ;INTERMED VAL IN EVAL
KOP *=*+1 ;NXT OPER FOR EVAL
KLEN *=*+1 ;LENGTH OF STR TO PACK
RETURN *=*+1 ;RTN CODE FROM EVAL
KBASE *=*+1 ;BASE OF # TO EVAL
LTLLEN *=*+1 ;TITLE LENGTH
J *=*+1 ;GENERAL COUNTER
LERCT *=*+1 ;TOTAL ERROR COUNT
JOPTYP *=*+1 ;OPERAND TYPE (PASS 1)
JNOPV *=*+1 ;FLAG FOR NO OPER VAL
LEROR *=*+1 ;ERROR NUMBER (PASS 2)
JERCOL *=*+1 ;ERROR COLUMN
ILSST *=*+1 ;START OF A LABEL
LCDPT *=*+1 ;MULTIPLE LINES FLAG
JLABL *=*+1
JORG *=*+1
JBYWOR *=*+1 ;ASM DIRECTIVE WORD
PASS *=*+1
ICRDNO *=*+2 ;CURRENT CARD NUMBER
ICSB *=*+1 ;CURRENT STRING BEGIN
ICSE *=*+1 ;CURRENT STRING END
ICSL *=*+1 ;CURRENT STRINT LENGTH
IEXP *=*+2 ;VALUE OF EXPR EVAL
ICOLP *=*+1 ;CURRENT COLUMN
LNCT *=*+1
JOPLEN *=*+1 ;OPERAND LENGTH
IERR *=*+1 ;ERROR CODE
LBOTH *=*+1 ;LIST TO SCR & PRNTER
NOPRIN *=*+1 ;NO HARD COPY FLAG
IFLAGS *=*+2 ;SET OF FLAGS
; NOGEN 128 = DON'T GENERATE STRINGS
; NOSYM 64 = DON'T GEN SYMBOL TABLEW
; OPCNT 32 = DO AN OPCODE COUNT
; NOERR 16 = ERROR ONLY LISTING
; INTER 8 = CREATE INTERFACE FILE
; LIST 4 = CREATE OUTPUT LISTING
; EXP 2 = EXPAND MACROS
COLCNT *=*+1 ;COLUMN COUNT
IMAXCL *=*+1 ;MAX COLUMNS ON CARD
KLOW *=*+1 ;< FLAG
KHIGH *=*+1 ;> FLAG
CHAR *=*+1
TEMP *=*+2
TEMB *=*+2 ;WORK AREA
SAVEX *=*+1 ;SAVE .X (WSW)
SAVEY *=*+1 ;SAVE .Y (PTCH)
SFILE *=*+1
;
; INPUT BUFFER AREA
;
ICRD *=*+80 ;INPUT BUFFER (MOVE TO $0200 ??)
LTLBUF *=*+20 ;TITLE BUFFER (E.C.)
LTAB *=*+6
ISYM *=*+16
;
; OBJECT FILE BUILD AREA
;
OBJMAP *=*+40 ;MEMORY MAP
CKSUML *=*+1 ;RECORD CHECKSUM
CKSUMH *=*+1
LADDL *=*+1 ;LAST ADDRESS
LADDH *=*+1
RECNTL *=*+1 ;RECORD COUNT
RECNTH *=*+1
MAXBYT =24 ;MAXIMUM BYTES/RECORD
BYTCNT =* ;RECORD BYTE COUNT
OBJBUF *=*+MAXBYT+3 ;OBJ OUT BUF
OBJFIL *=*+18 ;OBJECT FILE NAME
OBJLEN *=*+1 ;FILE NAME LENGTH
NOBJ *=*+1 ;NO OBJ FILE FLAG
.END

607
ASSEMBLER_PET_REC/directive

@ -0,0 +1,607 @@
.PAGE 'DIRECTIVE'
; EQUATE AND ORG PROCESSING ****
H102 LDA #$FF ;-1
STA JORG
INC ICOLP
STX ILSST ;SAVE START OF STRING
JSR NFNDNB ;IF REST FIELD BLANK
BCS H103 ;NONBLANK FOUND
H103A JMP H99
H103 LDA ICRD,X ;EQUATE OR ORG
CMP #'='
BNE H103A
H121 INC ICOLP
LDA ICOLP
CMP IMAXCL
BEQ H8804
BCC H8804
JMP H99 ;G.T. IMAXCL
H8804 JSR NFNDNB
BCS H104 ;NON-BLANK FOUND
LDX ICSE
LDA #7
LDY #0
JMP LTS1
H104 JSR EVAL ;EVAL OPERAND FIELD
DEC RETURN
BMI H105
BNE H8806
LDA #$11
LDY #3
JMP LTS1
H8806 LDA #$13
LDY #3
JMP LTS1
H105 LDA JORG ;EQU OR ORG
BEQ H9
LDA #1 ;ORG,EXPRESSION OK
AND IFLAGS+1
BEQ H150 ;EXPRESSION IS GE 0
LDX #0
STX IPC
STX IPC+1
LDX ICSB ;BAD EXPR - FLAG
LDA #$21
LDY #$FF
JMP LTINS
H150 LDX #0
TXA
TAY
JSR LTINS
LDA IEXP ;IPC = IEXP
STA IPC+1
LDA IEXP+1
STA IPC
JMP ENDLN
; IS EQUATE****
H9 PLA ;RESTORE LABEL PORTION
STA ICSL ;RESTORE LENGTH
LDX #5
H8846 PLA
STA ISYM,X
DEX
BPL H8846
JSR NFIND
BCC H106
LDA KNVAL ;SEE IF VALUE IS THE SAME
CMP IEXP
BNE MR01
LDA KNVAL+1
CMP IEXP+1
BEQ H106A ;OK
MR01 LDX ILSST ;ALREADY DEFINED
LDA #2
LDY #0
JMP LTS1
H106 LDA IEXP
STA KNVAL
LDA IEXP+1
STA KNVAL+1
JSR NSERT
H106A JMP H990
; ASSEMBLER DIRECTIVES *****
; FIND WHAT DIRECTIVE TO PROCESS
H5 LDA #$14 ;ASM ERROR CODE
STA IERR
LDX ICSB ;START OF DIRECTIVE
INX ;SKIP PERIOD
LDA #<ASMDIR
STA TBLPTR
LDA #>ASMDIR
STA TBLPTR+1
LDA #3 ;GET LENGTH
STA KLEN
JSR CONSYM ;BUILD DIRECTIVE
H8847 CPX IMAXCL
BEQ H8848
BCS H8849
H8848 LDA ICRD,X
CMP #$20
BEQ H8849
INX
JMP H8847
H8849 STX ICOLP ;PNTR TO CHAR AFTER DIRECT
LDA #0 ;INIT COLUMN TO ZERO
STA J
BCS H8835
JMP H900 ;ERROR--BAD SYMBOL
.PAGE
; SEARCH TABLE FOR MATCH
;
; COMPARE DONE BACK-FRONT
; MATCH-IND JMP MADE TO PROCESS
; MISMATCH-POINTER POINTS TO NEXT
; VALID DIRECTIVE IN TABLE.
; NUMASM IS # DIRECT TO SEARCH.
; (TBLPTR) IS CURR DIRECTIVE
H8835 LDX #NUMASM
H9938 LDY #2 ;OFFSET TO CHARS
H9939 LDA ISYM,Y ;CHR FROM SYMBOL
CMP (TBLPTR),Y ;CHAR IN TABLE
BNE H9940
DEY
BPL H9939 ;NOT DONE YET
; A MATCH-X USED TO LOC ADDR
TXA
ASL A ;*2 FOR ADDR TABLE INDEX
TAX
LDA ASMJMP,X ;LOW BYTE ADDR
STA TBLPTR
LDA ASMJMP+1,X ;HIGH BYTE ADDR
STA TBLPTR+1
LDA IFLAGS ;.OPT FLGS
JMP (TBLPTR) ;=>DIRECTIVE PROVESS
; POINT NEXT DIR & START AGAIN
; QUIT IF DONE (ERROR).
H9940 LDA TBLPTR ;LOW ADDR
CLC
ADC #3 ;OFFSET TO NEXT DIRECTIVE
STA TBLPTR
BCC H9938A
INC TBLPTR+1
H9938A DEX
BPL H9938 ;MORE DIRECTIVES
; INVALID DIRECTIVE - ERROR
JMP H900 ;PUT IN LENGTH TABLE
; BYTE, WORD, DBYTE PROCESSING ***
H111 LDA #1 ;*** .BYTE ***
.BYTE $2C
H506 LDA #3 ;*** DOUBLE BYTE ***
.BYTE $2C
H113 LDA #2 ;*** .WORD ***
STA JBYWOR
LDY #0
STY J ;MEMMAP INDEX FOR BYTE GEN
TAY
CPY #3 ;DBYTE ?
BNE H8809 ;NO
DEY
H8809 STY CHAR ;LENGTH OF EACH PARAM.
JSR NFNDNB ;NEXT NON-BLANK
BCS H18X ;NON-BLANK FOUND
LDX ICSE ;RAN OFF EOL
LDA #7
JMP LTS1
H18X STY CHAR
H18 LDX ICSB
JSR EVAL
DEC RETURN
BMI H14 ;RETURN =0
BEQ H8836 ;RETURN =1
JMP H29 ;RETURN =2
H8836 LDA #1 ;UNDEF'D SYM
STA IERR
XXXO CMP #1
BNE XXXM
LDY JBYWOR
STY CHAR
JMP XXXN
XXXM LDY CHAR
XXXN LDA IERR
LDX ICSB
JSR LTINS
LDY #0
STY J
LDY CHAR
CPY #3
BNE H15
DEC CHAR
JMP H15
H14 LDA #4 ;GOOD RETURN
STA IERR
LDX JBYWOR
CPX #3
BNE H8812
LDA IEXP
LDY J
JSR OBJOUT
INC J
H8812 LDA IEXP+1
LDY J
JSR OBJOUT
INC J
LDX JBYWOR
CPX #2
BNE H8820
LDA IEXP
LDY J
JSR OBJOUT ;IEXP IN MEMORY MAP
INC J
H8820 LDA IFLAGS+1
AND #$09
BNE XXXO
CPX #1
BNE XXXP
LDA IEXP
BNE XXXO
XXXP LDA #0
TAX
LDY CHAR
STA J
JSR LTINS
H15 JSR NFNCMP
BCS H8843
JMP ENDLN
H8843 LDA ICRD,X
CMP #','
BNE H15 ;MIGHT BE A PAREN
; FOUND COMMA OR PARENTHESIS
INX ;SKIP TO NEXT COLUMN
STX ICOLP
CPX IMAXCL ;PASSED END
BEQ H8814
BCC H8814
JMP H99 ;RAN OFF END OF CARD
H8814 JSR NFNDNB
BCS H8844 ;NON BLANK FOUND
JMP H99 ;ONLY BLANKS FOUND
H8844 JMP H18
; EXPRESSION HANDLER BOMBED
H29 LDA ICRD,X
CMP #$27 ;MIGHT BE ASCII (APPOSTROPHI)
BEQ H31 ;YES
H30 LDA #$13 ;BAD EXPRESSION
LDY TEMP
JSR LTINS
LDY #0
STY J
JMP H15
; LOOKS LIKE ASCII
H31 CPX ICSB ;FIRST IN STRING
BNE H30
LDY JBYWOR ;AFTER A .BYT
CPY #2
BCS H30
STX ICOLP ;COUNT BYTES GENERATED
LDY #0
H33 INC ICOLP
LDX ICOLP
CPX IMAXCL ;OFF END OF CARD?
BEQ H8815
BCS H473 ;OFF CARD
H8815 LDA ICRD,X
CMP #$27 ;A QUOTE?
BNE H32 ;NO
INC ICOLP ;IMBEDDED QUOTE
LDX ICOLP
CPX IMAXCL
BEQ H8821
BCS H34 ;RAN OFF END OF CARD
H8821 LDA ICRD,X
CMP #$27 ;A QUOTE?
BNE H34 ;NO
H32 PHA
AND #$7F
CMP #$20
BCC XXXQ
CMP #$60
BCC XXXR
XXXQ PLA
LDA #0
PHA
XXXR PLA
LDY J ;CONVERT TO ASCII
JSR OBJOUT
INC J ;COUNT OF ASCII CHARS
BNE H33 ; ** BRA
H34 LDY J
LDA #0
STA J
TAX
JSR LTINS
JMP H15
H473 LDY J ;*** RAN OFF END OF CARD ***
LDA #7
JMP LTS1
.PAGE
; .OPT ASSEMBLER DIRECTIVE
; LOOK FOR PARMS UNTIL NONE LEFT
; WHEN DONE TREAT AS A COMMENT
; USE SEARCH FROM ASMB DIRECTIVES
H301 JSR NFNDNB ;FIND STT OF PARM
BCS H8837 ;A NONBLANK FOUND
JMP H990 ;NO-TREAT LIKE COMMENT
H8837 LDX ICSB ;GET START OF PARM
LDA #3 ;3 IS LENGTH OF PARM
STA KLEN ;STORE FOR CONSYM
JSR CONSYM ;CONSTRUCT THE PARM
BCS H8838 ;O.K. SO CONTINUE
JMP H900 ;BAD PARM - ERROR
; ARE READY FOR SEARCH
; NEED TO RESTORE X AND THE ADRS
; WHERE THE SEARCH LEFT OFF
H8838 LDA #<OPTDIR
STA TBLPTR
LDA #>OPTDIR
STA TBLPTR+1
LDX #NUMSAV
JMP H9938 ;GO DO THE SEARCH
; GENERATE ASCII STRINGS
H323 AND #127 ;CLEAR NOGEN BIT
.BYTE $2C
; DON'T GENERATE ASCII STRINGS
H302 ORA #128 ;SET NOGEN BIT
.BYTE $2C
; SYMBOLS ************
H303 ORA #64 ;SET SYM BIT
.BYTE $2C
; DON'T PRINT SYMBOL TABLE
H304 AND #191 ;CLEAR SYM BIT
.BYTE $2C
; DON'T COUNT OP CODE USAGE
H305 AND #223 ;CLEAR OPCODE CNT
.BYTE $2C
; COUNT OP CODE USAGE
H306 ORA #32 ;SET OPCODE COUNT
.BYTE $2C
; GENERATE ERROR FILE
H307 ORA #16 ;SET ERROR GEN BIT
.BYTE $2C
; DON'T GENERATE ERROR FILE
H308 AND #239 ;CLEAR ERROR GEN
.BYTE $2C
; GENERATE INTERFACE FILE
H309 ORA #8 ;SET INTERFACE FILE
.BYTE $2C
; DON'T GEN INTERFACE FILE
H310 AND #247 ;NO GEN INT FILE
.BYTE $2C
; DON'T SUPPRESS PRINT FILE
H311 ORA #4 ;SET LIST
.BYTE $2C
; SUPPRESS PRINT FILE
H312 AND #251 ;TURN OFF PRT FILE
H390 STA IFLAGS ;ALL DONE WITH THIS PARM
H391 JSR NFNCMP ;LOOK FOR COMMA & START AGAIN
BCS H8840 ;COMMA OR RIGHT PAREN
JMP H990 ;NONE FOUND
H8840 LDA ICRD,X ;ICRD(ICOLP)
CMP #',' ;A COMMA?
BEQ H8839 ;YES,
JMP H990 ;NO,
H8839 INX
STX ICOLP
JMP H301
; SKIP ***
H26 JSR NFNDNB ;NEXT NON-BLANK
BCS H8808 ;NON-BLANK FOUND
LDX J
H8808 LDA #204
LDY #0
JMP LTS1
; PAGE ***
; HAS A TITLE WITH IT?
H12 JSR NFNDNB ;NEXT NONBLANK
BCC H8807 ;ONLY BLANKS FOUND
LDA ICRD,X ;NEXT TITLE CHAR
CMP #$27 ;A QUOTE?
BEQ H600 ;YES
H8807 LDX #0
H600 LDA #203
LDY #0
JMP LTS1
; END ***
H10 BIT SFILE ;WHAT IS DONE?
BVS ENLIB ;A LIBRARY ROUTINE...
LDX #$FF ;A SOURCE FILE...
TXS
LDX PASS ;WHICH PASS ON SOURCE?
BEQ DEND2 ;PASS1...
CPX #2
BEQ DEND0
INC PASS
;
; ***** COMPLETION OF PASS 2 *****
;
DEND0 BIT SFILE
BPL DEND1
LDA #2 ;LOGICAL FILE #2
JSR CLOSE ;IS SOURCE TO CLOSE
DEND1 LDX #0
TXA
TAY
; INC LBOTH
JSR LTINS ;PRINT THE .END
; DEC LBOTH
JMP PASS3 ;THEN SORT & PRT SYMS
;
; ***** END OF PASS 1 *****
;
DEND2 INC PASS
BIT SFILE
BPL DEND2A
LDA #2
JSR CLOSE
DEND2A JMP PASS2
ENLIB LDA #3 ;CLOSE LIBRARY FILE
JSR CLOSE
LDA SFILE
AND #$BF ;SWITCH CONTROL
STA SFILE
ENDR LDX #0
STX CHAN
LDY #0
LDA #205
INC LBOTH
JSR LTINS
DEC LBOTH
LDA #$0D
STA LCHAR
JMP ENDLN
; FILE ***
HFIL LDA #2 ;CLOSE OLD FILE
JSR CLOSE
JSR NFILE ;PARSE NEW FILE
LDA #2
STA LA ;LOGICAL ADDRESS
STA SA ;SECONDARY ADDRESS
LDA #8
STA FA ;DEVICE NUMBER
JSR OPEN
JSR FTEST
JMP ENDR
; COMMON PARSE ROUTINE
NFILE JSR NFNDNB ;FIND STT OF NAM
BCC NFIL1 ;NO NAME
LDY #0
NFIL3 LDA ICRD,X
CMP #$20
BEQ NFIL4
STA ISYM,Y
CPX IMAXCL
BEQ NFIL4
INY
INX
CPY #14
BNE NFIL3
BEQ NFIL1
NFIL4 LDA #$0D
INY
STY FNLEN
STA LCHAR
BNE NFIL2
NFIL1 LDA #>FNERR
LDY #<FNERR
JSR WSCRN
JMP DONE
NFIL2 LDX FNLEN ;ADD FILE TYPE
LDA #','
STA ISYM,X
INX
LDA #'S'
STA ISYM,X
INX
STX FNLEN
LDA #>ISYM ;SET UP NAME CALL
STA FNADR+1
LDA #<ISYM
STA FNADR
RTS
; LIB ***
HLIB BIT SFILE
BVC DLIB1 ;NOT ALREADY IN .LIB
LDA #>LIBERR
LDY #<LIBERR
JSR WSCRN
JMP DONE
DLIB1 JSR NFILE ;PARSE PARMS
LDA #3
STA LA
STA SA
LDA #8
STA FA
JSR OPEN
JSR FTEST
LDA #$40
ORA SFILE
STA SFILE ;FLAG IN .LIB
JMP ENDR
.END

385
ASSEMBLER_PET_REC/eval

@ -0,0 +1,385 @@
.PAGE 'EVAL'
; TEST A CHAR TO SEE IF ALPHABETIC
; CARRY SET IF ALPHABETIC, CARRY CLEAR IF NOT ALPHABETIC
; REG X CONTAINS INDEX INTO ICRD
NALPH LDA ICRD,X ;CHAR TO TEST
CMP #'A'
BCC J30 ;LESS THAN ALPHABET
CMP #$5B ;'Z' + 1
BCC J40 ;IN ALPHABET RANGE
BCS J30
; TESTS A CHAR TO SEE IF NUMERIC
; CARRY SET IF NUMERIC, CARRY CLEAR IF NOT NUMERIC
; REG X CONTAINS INDEX INTO ICRD
NUMRC LDA ICRD,X ;CHAR TO TEST
CMP #'0'
BCC J30 ;LESS THAN NUMBERS
CMP #':' ;'9' + 1
BCC J40
BCS J30 ;NOT NUMERIC
; *********************************
; * CONSTRUCTS A SYMBOL
; * NON-ALPHABETIC CAUSES CARRY CLR
; * OTHERWISE CARRY SET .X IS INDEX
; *********************************
CONSYM LDY #$FF ;Y IS A COUNTER
C10 INY
CPY #5 ;MAXIMUM SYMBOL LENGTH
BEQ C12
BCS NUMR2 ;SUCESSFUL CONSTRUCT (CARRY IS SET)
C12 CPY KLEN ;ALL CHARS TO SYM?
BCC C14
BCS C30 ;YES...FILL IN BLANKS
C14 JSR NALPH ;CHAR ALPHABETIC
BCS C20 ;YES...
JSR NUMRC ;IS IT A NUMBER
BCS C20 ;YES-(CARRY IS SET) (ALPHA)
RTS
NUMR2 SEC
RTS
C20 LDA ICRD,X ;NEXT CHAR OF SYM
STA ISYM,Y
INX ;NEXT COLUMN OF SOURCE
JMP C10
C30 LDA #$20 ;FILL IN WITH BLANKS
STA ISYM,Y
JMP C10 ;ALWAYS
.PAGE
; **********************************************************************
;
; EVALUATES AN EXPRESSION
;
; REG X CONTAINS INDEX TO START OF EXPRESSION TO BE EVALUATED.
; UPON RTN FROM ROUTINE X CONTAINS POINTER TO FIRST CHARACTER
; BEYOND END, OR ON ERROR RETURN, CONTAINS POINTER TO BAD PORTION.
;
; RETURN SET AS FOLLOWS:
;
; 0 -- STRING COULD BE EVALUATED (IEXP = VALUE OF THE STRING)
; 1 -- UNDEFINED SYMBOL
; 2 -- EXPRESSION IS BAD
;
; **********************************************************************
EVAL LDA #0 ;INIT EXPRESSION
STA IEXP
STA IEXP+1
LDA #$FE ;IEXP & KNVAL TO PLUS
AND IFLAGS+1
STA IFLAGS+1
CPX IMAXCL ;BEYOND CARD?
BEQ D10 ;NO...
BCC D10 ;NO....
JD300 JMP D300 ;NULL STRING
D10 JSR ENDTST ;END OF EXPR?
BCS JD300 ;YES-NULL STRING
;
; GET INITIAL OPERATION
;
D11 LDY #'+'
CMP #'-' ;UNARY MINUS?
BNE D15 ;NO
LDY #'-'
INX
D15 STY KOP ;SAVE OPER
CPX IMAXCL ;END OF CARD
BEQ D20 ;NO
BCS JD300 ;YES-UNINTERPRETABLE
;
; SEARCH FOR '<' & '>' FLAG
;
D20 LDA #0 ;INITIALIZE
STA KLOW ;<> FLAGS
STA KHIGH
JSR ENDTST ;END OF EXPRESSION?
BCS JD300 ;UNINTERPRETABLE
D21 CMP #'<' ;LOWER BYTE
BNE D150
INC KLOW
JMP D151
D150 CMP #'>' ;HIGHER BYTE
BNE D158
INC KHIGH
D151 INX
CPX IMAXCL
BEQ D158
BCS JD300
;
; CONSTANT NUMBER ?
;
D158 JSR NUMRC ;CHAR NUMERIC
BCC D25 ;NO...NOT BASE 10
LDY #10 ;BASE 10
JMP D55 ;EVALUATE THE NUMBER
D25 CMP #'$' ;HEX?
BNE D30 ;NO...NOT BASE 16
LDY #16 ;BASE 16
JMP D50 ;GET NEXT CHAR
D30 CMP #'@' ;OCTAL?
BNE D35 ;NO...NOT BASE 8
LDY #8 ;BASE 8
JMP D50 ;GET NEXT CHAR
D35 CMP #'%' ;BINARY?
BNE D40 ;NO...NOT BASE 2
LDY #2 ;BASE 2
BNE D50
;
; SYMBOLS ?
;
D40 JSR NALPH ;ALPHABETIC?
BCC D46 ;NO...MAYBE ASSEM CNTER
; PROCESS A SYMBOL
TXA ;LOOKS LIKE A SYMBOL
TAY
D41 INX ;FIND LENGTH OF SYMBOL
CPX IMAXCL ;OFF END OF CARD
BEQ D415 ;NO
BCS D42 ;YES-COMPUTE LENGTH
D415 JSR NUMRC ;CHAR NUMERIC?
BCS D41 ;YES...CONTINUE
JSR NALPH ;CHARACTER ALPHA?
BCS D41 ;YES...CONTINUE
D42 STY TEMP ;END..COMPUTE LENGTH
TXA ;GET ENDING COLUMN
SEC
SBC TEMP ;STARTING COLUMN
CMP #7 ;LENGTH OVER 6 CHARS?
BCC D43 ;NO...CONTINUE
J2D300 JMP D300 ;YES-UNINT
D43 STA KLEN ;LENGTH OF SYM
LDX TEMP
JSR CONSYM ;CONSTRUCT SYMBOL
BCC J2D300 ;BAD SYMBOL
D44 STX TEMP+1
JSR NFIND
LDX TEMP+1
BCS D60
LDX TEMP
JMP D200
; EVALUATE '*' ASSEMBLY COUNTER
D46 CMP #'*'
BNE J2D300 ;NO-BAD EXPRESSION
D47 LDA IPC
STA KNVAL+1
LDA IPC+1
STA KNVAL
INX
JMP D60
;
; EVALUATE NUMERIC FIELD
;
D50 INX
CPX IMAXCL ;END OF CARD?
BEQ D51 ;NO...CONTINUE
BCS J2D300 ;YES...BAD EXPRESSION
D51 JSR NUMRC ;CHAR NUMERIC?
BCS D55 ;YES...CONTINUE
JSR NALPH ;CHAR ALPHA?
BCC J2D300 ;NO...BAD EXPRESSION
D55 STY KBASE ;BASE OF OPERATION
; GET LENGTH OF NUMBER
TXA ;STARTING COLUMN
TAY
D56 INX ;NEXT CHARACTER
CPX IMAXCL ;END OF CARD?
BEQ D565 ;NO...
BPL D57 ;YES...
D565 JSR NUMRC ;CHAR NUMERIC?
BCS D56 ;YES...GET NEXT CHAR
JSR NALPH ;NO...IS CHAR ALPHA?
BCS D56 ;YES...GET NEXT CHAR
D57 STY TEMP ;COMPUTE LENGTH
TXA ;GET ENDING COLUMN
SEC
SBC TEMP ;STARTING COLUMN
STA KLEN ;LENGTH OF NUMBER
TYA ;COMPUTE THE VALUE
TAX
JSR NUMBER ;COMPUTE NUMBER
BCS D60 ;SUCCESSFUL CONVERSION
JMP D300 ;COULDN'T COMPUTE
;
; DO THE OPERATION
;
D60 LDA KLOW
BEQ XXXT
LDA #0
STA KNVAL
BEQ XXXU
XXXT LDA KHIGH
BEQ XXXU
LDA KNVAL
STA KNVAL+1
LDA #0
STA KNVAL
XXXU LDA KOP ;GET THE OPERATION
CMP #'+' ;AN ADD?
BNE D65 ;NO...
;
; '+' = ADDITION
;
LDA IEXP+1 ;LOW BYTE OF EXPR
CLC
ADC KNVAL+1 ;LOW BYTE OF NUMBER
STA IEXP+1
LDA IEXP
ADC KNVAL ;HI BYTE OF NUMBER
STA IEXP
LDA #0
ROL A
TAY
LDA #1
AND IFLAGS+1
ASL A
STA TEMP
LDA #2
AND IFLAGS+1
EOR TEMP
BNE XXXV
TYA
BEQ XXXW
LDA #8
ORA IFLAGS+1
STA IFLAGS+1
BNE XXXW
XXXV TYA
BEQ XXXW2
LDA #$FE
AND IFLAGS+1
STA IFLAGS+1
XXXW JMP D70
XXXW2 LDA #1
ORA IFLAGS+1
STA IFLAGS+1
JMP D70 ;CONTINUE
D65 CMP #'-' ;A SUBTRACT
BNE D80
;
; '-' = SUBTRACTION
;
LDA IEXP+1 ;GET LOW BYTE
SEC
SBC KNVAL+1 ;LOW BYTE
STA IEXP+1
LDA IEXP ;HIGH BYTE
SBC KNVAL ;HIGH BYTE
STA IEXP
LDA #0
ROL A
TAY
LDA #1
AND IFLAGS+1
ASL A
STA TEMP
LDA #2
AND IFLAGS+1
EOR TEMP
BNE XXXX
TYA
BEQ XXXY
LDA #-1+255
AND IFLAGS+1
STA IFLAGS+1
JMP D70
XXXY LDA #1
ORA IFLAGS+1
STA IFLAGS+1
JMP D70
XXXX STY TEMP
LDA #1
AND IFLAGS+1
EOR TEMP
BEQ D70
LDA #8
ORA IFLAGS+1
STA IFLAGS+1
; END OF OPERATION. DO END CHECK & IF END THEN DO '<' & '>'
D70 CPX IMAXCL ;START NEXT FIELD
BEQ D71 ;NOT END OF CARD
BPL D100 ;YES-END OF CARD
D71 JSR ENDTST ;END EXPRESSION?
BCS D100 ;YES-BAD
LDY ICRD,X ;(OPERATION)
INX
JMP D15
;
; OPERATION CONTINUED
;
D80 JMP D300
;--- EVALUATE END ---
;
; RETURNS - SET CODE AND RETURN
D100 LDA #0 ;GOOD RETURN
.BYTE $2C
D200 LDA #1 ;UNDEFINED SYMBOL
.BYTE $2C
D300 LDA #2 ;BAD EXPR
STA RETURN
RTS
; TEST FOR THE END OF A STRING (FINDS BLANK, COMMA, RIGHT PAREN)
; CARRY SET IF FOUND, CARRY CLEAR IF NONE FOUND
; X POINTS TO CHAR IN ICRD
ENDTST LDA ICRD,X
CMP #$20
BEQ DD10
CMP #','
BEQ DD10
CMP #')'
BEQ DD10
CMP #';'
BEQ DD10
CLC ;CHARACTERS NOT FOUND
DD10 RTS
.END

508
ASSEMBLER_PET_REC/main

@ -0,0 +1,508 @@
.PAGE 'MAIN'
PASS1 LDA #0
LDX #STKVAL
TXS
CLD
STX NOBJ
STA NOPRIN
STA LBOTH ;LIST ONLY TO PRINTER
STA CHAN
STA PASS ;SET PASS 1
STA SFILE
STA NOSYM
STA NOSYM+1
STA IFLAGS+1
LDY #>L2FFF
LDX #<L2FFF
STX L027A
STY L027A+1
LDY #>SYTBST ;START OF SYMTBL
LDX #<SYTBST
STX STSAVE
STY STSAVE+1
LDY SYTBND+1
LDX SYTBND
STX ISYEND
STY ISYEND+1
JSR RESET
LDA #5 ;OPEN KEYBOARD FILE #5
STA LA
LDA #0
STA SA
STA FA
STA FNLEN
JSR OPEN
LDA #0
STA FNLEN
STA SA
LDA #1 ;OPEN DISPLAY FILE #1
STA LA
LDA #3
STA FA
JSR OPEN
XXXA2 LDA #>STTMSG
LDY #<STTMSG
JSR WSCRN
JSR CLRCH
LDX #5
STX CHAN
JSR CHKIN
LDX #40
STX SAVEX
XXXA3 DEC SAVEX
BEQ XXXA2
JSR BASIN
CMP #' '
BEQ XXXA3
CMP #$0D
BEQ XXXA4
LDX #0
STX NOBJ
STX OBJLEN
BEQ XXXA6
XXXA8 JSR BASIN
CMP #' '
BEQ XXXA7
XXXA6 CMP #$0D
BEQ XXXA7
LDX OBJLEN
CPX #14
BEQ XXXA2
STA OBJFIL,X
INX
STX OBJLEN
JMP XXXA8
XXXA7 LDA #','
STA OBJFIL,X
INX
LDA #'S'
STA OBJFIL,X
INX
LDA #','
STA OBJFIL,X
INX
LDA #'W'
STA OBJFIL,X
INX
STX OBJLEN
XXXA4 LDA #>HCMSG
LDY #<HCMSG
JSR WSCRN
JSR BASIN
CMP #'N'
BNE RDOPNX
STA NOPRIN
RDOPNX LDA #>SRCMSG
LDY #<SRCMSG
JSR WSCRN
JSR CLRCH
LDX #5
STX CHAN
JSR CHKIN
LDX #40
STX SAVEX
XXXB4 DEC SAVEX
BEQ XXXA4
JSR BASIN
CMP #' '
BEQ XXXB4
CMP #$0D
BEQ L0553
PHA
JSR OPNSB1
PLA
LDX #0
STX FNLEN
BEQ XXXB6
XXXB8 JSR BASIN
CMP #' '
BEQ XXXB7
XXXB6 CMP #$0D
BEQ XXXB7
LDX FNLEN
CPX #14
BEQ XXXA4
STA ISRC,X
INX
STX FNLEN
STX ISRCLN
JMP XXXB8
XXXB7 LDA #',' ;PUT A COMMA AFTER THE NAME
STA ISRC,X
INX
LDA #'S' ;FOR THE AUTO OBJECT NAME FEATURE
STA ISRC,X
INX
STX FNLEN
STX ISRCLN
; ****************
; * PASS 1 START
; ****************
LDA #>CRMSG
LDY #<CRMSG
JSR WSCRN
JSR SOPEN ;OPEN SOURCE FILE
JMP L055B
L0553 LDA NOBJ
BNE L055B
JSR OPNSB1
L055B LDA #>P1MSG ;'PASS 1'
LDY #<P1MSG
JSR WSCRN
JMP SNEWLN ;BEGIN ASSEMBLY
; *******************************
; * OPEN DISK COMMAND CHANNEL
; *******************************
OPNSB1 LDA #7
STA LA
LDA #2
STA FNLEN
LDA #8
STA FA
LDA #15
STA SA
LDA #'I'
STA ISYM
LDA #'0'
STA ISYM+1
LDA #>ISYM
STA FNADR+1
LDA #<ISYM
STA FNADR
JSR OPEN
LDA #7
JSR CLOSE
LDA #'1'
STA ISYM+1
JMP OPEN ;OPEN COMMAND CHANNEL & SEND I
; ********************
; * OPEN SOURCE FILE
; ********************
SOPEN LDA #8 ;OPEN SOURCE FILE
STA FA
LDA #2
STA LA
STA SA
LDA #>ISRC
STA FNADR+1
LDA #<ISRC
STA FNADR
LDA ISRCLN
STA FNLEN
JSR OPEN ;OPEN SOURCE FILE
JSR FTEST
LDA #$80
STA SFILE
RTS
; ********************
; * PASS2
; ********************
PASS2 JSR RESET
JSR OBJINT
LDA #>P2MSG
LDY #<P2MSG
JSR WSCRN ;OPEN OBJECT FILE
LDA NOBJ
BNE PASS2B
LDA OBJLEN
STA FNLEN
LDA #>OBJFIL
STA FNADR+1
LDA #<OBJFIL
STA FNADR
LDA #6
STA LA
STA SA
LDA #8
STA FA
JSR OPEN ;OPEN OBJECT FILE
JSR FTEST
PASS2B LDA NOPRIN
BNE CLRTTL
LDA #4
STA LA
STA FA
LDA #0
STA SA
STA FNLEN
JSR OPEN
CLRTTL LDY #19
LDA #$20
PASS2H STA LTLBUF,Y
DEY
BPL PASS2H
BIT SFILE
BPL L0620
JSR SOPEN
LDX ISRCLN ;DON'T OUTPUT THE DRIVE #
DEX
DEX
STX LTLLEN
PASS2D LDA CHAN,X
STA LTLBUF-1,X
DEX
BNE PASS2D
L0620 JSR PTTTL0
JMP SNEWLN
RESET LDA #0
STA IPC
STA IPC+1
STA ICRDNO
STA ICRDNO+1
LDY #>L2000
STY L56+1
LDX #<L2000
STX L56
STA LTLLEN
STA LERCT
STA JOPTYP
LDA #1
STA LPGCT
LDA #$0D
STA LCHAR ;MAKES CLEAN START
LDA #%11011100; NOG,NOS,NOE,INT,LIS
STA IFLAGS
RTS
WSCRN PHA ;WRITE TO PET SCREEN
LDA #1
CMP CHAN
BEQ WSCRN1
TYA
PHA
JSR CLRCH
LDX #1
STX CHAN
JSR CKOUT
PLA
TAY
WSCRN1 PLA
STA TBLPTR+1
STY TBLPTR
LDY #0
WSCRN2 LDA (TBLPTR),Y
INY
PHA
AND #$7F
JSR BSOUT
PLA
BPL WSCRN2
RTS
; ************************
; *
; * -- SCAN NEW LINES --
; * MAIN LOGIC OF
; * PASS 1 & PASS 2
; *
; ************************
SNEWLN JSR CHKBRK
LDA #0 ;INIT NEXT CARD
STA LCDPT
STA IFLAGS+1
STA ICSB
STA ICSE
STA IERR
STA IMAXCL
STA ICSL
STA IEXP
STA IEXP+1
STA ILSST
STA JLABL
STA JORG
STA JBYWOR
STA ICOLP
LDA LCHAR
BEQ H8921
LDX #0
INC ICRDNO+1
BNE CARD1
INC ICRDNO
CARD1 JSR GETCHR ;INPUT A CHAR
CMP #$0D
BEQ CARD3 ;BRANCH IF A C.R.
CMP #$00 ;IS IT NULL
BNE CARD2
H8921 JMP H10
CARD2 STA ICRD,X
INX
JMP CARD1
CARD3 DEX
STX IMAXCL
;
; MAIN LINE BLOCK
;
H87 JSR NFNDNB ;BLANK CARD?
BCC H8830B ;YES
LDX ICOLP
LDA ICRD,X
CMP #';' ;IF TERMINATOR CARD
BNE H8830A
H8830B JMP H990
H8830A JSR NFNDEN ;FIND STRING END
BCS H1 ;END FOUND
LDA #3 ;ERROR--END NOT FOUND
LDX ICSB
TAY
JMP LTS1
H1 LDX ICSB
LDA ICRD,X
CMP #'.'
BNE H8841 ;NOT ASSEM DIRECT
JMP H5 ;AN ASSEM DIRECT
H8841 CMP #'*'
BNE H8832 ;NOT AN ORG
JMP H102 ;REDEFINE ORG
H8832 LDY ICSL
CPY #6 ;6 CHARACTERS LONG
BEQ H76 ;<=
BCC H76
LDA #9
LDY #3
JMP LTS1
H76 STY KLEN ;LENGTH OF SYMBOL
JSR CONSYM ;CONSTRUCT THE SYMBOL
BCS H3 ;NO ERRORS IN CONSYM
LDA #$10
LDY #3
JMP LTS1
H3 LDA ICSL ;LENGTH OF STRING
CMP #3 ;RIGHT LENGTH FOR LABEL
BNE H92 ;LABEL PROCESS-OVER 3
JSR NOPFND ;FIND A MNEMONIC
BCC H92 ;FAILED-MUST BE A LABEL
JMP H201 ;AN OP CODE
; ************************
; * LABEL PROCESSING
; ************************
H92 LDA JLABL
BEQ H94
LDA #$03
TAY
LDX ICSB
JMP LTS1
H94 LDA #1
STA JLABL
LDX ICOLP
JSR NALPH
BCS H91 ;NO
LDA #$08
LDY #$03
JMP LTS1
H91 LDA ISYM+1
CMP #' '
BNE H91X
LDA ISYM
CMP #'A'
BEQ L0820
CMP #'X'
BEQ L0820
CMP #'Y'
BEQ L0820
CMP #'S'
BEQ L0820
CMP #'P'
BNE H91X
L0820 LDA #$20
LDY #$03
JMP LTS1
H91X STX ILSST ;SAVE PARMS FOR EQU
LDX #0 ;SAVE THE SYMBOL
H8845 LDA ISYM,X
PHA
INX
CPX #6
BNE H8845
LDA ICSL ;SAVE ICSL
PHA
LDA ICSE
STA ICOLP ;SAVE ICSE
INC ICOLP
JSR NFNDNB ;CHECK FOR EQUATE
BCC H120 ;ONLY BLANKS FOUND
LDA ICRD,X
CMP #'='
BEQ H121
H120 JSR NFIND ;SEE IF GOOD LABEL
BCC H95B ;NOT PRESENT
LDA KNVAL ;IS THE NEW VALUE THE SAME AS THE OLD VALUE ?
CMP IPC+1
BNE MR04 ;NO
LDA KNVAL+1
CMP IPC
BEQ H95A ;OK
MR04 LDA #2 ;PREVIOUSLY DEFINED
LDY #3
LDX ILSST
JMP LTS1
H95B LDA IPC+1 ;PUT IN SYM TAB
STA KNVAL
LDA IPC
STA KNVAL+1
JSR NSERT
H95A LDA IMAXCL ;TRY FOR OPCODE
CMP ICOLP ;OFF CARD CHECK
BCS H8842
JMP H990 ;YES--OFF CARD
H8842 JMP H87 ;BACK TO MAIN SECT
.END

221
ASSEMBLER_PET_REC/numsyms

@ -0,0 +1,221 @@
.PAGE 'NUMSYMS'
; CONVERT BASE 8,10,16 TO BINARY
; CARRY SET IF SUCCESSFUL CONVERSION, CARRY CLEAR IF ERROR.
; X MUST POINT TO CHARACTER
NUMBER LDA #0
STA KNVAL ;VALUE OF NUMBER IS 0
STA KNVAL+1
E10 LDA ICRD,X ;CHARACTER
JSR NUMRC ;SEE IF NUMERIC
BCC E20 ;NOT NUMERIC
SBC #48 ;REMOVE ZONE
JMP E30 ;CHECK FOR VALID BASE
E20 JSR NALPH ;CHAR ALPHABETIC
BCC E40 ;NO...MEANS ERROR
SBC #55 ;ALPHA--REMOVE ZONE
E30 CMP KBASE ;BASE VALID
BCC E50 ;YES...VALID
E40 CLC ;INVALID BASE
RTS
E50 STA COLCNT
TXA
PHA ;PUT POINTER ON STACK
LDY KBASE ;BASE
CPY #2 ;BINARY?
BNE E60 ;NO...
LDX #1 ;BINARY...1 SHIFT
BNE E90
E60 CPY #8 ;OCTAL
BNE E70 ;NO...
LDX #3 ;OCTAL--3 SHIFTS.
BNE E90
E70 CPY #16 ;HEX
BNE E80 ;NO...
LDX #4 ;HEX--4 SHIFTS
BNE E90
E80 CPY #10 ;DECIMAL
BNE E40 ;NO... BASE IS INVALID
LDA KNVAL
STA TEMP
LDA KNVAL+1
STA TEMP+1
LDX #3 ;DECIMAL--3 + 1 SHIFTS
E90 ASL KNVAL+1 ;LOW ORDER BITS
ROL KNVAL ;HIGH ORDER BITS
BCC E100 ;NOT OVERFLOW
LDA IFLAGS+1 ;OVERFLOW BIT
ORA #8
STA IFLAGS+1
E100 DEX ;SHIFT COUNTER
BNE E90 ;CONTINUE
CPY #10 ;DECIMAL
BNE E120 ;NO...
ASL TEMP+1 ;DECIMAL DOES ANOTHER
ROL TEMP
BCC E115 ;DID NOT OVERFLOW
LDA IFLAGS+1 ;SET OVERFLOW
ORA #8
STA IFLAGS+1
E115 LDA KNVAL+1 ;ADD TO FINISH
CLC
ADC TEMP+1
STA KNVAL+1
LDA KNVAL
ADC TEMP
STA KNVAL
BCC E120 ;OVERFLOW?
LDA IFLAGS+1
ORA #8
STA IFLAGS+1
E120 LDA COLCNT
CLC
ADC KNVAL+1
STA KNVAL+1
BCC E130
INC KNVAL
BNE E130 ;NO OVERFLOW
LDA IFLAGS+1
ORA #8
STA IFLAGS+1
E130 PLA
TAX
INX
DEC KLEN ;LENGTH OF NUMBER
BEQ E140 ;DONE
JMP E10
E140 SEC ;SUCCESS
RTS
; SEARCH SYM TAB FOR CURRENT SYM. SEARCH IS LINEAR.
; CARRY SET IF FOUND. CARRY CLEAR IF NOT FOUND.
NFIND
L13C7 LDA STSAVE
STA SYMTBL
LDA STSAVE+1
STA SYMTBL+1
LDA #0
STA TOPPNT+1
STA TOPPNT
L13D5 SEC
LDA TOPPNT+1
SBC NOSYM+1
LDA TOPPNT
SBC NOSYM
BCS L13FC
LDY #5
L13E4 LDA ISYM,Y
CMP (SYMTBL),Y
BNE L13FE
DEY
BPL L13E4
LDY #6
LDA (SYMTBL),Y
STA KNVAL
INY
LDA (SYMTBL),Y
STA KNVAL+1
RTS
L13FC CLC
RTS
L13FE LDA SYMTBL
CLC
ADC #8
STA SYMTBL
BCC L1409
INC SYMTBL+1
L1409 INC TOPPNT+1
BNE L13D5
INC TOPPNT
JMP L13D5
NSERT SEC
LDA SYMTBL
SBC ISYEND
LDA SYMTBL+1
SBC ISYEND+1
BCS G110
XXXD2 LDY #5 ;PUT SYM INTO TABLE
G100 LDA ISYM,Y ;SOURCE
STA (SYMTBL),Y ;DESTINATION
DEY
BPL G100 ;NOT DONE
;
; SYMBOL IS IN TABLE- DEFINE
;
LDY #6
LDA KNVAL
STA (SYMTBL),Y
INY
LDA KNVAL+1
STA (SYMTBL),Y
INC NOSYM+1
BNE G101
INC NOSYM
G101 RTS
;
; OVERFLOWED SYMBOL TABLE
;
G110 LDA #>STOERR
LDY #<STOERR
JSR WSCRN
JMP DONE
; SEARCH OPCODE TAB FOR OPCODE
; CARRY SET IF OPCODE FOUND, CARRY CLEAR IF OPCODE NOT FOUND.
NOPFND LDA #<OPRNDS
STA PNT1
LDA #>OPRNDS
STA PNT1+1
LDX #0
XXXE3 LDY #2
XXXE2 LDA ISYM,Y
CMP (PNT1),Y
BNE XXXE1
DEY
BPL XXXE2
LDA KTMPL,X ;TEMPLATE
STA JOPTEM
LDA KCODE,X ;BASE OPCODE
STA JOPBAS
RTS
;
; NO MATCH
;
XXXE1 LDA PNT1
CLC
ADC #3
STA PNT1
BCC XXXE4
INC PNT1+1
XXXE4 INX
CPX #57
BMI XXXE3
SBNO CLC ;OPCODE NOT FOUND
RTS
.END

616
ASSEMBLER_PET_REC/operand

@ -0,0 +1,616 @@
.PAGE 'OPERAND'
; OPERAND PROCESSING *****
; PROCESSES NORMAL OPERANDS & DETERMINES IF THEY ARE VALID.
H201 LDY #0
STY JOPTYP ;OPERAND TYPE
STY JOPLEN ;BYTES TO GENERATE
STY JNOPV ;OPERAND VALUE FLAG
; CHECK FOR IMPLIED OPERAND
LDA JOPTEM ;OPCODE TEMPLATE
CMP #20 ;IMPLIED OPERAND
BNE H17 ;SKIP TO NEXT SECT
; GENERATE OPCODE FOR IMPLIED AND ACCUMULATOR MODES
H459 LDY #0 ;INSERT IN OP POSIT
LDA JOPBAS ;OP IS BASE OPCODE
JSR OBJOUT ;PUT IN MEMORY MAP
LDX #0 ;GET ERROR COL
LDY #1 ;NUM OF BYTES
TXA
JMP LTS1
; NEED OPERAND - CHECK BRANCH FIRST
H17 CMP #21 ;BRANCH TEMPLATE
BNE H9960 ;NO
LDA #14
STA JOPTEM
LDA #7 ;ERROR CODE
STA IERR
H9960 LDA ICSE ;PNTR TO LAST CHAR
STA ICOLP
INC ICOLP ;NEXT CHAR
JSR NFNDNB ;FIND START OF OPERND
BCS H9917
LDA #$18
STA IERR
JMP H99 ;ERROR--NO OPERAND
; PROCESS OPERAND FIELD
H9917 LDA ICRD,X ;FIRST CHAR
CMP #';' ;SEE IF COMMENT FIELD
BNE H9934
JMP H900 ;ERROR-NO OPERAND
; AN OPERAND-CHECK .A MODE FIRST
H9934 CMP #'A'
BNE H39 ;NOT ACCUMULATOR MODE
CPX IMAXCL ;SEE IF OFF END
BEQ H9965
LDY ICRD+1,X ;AFTER THE 'A'
CPY #' ' ;MUST BE BLANK
BNE H39 ;NOT .A MODE
H9965 LDY JOPTEM ;.A MODE - PROCESS
LDA KLTBL-1,Y
BMI H458 ;.A MODE NOT VALID
CLC
ADC JOPBAS ;COMPUTE REAL OPCODE
STA JOPBAS
JMP H459 ;DONE WITH THIS OPCODE
; .A MODE NOT ALLOWED- ERROR
H458 LDX ICSB ;ERROR COLUMN
LDY #3 ;NUMBER OF BYTES TO SAVE
LDA #5 ;ERROR CODE
JMP LTS1
H39 CMP #'#' ;CHECK FOR IMMEDIATE MODE
BNE H24 ;NOT IMMEDIATE
LDA #10 ;OPCODE TYPE
JMP H831
H24 CMP #'(' ;CHECK FOR INDIRECT MODE
BNE H23 ;NOT INDIRECT
LDA #5 ;SET OPTYPE
; DONE CHECKING OBVIOUS ADDR MODES. GET READY TO EVALUATE OPERAND.
H831 STA JOPTYP
INX
INC ICSB
CPX IMAXCL ;RAN OFF END CARD?
BEQ H23 ;NO
BCC H23
JMP H99 ;RAN OFF END
H23 JSR EVAL ;EVAL THE OPERAND
STX JERCOL ;ERROR COL FROM EVAL
LDA #$13 ;BAD EXPRESSION
STA IERR ;PRELOAD FOR LATER
DEC RETURN ;0,1 OR 2 FROM EVAL
BMI H20 ;GOOD RETURN (0)
BEQ H202 ;UNDEFINED SYMBOL (1)
;UNINTERP EXPR (2)
LDA JOPTYP ;MIGHT BE SINGLE ASCII IN #
CMP #10 ;SEE IF # MODE
BEQ H9935 ;YES
JMP H995 ;NO--(BAD EXPRESSION)
; IMMIDIATE ASCII OPERATION
H9935 LDA ICRD,X
CMP #$27 ;APPOSTROPHE
BEQ H9936
JMP H980 ;ERROR
H9936 TXA
TAY
INX
CPX IMAXCL ;OFF END OF CARD?
BEQ H457 ;NO
BCC H457
JMP H99 ;YES--ERROR
H457 LDA ICRD,X
CMP #$20
BCC XXXF1
CMP #$60
BCC XXXF2
XXXF1 LDA #0
XXXF2 STA IEXP+1
INX
CPX IMAXCL ;OFF END OF CARD?
BEQ H9923 ;NO
BCS H20 ;YES-FINISH PROCESS
H9923 LDA ICRD,X
CMP #$20 ;MUST BE BLANK
BEQ H20 ;OK
CMP #$27 ;APPOSTROPHE
BEQ H20 ;YES--VALID OPERAND
TYA ;ASCII STRING INVALID
TAX
LDY #3 ;NUMBER OF BYTES
LDA IERR ;ERROR CODE
JMP LTS1
.PAGE
; 1 - OPERAND HAS NO VALUE
H202 INC JNOPV ;NO OPERAND VAL
LDA #2 ;ASSUMED LENGTH
STA JOPLEN ;OPERAND LENGTH
; 0 - GOOD RETURN. INDEX REGISTER CHECK.
H20 JSR NFNCMP ;COMMA OR PAREN
BCC H500 ;NO INDEXING
LDA ICRD,X ;GET CHARACTER
CMP #')'
BNE H51 ;NO
INC JOPTYP ;RIGHT PAREN - ADD TO OPTYPE
INC JOPTYP
LDA JOPBAS ;JUMP INSTR. TEST
CMP #$4C ;JUMP INSTR
BEQ H140 ;YES
; DONE WITH PAREN - NEXT CHAR
INX ;POINT TO NEXT
CPX IMAXCL ;RAN OFF END
BEQ H51 ;NO
BCC H51
JMP H99 ;YES - FLAG AS ERROR
H51 LDA ICRD,X ;CHECK FOR COMMA - INDEXING
CMP #','
BNE H203 ;NO - COULD BE Y
; HAS A COMMA. CHECK FOR JUMP AGAIN.
LDA JOPBAS ;BASE OPCODE
CMP #$4C ;A JUMP
BEQ H142 ;YES-ERROR-NOT ALLOWED
; DONE WITH COMMA - LOOK FOR INDEX.
INX ;POINT TO NEXT CHARACTER
CPX IMAXCL ;OFF END OF CARD?
BEQ H203 ;NO
BCC H203
JMP H99 ;YES - FLAG AS ERROR
H203 LDA ICRD,X ;CHECK FOR INDEX REGISTER X
CMP #'X'
BNE H25 ;NO
INC JOPTYP ;AN X-ADD 1 TO OPTYPE
JMP H40
H25 CMP #'Y' ;CHECK FOR INDEX REG Y
BEQ H27 ;YES
LDY #3 ;INVALID INDEX REG - FLAG
LDA #$12 ;ERROR CODE
JMP LTS1
H27 INC JOPTYP ;INDEX REG Y-ADD 2 TO OPTYPE
INC JOPTYP
BNE H40
H500 LDA JOPBAS ;IF A JUMP INSTRUCTION CHECK
CMP #$4C
BNE H40 ;NOT A JUMP
; A JUMP-SEE IF OPTYPE IS VALID
; ONLY 2 TYPE OPERANDS ALLOWED: TYPE 0 IS ABS, 7 IS IND
H140 LDA JOPTYP
BEQ H145 ;TYPE 0...O.K.
CMP #7
BEQ H501 ;TYPE 7...O.K.
; INVALID OPER FOR JMP - FLAG
H142 LDA #$18 ;ERROR CODE
STA IERR
JMP H980 ;PUT IN LENGTH TAB
H501 INX ;GOOD OPTYPE- MAKE SURE NO MORE
CPX IMAXCL ;OFF END OF CARD?
BMI H9924 ;NO
BCS H145 ;YES
H9924 LDA ICRD,X
CMP #' '
BNE H142 ;NO-BAD JUMP
H145 LDA JOPTYP ;GOOD JUMP-INCR TO BASE OPCODE
BNE H9925 ;OPTYPE IS A 7
JMP H9926 ;FINISH JUMP
H9925 LDA #32 ;TYPE 7-ADD TO BASE
; END OF JUMP PROCESSING
H9926 LDY #2 ;LENGTH OF OPERAND
STY JOPLEN
JMP H46 ;FINISH LINE PROCESS
; OPERAND PROCESSED. SEE IF OPERAND VALID FOR OPCODE.
H40 LDA JNOPV ;OPERAND VALUE?
BEQ *+5
JMP H41 ;NO-ASSUME EXTENDED
; HAVE OPERAND VALUE - CHECK REL
LDA JOPTEM ;OPCODE TEMPLATE
CMP #14 ;RELATIVE ADDRESS
BNE H22 ;NOT RELATIVE
CLC ;RELATIVE ADR- CHK VALIDITY. ADJUST EXPR TO GET REL ADR
LDA IPC
ADC #2
STA TEMP+1
LDA IPC+1
ADC #0
STA TEMP
LDA IEXP+1 ;LOW BYTE OF EXPR
SEC
SBC TEMP+1
STA IEXP+1
TAY ;FOR LATER
LDA IEXP ;HIGH BYTE OF EXPR
SBC TEMP
STA IEXP
; TEST EXPR FOR BRANCH TOO FAR
; IF SIGN BITS SAME THEN O.K.
; LOW BYTE IEXP TESTED.
; BRANCH ATTEMPTED TO GO TOO FAR
BPL H9927 ;HIGH BYTE +
TYA ;HIGH BYTE NEG CHECK LO BYT
BMI H28 ;BOTH NEG-EXPR OK
BPL H9929 ;DIFFER SIGNS-BAD
H9927 TYA ;HI BYTE POS-CHECK LO
BPL H28 ;BOTH POS-EXPR OK
; BAD REL-FLAG AS ERROR
H9929 LDA #$17 ;BRANCH ERROR
STA IERR ;SAVE IN IERR
H28 LDA IEXP ;GOOD RELATIVE-OPLENGTH AT 2
BEQ H400
CMP #255
BEQ H285
LDA #$17
STA IERR
H285 LDA #0
STA IEXP
BEQ H400
; CHECK INDIRECT ADDRESS ERROR
; ERROR INDICATED BY EXPR OVER 254
; OR OPTYPE >= 6 AND <= 9
H22 LDA JOPTYP
CMP #6
BCC H400 ;NO
CMP #9
BEQ H9928 ;YES
BCS H400 ;NOT INDIRECT
H9928 LDA IEXP ;CHECK VAL OF EXPR
BNE H9930 ;ERROR-OVER 255
LDA IEXP+1
CMP #255
BNE H400 ;NO-OK
; ERROR ON INDIRECT
H9930 LDA #$19 ;ERROR CODE
STA IERR
LDA #0
STA IEXP
H400 LDA #2 ;ONE OR TWO BYTE OPERAND
STA JOPLEN
LDA IEXP
BNE H41 ;WE NEED 2 BYTES
; 1 BYTE OPERAND - CHECK IF VALID
LDA #1
STA JOPLEN
LDA JOPTYP
CLC
ADC #2
STA JOPTYP
H50 CMP #13 ;MAX ADDR MODE
BCC H45 ;YES...OPER VALID OPCODE
LDA #$15 ;BAD OPERAND-FLAG
STA IERR ;PAGE ZERO INVALID
JMP H900
H41 LDA JOPTYP ;PROCESS 2 BYTE OPERANDS
CLC
ADC #13
STA JOPTYP
H47 CMP #15 ;OVER 15 COULD BE BAD
BEQ H45 ;GOOD EXTENDED OPERAND
BCS H49 ;BAD-MIGHT BE A PAGE 0
; SEE IF OPERAND IS VALID FOR OPCODE.
H45 TAY ;FIRST SUBSCRIPT
DEY
LDA KLUDG,Y
CLC
ADC JOPTEM ;SECOND SUBSCRIPT
TAY ;OPCODE BASE INCREMENT
LDA KLTBL,Y
BPL H46 ;POS OPERAND TYPE VALID
; OPERAND NOT VALID FIRST TRY. TRY 2 BYTE OPERAND.
H49 LDA JNOPV ;AN OPERAND VALUE
BEQ H48 ;YES
LDA JOPLEN ;NO OPERAND VAL-TRY 1 BYTE INSTR
CMP #2
BEQ H206 ;WAS 2 - TRY AS 1
LDA #$18 ;1 BYTE NOVALUE OPERAND-FLG ERROR
STA IERR ;INVALID OPERAND
JMP H900
H206 LDA #1 ;ABS MODE AS PAGE ZERO MODE
STA JOPLEN
LDA JOPTYP
SEC
SBC #11
STA JOPTYP ;NEW OP TYPE
JMP H50
H48 LDA JOPLEN ;HAD AN OPERAND VALUE
CMP #1 ;1 BYTE LONG
BEQ H207 ;YES...TRY 2 BYTES
LDA #$18 ;OPERAND 2 BYTES - FLAG AS ERROR
STA IERR ;INVALID OPERAND
JMP H900
; PAGE 0 MODE AS ABS
H207 INC JOPLEN ;OP LENGTH TO 2
LDA JOPTYP
CLC
ADC #11
STA JOPTYP
JMP H47
; VALID OPERAND - COMPUTE OPCODE AND PUT IN MEMORY MAP
H46 CLC
ADC JOPBAS ;KLUDGE+BASE OPCODE
LDY #0
JSR OBJOUT
; OPERAND VALUE - ENTER INTO MEMORY MAP
LDA JNOPV ;OPERAND VALUE FLAG
BNE H313 ;NO VALUE
LDY #1 ;AN OPERAND VALUE
LDA IEXP+1 ;LOW BYTE OF EXPR
JSR OBJOUT
LDY #2
LDA JOPLEN
CMP #1 ;IF 1 BYTE THEN DONE
BEQ H9931 ;YES...DONE
LDA IEXP ;2BYT=HI-BYTE TO MEMORY
JSR OBJOUT
; ANY OPERAND ERRORS
H9931 LDA IERR ;ERROR CODE
CMP #$17 ;REL ADDRESS ERROR?
BEQ H900R
CMP #$19 ;IND ADDRESS ERROR?
BEQ H980 ;YES
; OVERFLOW OR NEGATIVE EXPR
;
LDA #9 ;MASK OVERFLOW AND SIGN
AND IFLAGS+1
BNE H960 ;ERROR EXISTS
LDA JOPLEN
CMP #1
BNE H9937 ;2 BYTES OK
LDA IEXP ;SEE IF OVER 1 BYT
BNE H960 ;YES...ERROR
;END OF PROCESSING
H9937 LDX #0 ;ERROR COLUMN
LDY JOPLEN
INY ;COUNT OPCODE
TXA ;ERROR CODE
JMP LTS1
H313 LDY JOPLEN ;FORWARD REFERENCES FOUND
LDA JOPTEM ;OPERAND TEMPLATE
CMP #14 ;BRANCH--3 BYTES
BNE H9932 ;NOT BRANCH
LDY #1 ;BRANCH OPERAND LENGTH
H9932 LDX ICSB ;ERR COL FROM EVAL
INY ;ADJUST COUNT FOR OPCODE
LDA #1
JMP LTS1
; COMMON LENGTH TABLE ENTRIES
;
; RELATIVE BRANCH ERROR #$17
H900R LDA ICSB ;COLUMN OF TARGET
LDY #2 ;TWO BYTE LENGTH
JMP LTS1
H99 LDA #7 ;RAN OFF END OF CARD ERROR
STA IERR
H900 LDX ICSB ;ERROR AT START OF FIELD
JMP H9933
H980 LDX ICOLP ;ERROR AT CURRENT COLUMN
JMP H9933
H995 LDX JERCOL ;ERR AT COL RETURNED BY EVAL
; ENTER IN LENGTH TABLE
H9933 LDY #3 ;SAVE 3 BYTES
LDA IERR ;ERROR CODE
JMP LTS1
H960 LDX ICSB ;INVALID ADDRESS ERR - START OF FIELD
LDY JOPLEN
INY ;COUNT OPCODE
LDA #4 ;GET ERROR MESSAGE
JMP LTS1
; NO ERROR - COMMENT OR BLANK CARD
H990 LDX #0 ;NO ERROR COLUMN
TXA ;NO ERROR CODE
TAY ;NO BYTES GENERATED
LTS1 JSR LTINS
ENDLN LDX #$FF
TXS
JMP SNEWLN
; FIND NEXT NON-BLANK. CARRY SET IF NON-BLANK FOUND.
NFNDNB LDA IMAXCL
CMP #$FF
BEQ J30
LDX ICOLP ;COLUMN POINTER
J10 CPX IMAXCL ;END OF CARD
BEQ J15 ;COL. POINTER GOOD
BCS J30 ;OUT OF RANGE
J15 LDA ICRD,X ;NEXT CHARACTER
CMP #$20
BEQ J20 ;YES...A BLANK
STX ICSB ;RESTORE COL. POINTER
BNE J40
J20 INX
STX ICOLP
JMP J10
; FIND END OF CURRENT STRING.
; CARRY SET WHEN END IS FOUND, CARRY CLEAR IF RAN OFF CARD.
NFNDEN LDY #0
STY ICSL
LDX ICOLP ;CURRENT COLUMN POINTER
I10 CPX IMAXCL ;IN RANGE
BEQ I15 ;POINTER GOOD
BCS I30 ;BAD POINTER
I15 LDA ICRD,X ;NEXT CHARACTER
CMP #$20 ;A BLANK
BEQ I20 ;YES, A BLANK
CMP #'='
BEQ I20 ;YES, EQUALS SIGN
CMP #';'
BNE I40
I20 CPY #0
BNE I60
I25 DEX
STX ICSE ;END OF STRING PNTR
J40 SEC
RTS
I30 CPY #0
BEQ I25
J30 CLC
RTS
I40 CMP #$27 ;APPOSTROPHE
BNE I60 ;NO
INY
CPY #2
BNE I60
LDY #0 ;RESET TEMP
I60 INX ;COL. POINTER
INC ICSL
JMP I10
; FIND NON-EMBEDDED "'" OR ")". CARRY SET IF ABOVE ARE FOUND.
NFNCMP LDX ICOLP ;COL. POINTER
K40 CPX IMAXCL ;OUT OF RANGE?
BEQ K45 ;YES
BCS J30 ;END OF CARD
K45 LDA ICRD,X ;NEXT CHARACTER
CMP #$27 ;BEGINNING OF A STRING? (APPOSTROPHE)
BNE K20
K30 INX ;SKIP OVER THE STRING
STX ICOLP ;NEW COL. POINTER
CPX IMAXCL ;OFF END OF CARD
BEQ K35
BCS J30
K35 LDA ICRD,X ;NEW CHARACTER
CMP #$27 ;CLOSING QUOTE (APPOSTROPHE)
BNE K30
INX ;COL. POINTER
STX ICOLP
JMP K40
K20 LDA ICRD,X ;ANOTHER CHAR
CMP #$20
BEQ J30
CMP #')'
BEQ J40
CMP #','
BEQ J40
INX
STX ICOLP
JMP K40
.END

10
ASSEMBLER_PET_REC/start

@ -0,0 +1,10 @@
.PAGE 'START'
;LINE OF BASIC TEXT TO ALLOW
;USER TO TYPE 'RUN'
* =$400
.BYTE 0,13,4,10,0,158
.BYTE '(1039)',0,0,0
.END

4
README.md

@ -138,7 +138,8 @@ Using [kernalemu](https://github.com/mist64/kernalemu) and [cbm6502asm](https://
| Directory | Year | Comments |
|--------------------------------------------------------------|------|-------------|
| [ASSEMBLER_AIM65](ASSEMBLER_AIM65) | 1978 | 4 KB, heavily optimized |
| [ASSEMBLER_PET_V112779_REC](ASSEMBLER_PET_V112779_REC) | 1979 | ROM 2 only |
| [ASSEMBLER_PET](ASSEMBLER_PET) | 197? | ROM 2 only (undated) |
| [ASSEMBLER_PET_V112779_REC](ASSEMBLER_PET_V112779_REC) | 1979 | ROM 2 only, adds mul/div, error messages |
| [ASSEMBLER_PET_V121579_REC](ASSEMBLER_PET_V121579_REC) | 1979 | ROM 2/4, adds `.IFN`/`.IFE` |
| [ASSEMBLER_PET_V090580_A_REC](ASSEMBLER_PET_V090580_A_REC) | 1980 | adds XREF support |
| [ASSEMBLER_PET_V090580_B_REC](ASSEMBLER_PET_V090580_B_REC) | 1980 | optimizations |
@ -436,6 +437,7 @@ This is a reconstruction of the oldest known version of the Resident Assembler.
Different versions of the PET Resident Assembler. Reconstructed from ASSEMBLER_TED, based on work by Martin Hoffmann-Vetter.
* ASSEMBLER_PET (undated, [6696 bytes](docs/cbmasm/resident_assembler_Vxxxxxx_pet.prg)); for BASIC 2
* ASSEMBLER_PET_V112779_REC (1979-11-27, [7426 bytes](docs/cbmasm/resident_assembler_V112779_pet.prg)); for BASIC 2
* ASSEMBLER_PET_V121579_REC (1979-12-15, [7546 bytes](https://www.pagetable.com/docs/cbmasm/resident_assembler_V121579_pet.prg) for BASIC 4; and with `BASIC4=0`: 1979-12-15, [7546 bytes](https://www.pagetable.com/docs/cbmasm/resident_assembler_V121579_alt_pet.prg) for BASIC 2)
* ASSEMBLER_PET_V090580_A_REC (1980-09-05, [7858 bytes](https://www.pagetable.com/docs/cbmasm/resident_assembler_V090580_alt2_pet.prg))

1
build.sh

@ -158,6 +158,7 @@ build2 DOS_1541C_03 serlib
build1 PRINTER_8023P us.ptr.src
build1 ASSEMBLER_AIM65 assembler
build1 ASSEMBLER_PET_REC assembler
build1 ASSEMBLER_PET_V112779_REC assembler
build1 ASSEMBLER_PET_V121579_REC assembler4
build1 ASSEMBLER_PET_V090580_A_REC assembler

Loading…
Cancel
Save