From abcac12471eab8b40bb662e8da6cdc8f53874e1f Mon Sep 17 00:00:00 2001 From: hugova Date: Sun, 30 Mar 2025 16:14:41 +0200 Subject: [PATCH] Add test for memcpy --- wip-hugo/macros/16aritmatic.s | 280 ++++++++++++------------- wip-hugo/routines/memory/memcpy_test.s | 31 +++ 2 files changed, 171 insertions(+), 140 deletions(-) mode change 100755 => 100644 wip-hugo/macros/16aritmatic.s create mode 100644 wip-hugo/routines/memory/memcpy_test.s diff --git a/wip-hugo/macros/16aritmatic.s b/wip-hugo/macros/16aritmatic.s old mode 100755 new mode 100644 index 3f65591..2a02d06 --- a/wip-hugo/macros/16aritmatic.s +++ b/wip-hugo/macros/16aritmatic.s @@ -1,140 +1,140 @@ -;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- - -;; A file containing 16-bit macro arithmatic. -;; You may add ,! ass a 5:th parameter to skipp flagg clearing. -;; This will make it run faster but will have unintended behavior. - -;;Se below for some fast 16bit logic -;;http://6502.org/tutorials/compare_beyond.html - -;; Addition uses the A register -;; a = a + b -.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - CLC -.endif - LDA b_low - ADC a_low - STA a_low - LDA b_hi - ADC a_hi - STA a_hi -.endmacro - -;; Untested! -;; Addition uses the A register -;; a = a + b. b_low = A, b_hi = X -.macro Add_16_AX low, hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - CLC -.endif - ADC low - STA low - TXA - ADC hi - STA hi -.endmacro - -.macro Add_16_A a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - CLC -.endif - LDA a_low - ADC b_low - STA a_low - LDA b_hi - ADC a_hi - STA a_hi -.endmacro - -;; Subtraction uses the A register -;; a = a - b -.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - SEC -.endif - LDA a_low - SBC b_low - STA a_low - LDA a_hi - SBC b_hi - STA a_hi -.endmacro - -.macro Sub_16_A a_low, a_hi, b_low, b_hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - SEC -.endif - SBC b_low - STA a_low - LDA a_hi - SBC b_hi - STA a_hi -.endmacro - -;; Untested -;; Subtraction uses the A register -;; a = a - b. b_low = A, b_hi = X -.macro Sub_16_AX low, hi, fast_unsafe -;; IF to run it fast -.ifblank fast_unsafe - SEC -.endif - SBC low - STA low - TXA - SBC hi - STA hi -.endmacro - -;; Multiplication of 2 -;; a = a*2 -.macro Mult_16 low_, hi_, NOT_ROL -;; IF NOT_ROL -.ifblank fast_unsafe - ASL low_ - ROL hi_ -.else - ROL low_ - ROL hi_ -.endif -.endmacro - -.macro Mov_16 a_low, a_hi, b_low, b_hi - LDA b_low - STA a_low - LDA b_hi - STA a_hi -.endmacro - -;;Larger then operation, uses the A register -;;IF a < b then: jump to label -; C =0 if jump to LABEL -.macro Lag_16 a_low, a_hi, b_low, b_hi, label - LDA a_hi - CMP b_hi - BCC label - BNE LABEL - LDA a_low - CMP b_low - BCC label - LABEL: -.endmacro - -.macro Lag_16y a_low, a_hi, b_hi, label - LDA a_hi - CMP b_hi - BCC label - BNE LABEL - LDA a_low - STY next +1 -next: - CMP #$ff - BCC label - LABEL: -.endmacro +;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- + +;; A file containing 16-bit macro arithmatic. +;; You may add ,! ass a 5:th parameter to skipp flagg clearing. +;; This will make it run faster but will have unintended behavior. + +;;Se below for some fast 16bit logic +;;http://6502.org/tutorials/compare_beyond.html + +;; Addition uses the A register +;; a = a + b +.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + CLC +.endif + LDA b_low + ADC a_low + STA a_low + LDA b_hi + ADC a_hi + STA a_hi +.endmacro + +;; Untested! +;; Addition uses the A register +;; a = a + b. b_low = A, b_hi = X +.macro Add_16_AX low, hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + CLC +.endif + ADC low + STA low + TXA + ADC hi + STA hi +.endmacro + +.macro Add_16_A a_low, a_hi, b_low, b_hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + CLC +.endif + LDA a_low + ADC b_low + STA a_low + LDA b_hi + ADC a_hi + STA a_hi +.endmacro + +;; Subtraction uses the A register +;; a = a - b +.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + SEC +.endif + LDA a_low + SBC b_low + STA a_low + LDA a_hi + SBC b_hi + STA a_hi +.endmacro + +.macro Sub_16_A a_low, a_hi, b_low, b_hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + SEC +.endif + SBC b_low + STA a_low + LDA a_hi + SBC b_hi + STA a_hi +.endmacro + +;; Untested +;; Subtraction uses the A register +;; a = a - b. b_low = A, b_hi = X +.macro Sub_16_AX low, hi, fast_unsafe +;; IF to run it fast +.ifblank fast_unsafe + SEC +.endif + SBC low + STA low + TXA + SBC hi + STA hi +.endmacro + +;; Multiplication of 2 +;; a = a*2 +.macro Mult_16 low_, hi_, NOT_ROL +;; IF NOT_ROL +.ifblank fast_unsafe + ASL low_ + ROL hi_ +.else + ROL low_ + ROL hi_ +.endif +.endmacro + +.macro Mov_16 a_low, a_hi, b_low, b_hi + LDA b_low + STA a_low + LDA b_hi + STA a_hi +.endmacro + +;;Larger then operation, uses the A register +;;IF a < b then: jump to label +; C =0 if jump to LABEL +.macro Lag_16 a_low, a_hi, b_low, b_hi, label + LDA a_hi + CMP b_hi + BCC label + BNE LABEL + LDA a_low + CMP b_low + BCC label + LABEL: +.endmacro + +.macro Lag_16y a_low, a_hi, b_hi, label + LDA a_hi + CMP b_hi + BCC label + BNE LABEL + LDA a_low + STY next +1 +next: + CMP #$ff + BCC label + LABEL: +.endmacro diff --git a/wip-hugo/routines/memory/memcpy_test.s b/wip-hugo/routines/memory/memcpy_test.s new file mode 100644 index 0000000..bb0892b --- /dev/null +++ b/wip-hugo/routines/memory/memcpy_test.s @@ -0,0 +1,31 @@ +;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- +memcpy_test: + ;; TESTING OF MEMCPY TEMPERARLY HERE BECAUSE IT WILL USE THAT :) + X_pos = $FA + A_start = $FAFB + Y_pos = $F9 + B_start = $FCFD + charset = $FB + B_end = $FEFF + code = $FE + petski_position = $FEFF ;reuses code:s memory + screen_position = $FCFD + + + Mov_16 >B_start, $D000 + ;#### TEMP INIT DATA #### + Mov_16 >B_end, ($D000 +$1F3F) + LDA #$10 + STA code + LDA #$10 + STA X_pos + STA Y_pos + + + Mov_16 >A_start, VIC_bank + ;We first need to clear some memory + ;Mov_16 >A_end, >A_end, #<(VIC_bank+100), #>(VIC_bank +100) + LDA #$00 + JSR memcpy + STA