Add test for memcpy

This commit is contained in:
hugova 2025-03-30 16:14:41 +02:00
parent c0446ba5e2
commit abcac12471
2 changed files with 171 additions and 140 deletions

280
wip-hugo/macros/16aritmatic.s Executable file → Normal file
View file

@ -1,140 +1,140 @@
;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*- ;;; -*- Mode: asm; indent-tabs-mode: t; tab-width: 8 -*-
;; A file containing 16-bit macro arithmatic. ;; A file containing 16-bit macro arithmatic.
;; You may add ,! ass a 5:th parameter to skipp flagg clearing. ;; You may add ,! ass a 5:th parameter to skipp flagg clearing.
;; This will make it run faster but will have unintended behavior. ;; This will make it run faster but will have unintended behavior.
;;Se below for some fast 16bit logic ;;Se below for some fast 16bit logic
;;http://6502.org/tutorials/compare_beyond.html ;;http://6502.org/tutorials/compare_beyond.html
;; Addition uses the A register ;; Addition uses the A register
;; a = a + b ;; a = a + b
.macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe .macro Add_16 a_low, a_hi, b_low, b_hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
CLC CLC
.endif .endif
LDA b_low LDA b_low
ADC a_low ADC a_low
STA a_low STA a_low
LDA b_hi LDA b_hi
ADC a_hi ADC a_hi
STA a_hi STA a_hi
.endmacro .endmacro
;; Untested! ;; Untested!
;; Addition uses the A register ;; Addition uses the A register
;; a = a + b. b_low = A, b_hi = X ;; a = a + b. b_low = A, b_hi = X
.macro Add_16_AX low, hi, fast_unsafe .macro Add_16_AX low, hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
CLC CLC
.endif .endif
ADC low ADC low
STA low STA low
TXA TXA
ADC hi ADC hi
STA hi STA hi
.endmacro .endmacro
.macro Add_16_A a_low, a_hi, b_low, b_hi, fast_unsafe .macro Add_16_A a_low, a_hi, b_low, b_hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
CLC CLC
.endif .endif
LDA a_low LDA a_low
ADC b_low ADC b_low
STA a_low STA a_low
LDA b_hi LDA b_hi
ADC a_hi ADC a_hi
STA a_hi STA a_hi
.endmacro .endmacro
;; Subtraction uses the A register ;; Subtraction uses the A register
;; a = a - b ;; a = a - b
.macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe .macro Sub_16 a_low, a_hi, b_low, b_hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
SEC SEC
.endif .endif
LDA a_low LDA a_low
SBC b_low SBC b_low
STA a_low STA a_low
LDA a_hi LDA a_hi
SBC b_hi SBC b_hi
STA a_hi STA a_hi
.endmacro .endmacro
.macro Sub_16_A a_low, a_hi, b_low, b_hi, fast_unsafe .macro Sub_16_A a_low, a_hi, b_low, b_hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
SEC SEC
.endif .endif
SBC b_low SBC b_low
STA a_low STA a_low
LDA a_hi LDA a_hi
SBC b_hi SBC b_hi
STA a_hi STA a_hi
.endmacro .endmacro
;; Untested ;; Untested
;; Subtraction uses the A register ;; Subtraction uses the A register
;; a = a - b. b_low = A, b_hi = X ;; a = a - b. b_low = A, b_hi = X
.macro Sub_16_AX low, hi, fast_unsafe .macro Sub_16_AX low, hi, fast_unsafe
;; IF to run it fast ;; IF to run it fast
.ifblank fast_unsafe .ifblank fast_unsafe
SEC SEC
.endif .endif
SBC low SBC low
STA low STA low
TXA TXA
SBC hi SBC hi
STA hi STA hi
.endmacro .endmacro
;; Multiplication of 2 ;; Multiplication of 2
;; a = a*2 ;; a = a*2
.macro Mult_16 low_, hi_, NOT_ROL .macro Mult_16 low_, hi_, NOT_ROL
;; IF NOT_ROL ;; IF NOT_ROL
.ifblank fast_unsafe .ifblank fast_unsafe
ASL low_ ASL low_
ROL hi_ ROL hi_
.else .else
ROL low_ ROL low_
ROL hi_ ROL hi_
.endif .endif
.endmacro .endmacro
.macro Mov_16 a_low, a_hi, b_low, b_hi .macro Mov_16 a_low, a_hi, b_low, b_hi
LDA b_low LDA b_low
STA a_low STA a_low
LDA b_hi LDA b_hi
STA a_hi STA a_hi
.endmacro .endmacro
;;Larger then operation, uses the A register ;;Larger then operation, uses the A register
;;IF a < b then: jump to label ;;IF a < b then: jump to label
; C =0 if jump to LABEL ; C =0 if jump to LABEL
.macro Lag_16 a_low, a_hi, b_low, b_hi, label .macro Lag_16 a_low, a_hi, b_low, b_hi, label
LDA a_hi LDA a_hi
CMP b_hi CMP b_hi
BCC label BCC label
BNE LABEL BNE LABEL
LDA a_low LDA a_low
CMP b_low CMP b_low
BCC label BCC label
LABEL: LABEL:
.endmacro .endmacro
.macro Lag_16y a_low, a_hi, b_hi, label .macro Lag_16y a_low, a_hi, b_hi, label
LDA a_hi LDA a_hi
CMP b_hi CMP b_hi
BCC label BCC label
BNE LABEL BNE LABEL
LDA a_low LDA a_low
STY next +1 STY next +1
next: next:
CMP #$ff CMP #$ff
BCC label BCC label
LABEL: LABEL:
.endmacro .endmacro

View file

@ -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, <B_start, #<$D000, #>$D000
;#### TEMP INIT DATA ####
Mov_16 >B_end, <B_end, #<($D000+$1F3F), #>($D000 +$1F3F)
LDA #$10
STA code
LDA #$10
STA X_pos
STA Y_pos
Mov_16 >A_start, <A_start, #<VIC_bank, #>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 <petski_position
jmp exit