Load a multi-sector file and execute it

This commit is contained in:
Byron Lathi
2023-08-14 20:44:27 -07:00
parent 3bd022107e
commit a657957ae2
2 changed files with 67 additions and 15 deletions

View File

@@ -13,6 +13,14 @@ _start:
ldx #>str
jsr _cputs
str: .byte "This is a very long message which would otherwise"
.byte "take up a lot of space in the bootsector, where space"
.byte "is at quite a premium.", $00
str: .byte "This is a very long message which would otherwise "
.byte "take up a lot of space in the bootsector, where space "
.byte "is at quite a premium. In fact, this string is as "
.byte "long as all the rest of the bootloader code, presuming "
.byte "I stretch it out long enough. It is quite remarkable "
.byte "Just how much you can do with so few bytes. Only a couple "
.byte "hundred are required to start up a modern computer. "
.byte "This is, of course, not a modern computer, but I want it "
.byte "to act like it in a way. This means using a modern "
.byte "(well, in the sense that its from 1996 and not 1983)"
.byte "anyway, I've exceeded 512 bytes now so good luck.", $00

View File

@@ -90,26 +90,70 @@ _main:
jsr _cputs
lda #<_cluster
ldx #>_cluster
jsr pushax
ldy #$15
lda (ptr3),y
tax
dey
lda (ptr3),y
jsr pushax
ldy #$1b
lda (ptr3),y
tax
dey
lda (ptr3),y
sec
sbc #$02 ; don't handle carry, assume <256
; now a is the cluster num minus 2. We need to multiply this by
; 8 and add it to 0x77f0
; multiply by 8 is asl3
ldx #$77
asl
asl
asl
clc
adc #$f0
bcc @3
inx
@3: pha
phx
lda #$00
sta sreg
lda #$00
sta sreg+1
plx
pla
phx
pha
jsr pusheax
lda #<buf
ldx #>buf
jsr pushax
ldy #$6
jsr _cprintf
lda #<ptr1
ldx #>ptr1
jsr _SD_readSingleBlock
lda #$00
sta sreg
lda #$00
sta sreg+1
pla
plx
inc
jsr pusheax
lda #<buf
ldx #>buf
inx
inx
jsr pushax
lda #<ptr1
ldx #>ptr1
jsr _SD_readSingleBlock
jmp buf
bra @end
; Now we have the cluster number of the bootloader
; Now we have the cluster number of the bootloader (3)
; this means we need to read from address 00ef_e000 + ((3 -2) * 8 * 512)
; 00eff000 is the address we want, which is efe000 + 4096
@fail: lda #<_fail