From eb72e8362924008d0daf1365c9a1d3f007baa18d Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Wed, 23 Aug 2023 20:48:57 -0700 Subject: [PATCH] Use old offset calculation, save ptr3 Looks like cprintf modifies ptr3, so make sure to save it if you are calling that. There also may have been an issue with how the previous sector address was calculated, the one which does not account for carries seems to work. --- sw/bios/boot2.s | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sw/bios/boot2.s b/sw/bios/boot2.s index 906d348..8e6b5c8 100644 --- a/sw/bios/boot2.s +++ b/sw/bios/boot2.s @@ -101,6 +101,11 @@ _start: ldx #>word_str jsr pushax + lda ptr3 + pha + lda ptr3 + 1 + pha + ldy #$1d ; load file size (256) lda (ptr3),y lsr ; divide by 2 to get file size (512) @@ -108,26 +113,29 @@ _start: ldy #$4 jsr _cprintf + pla + sta ptr3 + 1 + pla + sta ptr3 + ldy #$1b ; load high byte of low first cluster lda (ptr3),y tax dey lda (ptr3),y ; load low byte of low first cluster - ldx data_start + 1 sec - sbc #$02 - bcs @3 - dex -@3: asl + sbc #$02 ; don't handle carry, assume low byte is not 0 or 1 + ldx data_start + 1 ; load x as high data start + asl ; multiply cluster num (minus 2) by 8 asl asl clc - adc data_start - bcc @5 + adc data_start ; add that to low data start + bcc @5 ; handle carry inx -@5: stz sreg ; data start is not going to be > 2^16 - stz sreg + 1 ; (I hope) +@5: stz sreg + stz sreg+1 phx pha