I've received new batch of boards and will be working on other projects, so I'll summarized what has been accomplished on 65ALL for now.
CF bootstrap is working. The code is 32 bytes, 29 bytes plus 6 bytes for NMI, reset, interrupt vectors. I know 29+6 is not 32, but I've overlapped the NMI and low byte of reset vector with JUMP $C020 instruction (opcode $4C20C0) because I've ran out of code space. The interrupt vector is $0200; the reset vector is $FFC0 and the NMI vector is $204C. Ideally I should tune the JUMP instruction to JUMP $C002 (opcode 4C02C0) which will place NMI vector at $024C, but the resource utilization is so tight, it won't compile. This is the CF bootstrap code in CPLD:
Code:
000000r 1 ;9/22/23
000000r 1 ;ROM in CPLD
000000r 1 ;boot from CF disk
000000r 1 ; CF is in native 16 bit mode
000000r 1 ; only the low byte contains meaningful program
000000r 1 ; read data from master boot sector
000000r 1 ; execute the program in master boot sector to load more program
000000r 1
000000r 1 ;copy (256-32) bytes file to 0xC020
000000r 1 SerData = $f0f9 ;CPLD serial register
000000r 1 SerStat = $f0f8 ;CPLD serial status, bit 0 is receive ready, bit 1 is txempty
000000r 1 CFdata = $ee00 ;CF data register
000000r 1 CFerr = $ee01 ;CF error reg
000000r 1 CFsectcnt = $ee02 ;CF sector count reg
000000r 1 CF07 = $ee03 ;CF LA0-7
000000r 1 CF815 = $ee04 ;CF LA8-15
000000r 1 CF1623 = $ee05 ;CF LA16-23
000000r 1 CF2427 = $ee06 ;CF LA24-27
000000r 1 CFstat = $ee07 ;CF status/command reg
000000r 1
000000r 1 .ORG $ffc0
00FFC0 1 readbsy:
00FFC0 1 AD 07 EE LDA CFstat ;check for Busy (bit7) flag cleared
00FFC3 1 30 FB BMI readbsy
00FFC5 1 A2 20 LDX #$20 ;issue read CF command and initialize X to $20
00FFC7 1 8E 07 EE STX CFstat
00FFCA 1 chkdrq:
00FFCA 1 AD 07 EE LDA CFstat ;check data request bit set before read CF data
00FFCD 1 29 08 AND #8 ;bit 3 is DRQ, wait for it to set
00FFCF 1 F0 F9 BEQ chkdrq
00FFD1 1 getCFdata:
00FFD1 1 AD 00 EE LDA CFdata
00FFD4 1 9D 00 C0 STA $c000,x ;get (256-32) bytes of data to $c020
00FFD7 1 E8 INX
00FFD8 1 D0 F7 BNE getCFdata
00FFDA 1 4C 20 C0 JMP $c020
00FFDD 1
00FFDD 1
00FFDD 1
00FFDD 1 FF .byte $ff
00FFDE 1 00 02 .word $200
The CF bootstrap waits for CF disk to be ready, write "READ command", and reads the contents of Master Boot Record to memory from $C020 to $C0FF and then jumps into $C020. I'm short on code space but need to initialize regX for the "STA $c000,x" instruction so I used "LDX #$20" and STX CFstat to initialize regX to $20.
The program in Master Boot Record copies 8 sectors (4K) from CF disk to $B000-$BFFF and jumps into $B400. This is the program resides in Master Boot Record:
Code:
;9/24/23
;CFboot for 65all
;collection of programs
; Bootstrap program reside in CF master boot blaock
; Program that writes bootstrap program into CF master boot block
; Program that writes monitor program into CF track 0 area
; Program that write memory diagnostic into CF track 0 area
; Program that write EhBasic into CF track 0 area
;
;At power on bootstrap ROM in CPLD will copy master boot record into $c020 to $c0ff
; then jump into $c020. CF is 16-bit mode during the bootstrap operation
SerData = $f0f9 ;UART transmit/receive register
SerStat = $f0f8 ;UART status register
CFdata = $ee00 ;CF data register
CFerr = $ee01 ;CF error reg
CFsectcnt = $ee02 ;CF sector count reg
CF07 = $ee03 ;CF LA0-7
CF815 = $ee04 ;CF LA8-15
CF1623 = $ee05 ;CF LA16-23
CF2427 = $ee06 ;CF LA24-27
CFstat = $ee07 ;CF status/command reg
; .pc02 ;use 65C02 instructions
;relocatable program destine for $c020
start:
LDX #$FF ;initialize stack pointer
TXS
CLD
LDA #$e0 ;set up LBA mode
STA CF2427
LDA #1 ;set feature to 8-bit interface
STA CFerr
LDA #$ef ;the set feature command
STA CFstat
readbsy:
LDA CFstat ;check busy flag
AND #$80
BNE readbsy
;load a 4K program (mon65all) stored in track 0, sector $f8-$ff
; to RAM starting from $b000-$bfff
STA CF1623 ;track 0
STA CF815
;zero page locations 0xc0 and 0xc1 are indirect index of address to be loaded
STA $c0 ;put zero in $c0 (LSB)
LDA #$b0 ;put $b1 in $c1 (MSB)
STA $c1
LDX #$f8 ;read sectors $f8-$ff, start from sector 0xf8
moresect:
LDA #1 ;sector count of 1
STA CFsectcnt
TXA ;X contains the sector to be read
STA CF07
LDA #$20 ;read CF command
STA CFstat
;bit bang transmitter starts here
STX $c2 ;save X
LDA #'.' ;put out a '.' for every sector loaded
LDY #9 ;shift 9 bits
CLC ;use carry bit as start bit
ROL ;move carry into bit 0
ROL ;again, because it will be ROR immediately
bitBang1:
;assert a bit for 8.6uS for 25.175MHz clock
ROR ;next bit (2)
STA SerData ;bit bang with D(0) (4)
LDX #$2a ;(2)
bitTime1a:
DEX ;burn 23x5 clocks (2)n
BNE bitTime1a ;(3)n
DEY ;(2)
BNE bitBang1 ;(3)
INY
STY SerData ;stop bit
DEY ;initialize Y back to zero
LDX $c2 ;restore X
;bit bang transmitter ends here
readdrq:
LDA CFstat ;check data request bit set before read CF data
AND #8
BEQ readdrq
blk1st:
LDA CFdata
STA ($c0),y ;save, starting from 0xB000
INY
BNE blk1st
INC $c1 ;next 256 bytes
blk2nd:
LDA CFdata
STA ($c0),y
INY
BNE blk2nd ;save a total of 512 bytes
INX ;next CF sector
INC $c1 ;next 256 byte of address
LDA #$c0 ;top of memory to store is 0xBFFF
CMP $c1
BNE moresect
JMP $b400 ;start location of CRCMon
saveXa:
.byte 0
There are helper programs that copy several programs into track 0 of CF disk, but I won't bother listing them unless there are interests. It will be uploaded to 65ALL homepage eventually.
So it boots from CF and runs the monitor. Power consumption is 300mA @5V. "The devil is in the detail", there are lots of loose ends to clean up, most important one is an updated PC board.
Bill