Browse Source

added LOADER_C64

pull/5/head
Michael Steil 4 years ago
parent
commit
4bd0696553
  1. 4
      LOADER_C64/hiload
  2. 406
      LOADER_C64/load.main
  3. 4
      LOADER_C64/loload
  4. 5
      README.md
  5. 2
      build.sh

4
LOADER_C64/hiload

@ -0,0 +1,4 @@
;LOAD FOR CBM64 AT $C800
LOC =1
.LIB LOAD.MAIN
.END

406
LOADER_C64/load.main

@ -0,0 +1,406 @@
;CPUT"@1:C64/LOAD.MAIN"
;LOADER FOR RESIDENT PET 6502
;ASSEMBLER
;MUST SET LOC; 0= $0801, 1= $C800
.SKI
;DECEMBER 13,1979
;CONVERTED TO CBM64 BY RJF
;ON 07/28/82
.SKI
;CONSTANTS FROM PET BASIC 2.0
READY =$E391 ;(NREADY) [NOT KERNAL]
CLRCHN =$FFCC ;CLOSE I/O CHANNELS
CHKIN =$FFC6 ;OPEN INPUT CHANNEL
BASIN =$FFCF ;INPUT SOURCE BYTE
BASOUT =$FFD2 ;OUTPUT CHARACTER TO CHAN
STOP =$FFE1 ;TEST FOR STOP KEY
CLOSE =$FFC3 ;CLOSE FILE .A
SETLFS =$FFBA ;SET LA FA SA
SETNAM =$FFBD ;SETNAME
OPEN =$FFC0 ;OPEN FILE
;+++
;PAGE ZERO VARIABLES
;---
STATUS =$90 ;I/O STATUS BYTE
* =$FB
LDADDR *=*+2 ;LOAD ADDRESS
.PAG 'PET LOADER'
.IFE LOC <
;LINE OF BASIC TEXT TO ALLOW
; USER TO TYPE 'RUN'
* =$0801
.BYT 13,8,10,0,158 ;10 SYS(2063)
.BYT '(2063)',0,0,0
.SKI 5
>
.IFE LOC-1 <
* = $C800
>
LOAD
JSR CLRCHN ;CLOSE CHANNEL
LDA #0 ;CLEAR VARIABLES
STA RECCNT
STA RECCNT+1
STA OFFSET
STA OFFSET+1
STA STATUS ;CLEAR I/O STATUS
LDX #OFFMSG-MSGS ;ASK FOR OFFSET
JSR MSG
JSR RDOA ;READ OFFSET (MUST BE FOUR CHARACTERS)
BCC LOAD ;DO IT AGAIN
.SKI
LDX #OBJMSG-MSGS ;ASK FOR OFFEST
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...
.PAG
GOLOAD ;ASK FOR FILENAME
LDX #0
STX OBJLEN
BEQ LD30
LD20 JSR BASIN
CMP #$20
BEQ LD40
LD30 CMP #$D
BEQ LD40
LDX OBJLEN
CPX #15 ;MAX OF 16 CHARACTERS
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 BASOUT
.PAG
;+++
; INIT THE DRIVE
;---
LDA #7
LDX #8
LDY #15
JSR SETLFS
LDA #'I
STA CHKSUM
LDA #'0
STA CHKSUM+1
LDX #<CHKSUM
LDY #>CHKSUM
LDA #2
JSR SETNAM
JSR OPEN
LDA STATUS ;READ STATUS AFTER OPEN
BEQ INITOK
CMP #$40 ;EOI IS OK
BNE ERRORX
INITOK LDA #7
JSR CLOSE
;+++
;OPEN OBJECT FILE
;---
LDA #7
LDX #8
LDY #7
JSR SETLFS
LDX #<OBJFIL
LDY #>OBJFIL
LDA OBJLEN
JSR SETNAM
JSR OPEN
LDA STATUS ;DID OPEN GO OK
BEQ LOAF
CMP #$40
BEQ LOAF
ERRORX JMP ERROR0 ;DISK ERROR
.PAG
;+++
;BEGIN LOAF
;---
LOAF
LDX #7 ;SET CHANNEL
JSR CHKIN
LH1 JSR STOP ;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
BEQ LH1D
JMP ERROR4
LH1D JSR GETBYT
CMP RECCNT
BNE ERROR4
JMP DONE
.SKI
LH2 STA BYTCNT
INC RECCNT
BNE LH1B
INC RECCNT+1
LH1B JSR ADDCHK ;LENGTH 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 ;DO CHECKSUM
;
LDA RECCNT
CMP #1 ;ONLY WHEN LO = 1
BNE LH3
LDA #$0D ;PRINT EVERY 256
JSR BASOUT
JSR WROA ;WRITE LOAD ADDRESS
.SKI
LH3 JSR GETBYT
LDY INDEX
STY OBJLEN ;SAVE FOR LAST ADDRESS
INC INDEX
STA (LDADDR),Y ;STORE DATA
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
LDA #'. ;FINISHED RECORD
JSR BASOUT
JMP LH1 ;CONTINUE NEXT RECORD
.SKI
ERROR0 LDX #DSKERR-MSGS
.BYT $2C
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 ;FINISHED WITH LOAD
JSR CLRCHN
LDA #7
JSR CLOSE
CLC ;PRINT LAST ADDRESS LOADED
LDA OBJLEN ;ADD IN INDEX
ADC LDADDR
STA LDADDR
LDA LDADDR+1
ADC #0
STA LDADDR+1
LDA #13
JSR BASOUT
JSR WROA ;PRINT THE ADDRESS
LDX #DNMSG-MSGS
JSR MSG
JMP READY
.SKI 5
.PAG 'SUBROUTINES'
;+++
;PRINT MESSAGE
;---
MSG STX INDEX
MS10 LDX INDEX
LDA MSGS,X
PHP
AND #$7F
JSR BASOUT
INC INDEX
PLP
BPL MS10
RTS
.SKI
HEXIT CMP #': ;NUMERIC?
PHP
AND #$0F
PLP
BCC HEXOUT ;0-9
ADC #8 ;ALPHA ADD 8+CY=9
HEXOUT RTS
;+++
;GET FROM CHANNEL
;---
GETCHR
JSR BASIN
PHA
LDA STATUS
BEQ GETOK
CMP #$40
BNE GETERR
GETOK PLA
RTS
GETERR PLA ;ERROR GET OUT
PLA
PLA
PLA
PLA
JMP ERROR0
;+++
;DO CHECKSUM
;---
ADDCHK CLC
ADC CHKSUM
STA CHKSUM
BCC ADD10
INC CHKSUM+1
ADD10 RTS
.PAG
;+++
;READ HEX ADR, RETURN IN OFFSET
;AND CY=1
;IF SP CY=0
;---
RDOA
JSR GETCHR
CMP #$0D
BEQ RDOA2 ;CR IS ZERO
CMP #$20
BEQ RDOA3
JSR RDOB1
BCC RDOA3
STA OFFSET+1 ;GOT HI BYTE
.SKI
JSR RDOB
BCC RDOA3
STA OFFSET ;GOT LO BYTE
RDOA2 ;RETURN OK
SEC
RTS
RDOA3 ;RETURN BAD
CLC
RTS
;+++
;READ HEX BYTE AND RETURN IN .A
;AND CY=1 IF SP CY=0
;---
GETBYT
RDOB LDA #0 ;SPACE
STA DATA ;READ NEXT CHAR
JSR GETCHR
RDOB1 CMP #$20
BNE RDOB2
JSR GETCHR ;READ NEXT CHAR
CMP #$20
BNE RDOB3
CLC ;CY=0
RTS
RDOB2 JSR HEXIT ;TO HEX
ASL A
ASL A
ASL A
ASL A
STA DATA
JSR GETCHR
RDOB3
JSR HEXIT
ORA DATA
SEC
RTS
.PAG
;+++
;WRITE ADDRESS
;---
WROA
LDA LDADDR
PHA
LDA LDADDR+1
JSR WROB
PLA
;WRITE BYTE --- .A = BYTE
;UNPACK BYTE DATA INTO TWO ASCII
;CHARACTERS. .A=BYTE; .X, .A=CHARS
WROB PHA
LSR A
LSR A
LSR A
LSR A
JSR ASCII ;CONVERT TO ASCII
TAX
PLA
AND #$0F
JSR ASCII
;WRITE 2 CHARS-- .X, .A=CHARS
WRTWO PHA
TXA
JSR BASOUT
PLA
JMP BASOUT
ASCII CLC ;MAKE ASCII
ADC #$F6
BCC ASC1
ADC #$06
ASC1 ADC #$3A
RTS
.PAG
;+++
;DATA AREA
;---
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
OBJFIL *=*+18 ;USER OBJECT FILE NAME
OBJLEN *=*+1 ;LENGTH OF FILE NAME
.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
DSKERR .BYT $D,'FILE ERRO',$D2
OFFMSG .BYT $D,$D,$D
.IFE LOC <
.BYT 'LO'
>
.IFE LOC-1 <
.BYT 'HI'
>
.BYT 'LOAD.C64 V072882',$D
.BYT '(C) 1982 BY COMMODORE BUSINESS MACHINES',$D,$D
.BYT $D,'HEX OFFSET (CR IF NONE) ?',$A0
OBJMSG .BYT $D,'OBJECT FILE NAME ?',$A0
.END

4
LOADER_C64/loload

@ -0,0 +1,4 @@
;LOAD FOR CBM64 AT $0800
LOC =0
.LIB LOAD.MAIN
.END

5
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_C64](LOADER_C64) | 1986 | OBJ Loader |
## Software: Games
@ -405,6 +406,10 @@ 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_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.
### MONITOR_KIM
The KIM-1 "monitor" ROM (1975), i.e. 6530-002 and 6530-003. From the [Hans Otten reconstructed source from the KIM-1 users manual](http://retro.hansotten.nl/uploads/6502docs/usrman.htm).

2
build.sh

@ -149,6 +149,8 @@ build1 ASSEMBLER_PET_V102780_REC assembler
build1 ASSEMBLER_PET_V26MAR82RR_REC assembler
build1 ASSEMBLER_C64_REC assembler
build2 ASSEMBLER_TED assembler
build1 LOADER_C64 loload
build1 DISK_MONITOR mon.lib
build1 MATHPACK mathpack

Loading…
Cancel
Save