From 1130db35e05ef422a866ba9f8afd5b62ddcde775 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 28 Sep 2019 10:57:12 +0200 Subject: [PATCH] more aliases cleanup --- c64/aliases/,aliases_ram_lowmem.s | 39 ++++++++++++++++++++++++---- c64/basic/,aliases.s | 27 ------------------- c64/basic/basic_parse_line_number.s | 10 ++++---- c64/basic/fac1_mul.s | 40 ++++++++++++++--------------- c64/basic/injest_number.s | 18 ++++++------- c64/kernal/,aliases.s | 15 ----------- 6 files changed, 68 insertions(+), 81 deletions(-) delete mode 100644 c64/kernal/,aliases.s diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 00d19059..1b4a04b1 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -57,12 +57,22 @@ .label JMPER = $54 // $54-$56 -- NOT IMPLEMENTED -- .label TEMPF1 = $57 // $57-$5B BASIC numeric work area .label TEMPF2 = $5C // $5C-$60 BASIC numeric work area - .label FAC1 = $61 // $61-$66 -- NOT IMPLEMENTED -- + + .label __FAC1 = $61 // $61-$66 floating point accumulator 1 + .label FAC1_exponent = $61 + .label FAC1_mantissa = $62 // $62 - $65 + .label FAC1_sign = $66 + .label SGNFLG = $67 // -- NOT IMPLEMENTED -- - .label BITS = $68 // -- NOT IMPLEMENTED -- - .label FAC2 = $69 // $69-$6E -- NOT IMPLEMENTED -- [!] also used for memory move pointers + .label BITS = $68 // FAC1 overflow + + .label __FAC2 = $69 // $69-$6E floating point accumulator 2 [!] also used for memory move pointers + .label FAC2_exponent = $69 + .label FAC2_mantissa = $6A // $6A - $6D + .label FAC2_sign = $6E + .label ARISGN = $6F // -- NOT IMPLEMENTED -- - .label FACOV = $70 // -- NOT IMPLEMENTED -- + .label FACOV = $70 // FAC1 low order mantissa .label FBUFPT = $67 // $71-$72 -- NOT IMPLEMENTED -- .label CHRGET = $73 // $73-$8A -- NOT IMPLEMENTED -- .label TXTPTR = $7A // $7A-$7B current BASIC statement pointer @@ -190,7 +200,26 @@ .label TD1IRQ = $2A4 // -- NOT IMPLEMENTED -- .label TLNIDX = $2A5 // -- NOT IMPLEMENTED -- .label TVSFLG = $2A6 // 0 = NTSC, 1 = PAL - // [!] XXX document $2A7-$2FF usage + + // [!] $2A7-$2FF is normally free, but in our case some extra functionality uses it + +#if CONFIG_MEMORY_MODEL_60K + + // IRQs are disabled when doing such accesses, and a default NMI handler only increments + // a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured. + + .label missed_nmi_flag = $2A7 + .label tiny_nmi_handler = $2A8 + .label peek_under_roms = tiny_nmi_handler + peek_under_roms_routine - tiny_nmi_handler_routine + .label poke_under_roms = tiny_nmi_handler + poke_under_roms_routine - tiny_nmi_handler_routine + .label memmap_allram = tiny_nmi_handler + memmap_allram_routine - tiny_nmi_handler_routine + .label memmap_normal = tiny_nmi_handler + memmap_normal_routine - tiny_nmi_handler_routine +#if SEGMENT_BASIC + .label shift_mem_up = tiny_nmi_handler + shift_mem_up_routine - tiny_nmi_handler_routine + .label shift_mem_down = tiny_nmi_handler + shift_mem_down_routine - tiny_nmi_handler_routine +#endif // SEGMENT_BASIC + +#endif // CONFIG_MEMORY_MODEL_60K // BASIC vectors .label IERROR = $300 // $300-$301 diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 479d6bf1..f5cb035e 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -37,35 +37,8 @@ .label basic_numeric_work_area = $57 // $57 - $60 inclusive = 10 bytes - // Floating point accumulator 1 $61 - $68 - .label basic_fac1_exponent = $61 - .label basic_fac1_mantissa = $62 // $62 - $65 - .label basic_fac1_sign = $66 - .label basic_fac1_overflow = $68 - .label basic_fac1_mantissa_lob = $70 - - .label basic_fac2_exponent = $69 - .label basic_fac2_mantissa = $6A // $6A - $6D - .label basic_fac2_sign = $6E - // We also re-use FAC2 for memory move pointers, since // we can't be doing calculations while moving memory .label memmove_src = $69 .label memmove_dst = $6b .label memmove_size = $6d - -#if CONFIG_MEMORY_MODEL_60K - - // BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards - // IRQs are disabled when doing such accesses, and a default NMI handler only increments - // a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured. - .label missed_nmi_flag = $2A7 - .label tiny_nmi_handler = $2A8 - .label shift_mem_up = tiny_nmi_handler+shift_mem_up_routine-tiny_nmi_handler_routine - .label shift_mem_down = tiny_nmi_handler+shift_mem_down_routine-tiny_nmi_handler_routine - .label peek_under_roms = tiny_nmi_handler+peek_under_roms_routine-tiny_nmi_handler_routine - .label poke_under_roms = tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine - .label memmap_allram = tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine - .label memmap_normal = tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - -#endif // CONFIG_MEMORY_MODEL_60K diff --git a/c64/basic/basic_parse_line_number.s b/c64/basic/basic_parse_line_number.s index 90aa8336..aab2efb0 100644 --- a/c64/basic/basic_parse_line_number.s +++ b/c64/basic/basic_parse_line_number.s @@ -5,9 +5,9 @@ basic_parse_line_number: // Check if the number is a valid line number // i.e., 16 bits, no exponent, no decimal - lda basic_fac1_mantissa+2 - ora basic_fac1_mantissa+3 - ora basic_fac1_exponent + lda FAC1_mantissa+2 + ora FAC1_mantissa+3 + ora FAC1_exponent beq !+ ml_bad_line_number: // Invalid line number @@ -19,9 +19,9 @@ ml_bad_line_number: bne ml_bad_line_number // Got a valid line number. - lda basic_fac1_mantissa+0 + lda FAC1_mantissa+0 sta basic_line_number+0 - lda basic_fac1_mantissa+1 + lda FAC1_mantissa+1 sta basic_line_number+1 clc rts diff --git a/c64/basic/fac1_mul.s b/c64/basic/fac1_mul.s index f3618aa6..8df97b6a 100644 --- a/c64/basic/fac1_mul.s +++ b/c64/basic/fac1_mul.s @@ -3,13 +3,13 @@ // Implement by shifting MAC left one bit, // and then keeping that value to add on after // shifting two more bits left. -// This should be done using basic_fac1_overflow to +// This should be done using BITS to // hold the overflow bits, so that the result can // be exponent adjusted after, if required. fac1_mul10: lda #$00 - sta basic_fac1_overflow + sta BITS // Multiply mantissa by 2 jsr fac1_mantissa_mul2 @@ -20,7 +20,7 @@ fac1_mul10: // the overflow bits, and the copy is as small as possible) ldx #7 f1m10_l1: - lda basic_fac1_mantissa,x + lda FAC1_mantissa,x sta basic_numeric_work_area,x dex bpl f1m10_l1 @@ -33,21 +33,21 @@ f1m10_l1: ldy #3 ldx #0 clc -f1m10_l2: - lda basic_fac1_mantissa,x +f1m10_l2: + lda FAC1_mantissa,x adc basic_numeric_work_area,x - sta basic_fac1_mantissa,x + sta FAC1_mantissa,x inx dey bpl f1m10_l2 - lda basic_fac1_overflow + lda BITS adc basic_numeric_work_area+7 - sta basic_fac1_overflow + sta BITS // Now shift right and increase exponent until overflow // bits = $00 f1m10_l3: - lda basic_fac1_overflow + lda BITS bne !+ // All done, return clc @@ -55,8 +55,8 @@ f1m10_l3: !: // Divide mantissa by two, and increment exponent jsr fac1_mantissa_div2 - inc basic_fac1_exponent - lda basic_fac1_exponent + inc FAC1_exponent + lda FAC1_exponent bpl f1m10_l3 // Exponent has bit 7 set, so has wrapped. // = OVERFLOW ERROR @@ -68,30 +68,30 @@ fac1_mantissa_mul2: clc f1m1_l1: // Multiply mantissa by 2, and store overflow - // in basic_fac1_bits - lda basic_fac1_mantissa,x + // in FAC1_bits + lda FAC1_mantissa,x rol - sta basic_fac1_mantissa,x + sta FAC1_mantissa,x inx dey bpl f1m1_l1 - lda basic_fac1_overflow + lda BITS rol - sta basic_fac1_overflow + sta BITS rts fac1_mantissa_div2: // Divide mantissa by 2, including using overflow bits clc - lda basic_fac1_overflow + lda BITS ror - sta basic_fac1_overflow + sta BITS ldy #3 f1md2_l1: - lda basic_fac1_mantissa,y + lda FAC1_mantissa,y ror - sta basic_fac1_mantissa,y + sta FAC1_mantissa,y dey bpl f1md2_l1 rts diff --git a/c64/basic/injest_number.s b/c64/basic/injest_number.s index 948ddc82..5ed2b3f7 100644 --- a/c64/basic/injest_number.s +++ b/c64/basic/injest_number.s @@ -60,7 +60,7 @@ injest_number: // Set sign to negative lda #$ff - sta basic_fac1_sign + sta FAC1_sign // Skip over the minus sign jsr basic_consume_character @@ -80,7 +80,7 @@ ij_loop1: // Only add digit if we have not overflowed the accuracy of // the mantissa - lda basic_fac1_exponent + lda FAC1_exponent beq ij_accept_precision // We have an extra digit after saturating our precision. @@ -103,7 +103,7 @@ ij_accept_precision: // we can add the new digit in jsr fac1_mul10 - lda basic_fac1_exponent + lda FAC1_exponent bne ij_consider_next_digit // Get digit @@ -114,14 +114,14 @@ ij_accept_precision: // Add to FAC1 mantissa clc - adc basic_fac1_mantissa+0 - sta basic_fac1_mantissa+0 + adc FAC1_mantissa+0 + sta FAC1_mantissa+0 ldx #1 ldy #3 ij_loop2: - lda basic_fac1_mantissa,x + lda FAC1_mantissa,x adc #$00 - sta basic_fac1_mantissa,x + sta FAC1_mantissa,x inx dey bne ij_loop2 @@ -146,10 +146,10 @@ erase_fac1: lda #$00 ldx #8 !: - sta basic_fac1_exponent,x + sta FAC1_exponent,x dex bpl !- - sta basic_fac1_mantissa_lob + sta FACOV rts diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s deleted file mode 100644 index 528f852f..00000000 --- a/c64/kernal/,aliases.s +++ /dev/null @@ -1,15 +0,0 @@ - -// XXX get rid of this file - -#if CONFIG_MEMORY_MODEL_60K - - // Under-ROM routines - // (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) - .label missed_nmi_flag = $2A7 - .label tiny_nmi_handler = $2A8 - .label peek_under_roms = tiny_nmi_handler+peek_under_roms_routine-tiny_nmi_handler_routine - .label poke_under_roms = tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine - .label memmap_allram = tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine - .label memmap_normal = tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - -#endif // CONFIG_MEMORY_MODEL_60K