From b4400344143a2e2475c4c03ee941093585e8c732 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 19 Jul 2020 12:56:51 +0200 Subject: [PATCH] optimization in variable search --- src/basic/engine_editor/find_line_46K_50K.s | 7 ++-- .../is_line_pointer_null_46K_50K.s | 11 ++---- src/basic/engine_variables/fetch_variable.s | 11 ++++-- .../helper_cmp_varnam_46K_50K.s | 38 +++++++++++++++++++ .../helper_strdesccpy_46K_50K.s | 2 +- 5 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 src/basic/engine_variables/helper_cmp_varnam_46K_50K.s diff --git a/src/basic/engine_editor/find_line_46K_50K.s b/src/basic/engine_editor/find_line_46K_50K.s index da797733..a62d8635 100644 --- a/src/basic/engine_editor/find_line_46K_50K.s +++ b/src/basic/engine_editor/find_line_46K_50K.s @@ -25,7 +25,7 @@ find_line_from_current: // Check if line is not empty - jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM + jsr line_pointer_null_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM beq remap_BASIC_sec_rts // search failed if there is no program // Fetch the high byte of line number and compare @@ -52,7 +52,7 @@ find_line_next: // Advance to the next line - jsr find_line_null_ptr_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM + jsr line_pointer_null_check // we can't use 'is_line_pointer_null', it maps out/in the BASIC ROM beq remap_BASIC_sec_rts // search failed if no more line exists ldy #$00 @@ -68,7 +68,7 @@ find_line_next: jmp_8 find_line_from_current -find_line_null_ptr_check: +line_pointer_null_check: // reused by 'is_line_pointer_null' // Check the pointer @@ -82,7 +82,6 @@ find_line_null_ptr_check: !: rts - remap_BASIC_clc_rts: lda #$27 diff --git a/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s b/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s index 0f743885..8ffc839d 100644 --- a/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s +++ b/src/basic/engine_runtime/is_line_pointer_null_46K_50K.s @@ -16,15 +16,9 @@ is_line_pointer_null: lda #$26 sta CPU_R6510 - // Check the pointer + // Check the pointer - reuse code from other routine - ldy #$01 // for non-NULL pointer, high byte is almost certainly not NULL - lda (OLDTXT),y - bne !+ // branch if pointer not NULL - - dey - lda (OLDTXT),y -!: + jsr line_pointer_null_check // Restore memory mapping and quit @@ -32,6 +26,7 @@ is_line_pointer_null: lda #$27 sta CPU_R6510 plp + rts #endif diff --git a/src/basic/engine_variables/fetch_variable.s b/src/basic/engine_variables/fetch_variable.s index 1c8cc5be..348fc6d2 100644 --- a/src/basic/engine_variables/fetch_variable.s +++ b/src/basic/engine_variables/fetch_variable.s @@ -130,13 +130,15 @@ fetch_variable_find_addr_loop: // Compare current variable name with searched one // XXX consider creating optimized version for 46K/50K memory models +#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K + jsr helper_cmp_varnam +#else + ldy #$00 #if CONFIG_MEMORY_MODEL_60K ldx #