Compare commits
3 commits
c0446ba5e2
...
9768287b86
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9768287b86 | ||
![]() |
1144fd01ca | ||
![]() |
abcac12471 |
3 changed files with 86 additions and 57 deletions
|
@ -7,64 +7,82 @@
|
||||||
;;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 always 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
|
||||||
|
.if .not .match ({b_low}, a)
|
||||||
LDA b_low
|
LDA b_low
|
||||||
|
.endif ;;untested
|
||||||
ADC a_low
|
ADC a_low
|
||||||
STA a_low
|
STA a_low
|
||||||
LDA b_hi
|
.if .match ({b_hi}, x) ;;Untested
|
||||||
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
|
TXA
|
||||||
ADC hi
|
.else
|
||||||
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
|
LDA b_hi
|
||||||
|
.endif
|
||||||
ADC a_hi
|
ADC a_hi
|
||||||
STA a_hi
|
STA a_hi
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
;; Subtraction uses the A register
|
|
||||||
|
;; Subtraction uses always uses 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
|
||||||
|
;; if b_low = A and b_hi =A
|
||||||
|
.if .match({b_low}, a) .and .match({b_hi}, a) ;;untested
|
||||||
|
.LOCAL rewrite
|
||||||
|
.LOCAL rewrite2
|
||||||
|
STA rewrite +1
|
||||||
|
STA rewrite2 + 1
|
||||||
|
LDA a_low
|
||||||
|
rewrite:
|
||||||
|
SBC #b_low
|
||||||
|
STA a_low
|
||||||
|
LDA a_hi
|
||||||
|
rewrite2:
|
||||||
|
SBC #b_hi
|
||||||
|
STA a_hi
|
||||||
|
;; if b_low = A
|
||||||
|
.elseif .match({b_low}, a) ;;untested
|
||||||
|
.LOCAL rewrite
|
||||||
|
STA rewrite +1
|
||||||
|
LDA a_low
|
||||||
|
rewrite:
|
||||||
|
SBC #b_low
|
||||||
|
STA a_low
|
||||||
|
LDA a_hi
|
||||||
|
SBC b_hi
|
||||||
|
STA a_hi
|
||||||
|
.elseif .match({b_hi}, a) ;;untested
|
||||||
|
.LOCAL rewrite
|
||||||
|
STA rewrite +1
|
||||||
|
LDA a_low
|
||||||
|
SBC b_low
|
||||||
|
STA a_low
|
||||||
|
LDA a_hi
|
||||||
|
rewrite:
|
||||||
|
SBC #b_hi
|
||||||
|
STA a_hi
|
||||||
|
.else
|
||||||
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
|
||||||
|
.endif
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
;; Subtraction uses always uses A register
|
||||||
|
;; a = (A, a_hi) - b
|
||||||
.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
|
||||||
|
@ -77,20 +95,6 @@
|
||||||
STA a_hi
|
STA a_hi
|
||||||
.endmacro
|
.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
|
;; Multiplication of 2
|
||||||
;; a = a*2
|
;; a = a*2
|
||||||
|
@ -112,29 +116,25 @@
|
||||||
STA a_hi
|
STA a_hi
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
;;http://www.6502.org/tutorials/compare_beyond.html
|
||||||
;;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
|
||||||
|
.LOCAL 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
|
.if .match ({b_low}, a)
|
||||||
BCC label
|
.LOCAL next
|
||||||
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
|
STY next +1
|
||||||
next:
|
next:
|
||||||
CMP #$ff
|
CMP #$ff
|
||||||
|
.else
|
||||||
|
CMP b_low
|
||||||
|
.endif
|
||||||
BCC label
|
BCC label
|
||||||
LABEL:
|
LABEL:
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
|
@ -18,9 +18,7 @@
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA >B_start
|
STA >B_start
|
||||||
loop:
|
loop:
|
||||||
;Lag_16 >B_end, <B_end, >B_start, <B_start, end_loop
|
Lag_16 >B_end, <B_end, A, <B_start, end_loop
|
||||||
Lag_16y >B_end, <B_end, <B_start, end_loop
|
|
||||||
;Lag_16y <B_start, >B_end, <B_end, end_loop ; IF B_end >B_start stop the loop
|
|
||||||
LDA (>B_start), Y
|
LDA (>B_start), Y
|
||||||
STA (>A_start), Y
|
STA (>A_start), Y
|
||||||
;Tip save time by counting downward, fast to check if Y ==0 // hugo
|
;Tip save time by counting downward, fast to check if Y ==0 // hugo
|
||||||
|
|
31
wip-hugo/routines/memory/memcpy_test.s
Normal file
31
wip-hugo/routines/memory/memcpy_test.s
Normal 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
|
Loading…
Add table
Reference in a new issue