Browse Source

added LOADER_PET

pull/5/head
Michael Steil 4 years ago
parent
commit
4a6beff382
  1. 328
      LOADER_PET/load.main
  2. 5
      LOADER_PET/loload.4
  3. 7
      README.md
  4. 1
      build.sh

328
LOADER_PET/load.main

@ -0,0 +1,328 @@
;LOADER FOR RESIDENT PET 6502
; ASSEMBLER
.SKI
;DECEMBER 13,1979
.SKI
.IFE BASIC-2 <
;CONSTANTS FROM PET BASIC 2.0
READY =$C389
CLRCHN =$FFCC ;CLOSE I/O CHANNELS
CHKIN =$F770 ;OPEN INPUT CHANNEL
BASIN =$F1E1 ;INPUT SOURCE BYTE
CKOUT =$F7BC ;OPEN OUTPUT CHANNEL
BASOUT =$F232 ;OUTPUT CHARACTER TO CHAN
PRT =$E3D8 ;PRINT CHARACTER TO SCREEN
RDOB =$E7B6 ;INPUT A HEX BYTE
RDOB1 =$E7BE ;INPUT A HEX BYTE
STOP1 =$F301 ;TEST FOR STOP KEY
FCLOSE =$F2AE ;CLOSE FILE .A
LA =$D2 ;LOGICAL DEVICE NUMBER
FA =$D4 ;PRIMARY ADDRESS
SA =$D3 ;SECONDARY COMMAND
FNADR =$DA ;ADDRESS OF FILE NAME
FNLEN =$D1 ;LENGTH OF FILE NAME
FOPEN =$F524 ;OPEN FILE LA,FA,SA
>
.IFE BASIC-4 <
;CONSTANTS FROM PET BASIC 4.0
READY =$B3FF
CLRCHN =$FFCC ;CLOSE I/O CHANNELS
CHKIN =$FFC6 ;OPEN INPUT CHANNEL
BASIN =$FFCF ;INPUT SOURCE BYTE
CKOUT =$FFC9 ;OPEN OUTPUT CHANNEL
BASOUT =$FFD2 ;OUTPUT CHARACTER TO CHAN
PRT =$E202 ;PRINT CHARACTER TO SCREEN
RDOB =$D763 ;INPUT A HEX BYTE
RDOB1 =$D76B ;INPUT A HEX BYTE
STOP1 =$F335 ;TEST FOR STOP KEY
FCLOSE =$F2E2 ;CLOSE FILE .A
LA =$D2 ;LOGICAL DEVICE NUMBER
FA =$D4 ;PRIMARY ADDRESS
SA =$D3 ;SECONDARY COMMAND
FNADR =$DA ;ADDRESS OF FILE NAME
FNLEN =$D1 ;LENGTH OF FILE NAME
FOPEN =$F563 ;OPEN FILE LA,FA,SA
>
.SKI
;PAGE ZERO VARIABLES
* =$42
LDADDR *=*+2 ;LOAD ADDRESS
.SKI
;WORKING VARIABLES
.IFE LOC <
* =$027A
>
.IFE LOC-16 <
* =$3000
>
.IFE LOC-32 <
* =$7000
>
.IFN LOC <
JMP LOAD ;GO TO THE LOAD ROUTINE
>
CHKSUM *=*+2 ;CHECKSUM OF CURRENT
OFFSET *=*+2 ;LOAD OFFSET (ADDED)
BYTCNT *=*+1 ;COUNT OF CURRENT BYTES
RECCNT *=*+2 ;TOTAL RECORDS LOADED
INDEX *=*+1 ;INDEX FROM LOAD ADDRESS
DATA *=*+1 ;HEX BYTE IN TRANSIT
CHAN *=*+1 ;CURRENT CHANNEL FLAG
OBJFIL *=*+16 ;USER OBJECT FILE NAME
OBJLEN *=*+1 ;LENGTH OF FILE NAME
.PAG 'PET LOADER'
.IFE LOC <
;LINE OF BASIC TEXT TO ALLOW
; USER TO TYPE 'RUN'
* =$400
.BYT 0,13,4,10,0,158 ;10 SYS
.BYT '(1039)',0,0,0
.SKI 5
>
LOAD LDA #0
STA CHAN
STA OBJLEN
STA RECCNT
STA RECCNT+1
STA OFFSET ;ZERO OFFSET
STA OFFSET+1
LDX #OFFMSG-MSGS ;ASK FOR OFFSET
JSR MSG
LD005 JSR BASIN ;GET A CHARACTER
CMP #$20 ;SPACE IS ERROR
BEQ LD005
CMP #$0D ;RETURN IS OK (DEFAULT OFFSET TO ZERO)
BEQ LD010
.SKI
JSR RDOB1 ;GET THE HIGH BYTE
BCC LOAD ;ERROR START OVER...
STA OFFSET+1
JSR RDOB ;GET THE LOW BYTE
BCC LOAD ;ERROR START OVER....
STA OFFSET
LD010
.SKI
LDX #OBJMSG-MSGS
JSR MSG
LDX #40
STX INDEX
LD10 DEC INDEX
BEQ LOAD
JSR BASIN
CMP #$20
BEQ LD10
CMP #$D
BNE GOLOAD
JMP DONE ;RETURN EXITS LOADER...
GOLOAD LDX #0
STX OBJLEN
BEQ LD30
LD20 JSR BASIN
CMP #$20
BEQ LD40
LD30 CMP #$D
BEQ LD40
LDX OBJLEN
CPX #14
BEQ LOAD
STA OBJFIL,X
INX
STX OBJLEN
JMP LD20
LD40 LDA #',
STA OBJFIL,X
INX
LDA #'S
STA OBJFIL,X
INX
STX OBJLEN
LDA #$D
JSR PRT
;.IFE BASIC-2 <
;INIT DISK
LDA #7
STA LA
LDA #2
STA FNLEN
LDA #8
STA FA
LDA #15
STA SA
LDA #'I
STA CHKSUM
LDA #'0
STA CHKSUM+1
LDA #>CHKSUM
STA FNADR+1
LDA #<CHKSUM
STA FNADR
JSR FOPEN
LDA #7
JSR FCLOSE
LDA #'1
STA CHKSUM+1
JSR FOPEN
LDA #7
JSR FCLOSE
;>
;OPEN OBJECT FILE
LDA #7
STA SA
LDA #>OBJFIL
STA FNADR+1
LDA #<OBJFIL
STA FNADR
LDA OBJLEN
STA FNLEN
JSR FOPEN
;BEGIN LOAF
LH1 JSR STOP1 ;STOP KEY?
BNE LHH1
JMP ERROR3 ;YES BREAK.....
LHH1 JSR GETCHR
CMP #'; ;RECORD INITIATOR?
BNE LH1 ;NO...KEEP LOOKING
.SKI
LDA #0
STA CHKSUM
STA CHKSUM+1
STA INDEX
JSR GETBYT ;READ BYTE COUNT
BNE LH2 ;NOT LAST RECORD
;CHECK END RECORD COUNT
JSR GETBYT
CMP RECCNT+1
BNE ERROR4
JSR GETBYT
CMP RECCNT
BNE ERROR4
BEQ DONE
.SKI
LH2 STA BYTCNT
INC RECCNT
BNE LH1B
INC RECCNT+1
LH1B JSR ADDCHK ;LENGHT TO CHECKSUM
JSR GETBYT
PHA ;SAVE FOR CHECKSUM
CLC
ADC OFFSET+1 ;ADD IN THE OFFSET
STA LDADDR+1 ;HIGH BYTE ADDRESS
PLA
JSR ADDCHK ;CHECKSUM ADD
JSR GETBYT ;GET LOW ADDRESS
PHA ;SAVE FOR CHECKSUM
CLC
ADC OFFSET ;CARRY SET
STA LDADDR
BCC LH1C
INC LDADDR+1
LH1C PLA
JSR ADDCHK
.SKI
LH3 JSR GETBYT
LDY INDEX
INC INDEX
STA (LDADDR)Y
CMP (LDADDR)Y ;GOOD STORE?
BNE ERROR1 ;NO...
JSR ADDCHK
DEC BYTCNT ;LAST BYTE?
BNE LH3 ;NO...
.SKI
JSR GETBYT ;TEST CHECKSUM HI
CMP CHKSUM+1
BNE ERROR2 ;CHECKSUM ERROR
JSR GETBYT ;GET CHECKSUM LO
CMP CHKSUM
BNE ERROR2 ;CHECKSUM ERROR
JMP LH1 ;CONTINUE NEXT RECORD
.SKI 5
ERROR1 LDX #CMPERR-MSGS
.BYT $2C
ERROR2 LDX #CHKERR-MSGS
.BYT $2C
ERROR3 LDX #BRKMSG-MSGS
.BYT $2C
ERROR4 LDX #RECERR-MSGS
JSR MSG
.SKI
DONE LDA #7
JSR FCLOSE
JSR CLRCHN
LDX #DNMSG-MSGS
JSR MSG
JMP READY
.SKI 5
MSG STX INDEX
MS10 LDX INDEX
LDA MSGS,X
PHP
AND #$7F
JSR PRT
INC INDEX
PLP
BPL MS10
RTS
.SKI
MSGS
RECERR .BYT $D,'BAD RECORD COUN',$D4
BRKMSG .BYT $D,'BREAK',$8D
DNMSG .BYT $D,'END OF LOA',$C4
CMPERR .BYT $D,'NON-RAM LOA',$C4
CHKERR .BYT $D,'CHECKSUM ERRO',$D2
OFFMSG .BYT $D,$D,$D
.IFE LOC <
.BYT 'LOW'
>
.IFE LOC-16 <
.BYT '16K'
>
.IFE LOC-32 <
.BYT '32K'
>
.BYT ' LOADER V121379',$D
.BYT '(C) 1979 BY COMMODORE BUSINESS MACHINES',$D,$D
.BYT $D,'INPUT OFFSET?',$A0
OBJMSG .BYT $D,'OBJECT FILE NAME?',$A0
.SKI 5
GETBYT JSR GETCHR
JSR HEXIT
ASL A
ASL A
ASL A
ASL A
STA DATA
JSR GETCHR
JSR HEXIT
ORA DATA
RTS
.SKI 5
HEXIT CMP #': ;NUMERIC?
PHP
AND #$0F
PLP
BCC HEXOUT ;0-9
ADC #8 ;ALPHA ADD 8+CY=9
HEXOUT RTS
.SKI 5
GETCHR LDA CHAN
CMP #7
BEQ GET10
JSR CLRCHN
LDX #7
STX CHAN
JSR CHKIN
GET10 JSR BASIN
PHA
JSR PRT
PLA
RTS
.SKI 5
ADDCHK CLC
ADC CHKSUM
STA CHKSUM
BCC ADD10
INC CHKSUM+1
ADD10 RTS
.END

5
LOADER_PET/loload.4

@ -0,0 +1,5 @@
;LOAD FOR BASIC4 AT $0400
BASIC =4
LOC =0
.LIB LOAD.MAIN
.END

7
README.md

@ -132,6 +132,7 @@ Using [kernalemu](https://github.com/mist64/kernalemu) and [cbm6502asm](https://
| [ASSEMBLER_PET_V26MAR82RR_REC](ASSEMBLER_PET_V26MAR82RR_REC) | 1982 | based on V090580_B, LST output changes, non-mainline |
| [ASSEMBLER_C64_REC](ASSEMBLER_C64_REC/) | 1982 | "C64 Macro Assembler", adds `.MAC` |
| [ASSEMBLER_TED](ASSEMBLER_TED) | 1984 | TED version, adds `.OPT LON`, `.OPT MLI` |
| [LOADER_PET](LOADER_PET) | 1979 | OBJ Loader |
| [LOADER_C64](LOADER_C64) | 1986 | OBJ Loader |
## Software: Games
@ -406,9 +407,13 @@ The C64 Macro Assembler (a version of the Commodore Resident Assembler). Reconst
A version of the Commodore Resident Assembler for the TED series (Plus/4, C16 and C116). Extracted from [ted_kernal_basic_src.tar.gz](http://www.zimmers.net/anonftp/pub/cbm/src/plus4/ted_kernal_basic_src.tar.gz).
### LOADER_PET
The PET OBJ Loader, version V121379. Extracted from [ted_kernal_basic_src.tar.gz](http://www.zimmers.net/anonftp/pub/cbm/src/plus4/ted_kernal_basic_src.tar.gz) and converted to uppercase and LST-style indenting. File loload.4 added.
### LOADER_C64
The OBJ Loader of the C64 Macro Assembler, version V072882. Extracted from [c64_kernal_bas_src.tar.gz](http://www.zimmers.net/anonftp/pub/cbm/src/c64/c64_kernal_bas_src.tar.gz), converted to uppercase and LST-style indenting.
The OBJ Loader of the C64 Macro Assembler, version V072882. Extracted from [c64_kernal_bas_src.tar.gz](http://www.zimmers.net/anonftp/pub/cbm/src/c64/c64_kernal_bas_src.tar.gz) and converted to uppercase and LST-style indenting.
### MONITOR_KIM

1
build.sh

@ -149,6 +149,7 @@ build1 ASSEMBLER_PET_V102780_REC assembler
build1 ASSEMBLER_PET_V26MAR82RR_REC assembler
build1 ASSEMBLER_C64_REC assembler
build2 ASSEMBLER_TED assembler
build1 LOADER_PET loload.4
build1 LOADER_C64 loload
build1 DISK_MONITOR mon.lib

Loading…
Cancel
Save