Remove 'test-programs' dir
This commit is contained in:
parent
072d2ccdb5
commit
3cc41b8b5a
|
|
@ -1,18 +0,0 @@
|
||||||
;; test addition and substraction
|
|
||||||
; with direct addressing...
|
|
||||||
LDA $FE
|
|
||||||
ADD $01 ; $FF
|
|
||||||
ADD $01 ; $00 + CF=1
|
|
||||||
ADD $01 ; $01 + CF=0
|
|
||||||
SUB $01 ; $00 + CF=0
|
|
||||||
SUB $01 ; $FF + CF=1
|
|
||||||
; and with indirect...
|
|
||||||
LDA $01
|
|
||||||
STO $00
|
|
||||||
LDA $FE
|
|
||||||
ADD ($00) ; $FF
|
|
||||||
ADD ($00) ; $00 + CF=1
|
|
||||||
ADD ($00) ; $01 + CF=0
|
|
||||||
SUB ($00) ; $00 + CF=0
|
|
||||||
SUB ($00) ; $00 + CF=1
|
|
||||||
END
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
;; Test constants
|
|
||||||
#foo $01
|
|
||||||
#bar $02
|
|
||||||
ADD #foo
|
|
||||||
STO #bar
|
|
||||||
STO (#bar)
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
; Routine for drawing at (x, y) coordinates
|
|
||||||
|
|
||||||
#zeroflag 1
|
|
||||||
|
|
||||||
; *** Set your desired (x, y) here: ***
|
|
||||||
#input_x 2
|
|
||||||
#input_y 2
|
|
||||||
|
|
||||||
; Set up some handy shortcuts
|
|
||||||
#x $FA
|
|
||||||
#y $FB
|
|
||||||
#return_addr_ptr $FE
|
|
||||||
|
|
||||||
|
|
||||||
; Main:
|
|
||||||
|
|
||||||
LDA #input_x
|
|
||||||
STO #x
|
|
||||||
LDA #input_y
|
|
||||||
STO #y
|
|
||||||
LDA * 6 ; acc = current address + 6 (LDA, STO, JMP = 6)
|
|
||||||
STO #return_addr_ptr
|
|
||||||
JMP @getxy
|
|
||||||
|
|
||||||
LDA $FF
|
|
||||||
STO ($FD)
|
|
||||||
END
|
|
||||||
|
|
||||||
;; Convert a pair of (x, y) coords
|
|
||||||
;; to the address of a pixel on the display
|
|
||||||
;;
|
|
||||||
;; Call with:
|
|
||||||
;; - x in #x
|
|
||||||
;; - y in #y
|
|
||||||
;; - return address in #return_addr_ptr
|
|
||||||
;;
|
|
||||||
;; Returns: pixel address in $FD
|
|
||||||
@getxy
|
|
||||||
#gxy_px $FD
|
|
||||||
|
|
||||||
; stash x...
|
|
||||||
LDA (#x)
|
|
||||||
STO #gxy_px
|
|
||||||
|
|
||||||
; check if this is row 0...
|
|
||||||
LDA (#y)
|
|
||||||
FHP #zeroflag
|
|
||||||
JMP @getxy_loop
|
|
||||||
JMP (#return_addr_ptr) ; if row 0, we're done
|
|
||||||
|
|
||||||
@getxy_loop
|
|
||||||
LDA (#gxy_px)
|
|
||||||
ADD 5 ; add 5 to get to the next row
|
|
||||||
STO #gxy_px
|
|
||||||
LDA (#y) ; decrement y (it's acting as a loop counter)...
|
|
||||||
SUB 1
|
|
||||||
STO #y
|
|
||||||
FHP #zeroflag
|
|
||||||
JMP @getxy_loop
|
|
||||||
JMP (#return_addr_ptr)
|
|
||||||
|
|
||||||
;; Main variables:
|
|
||||||
;; F8
|
|
||||||
;; F9
|
|
||||||
;; FA - x coord
|
|
||||||
;; FB - y coord
|
|
||||||
;; FC - gxy temp
|
|
||||||
;; FD - gxy temp
|
|
||||||
;; FE - Return address for subroutine
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
;; Fill display with $FF
|
|
||||||
; updated for 5x5 display
|
|
||||||
|
|
||||||
#Zero 1
|
|
||||||
#px_ptr $F0
|
|
||||||
#fill $F1
|
|
||||||
|
|
||||||
; Initialize variables...
|
|
||||||
LDA $00 ; (Address for the first px on the display)
|
|
||||||
STO #px_ptr ; Pointer to current px
|
|
||||||
LDA $FF ; ($FF is 'on', $00 is 'off')
|
|
||||||
STO #fill ; Stash value to fill with
|
|
||||||
|
|
||||||
@paint
|
|
||||||
LDA (#fill) ; (A = mem[fill] = $FF)
|
|
||||||
STO (#px_ptr); Paint pixel (mem[mem[*px]] = A = $FF)
|
|
||||||
|
|
||||||
LDA (#px_ptr) ; Increment pixel pointer...
|
|
||||||
ADD $01
|
|
||||||
STO #px_ptr
|
|
||||||
|
|
||||||
LDA (#px_ptr) ; Test whether to loop or not...
|
|
||||||
SUB $19 ; if *px - $19 == 0, we've reached the end
|
|
||||||
FHP #Zero
|
|
||||||
JMP @paint
|
|
||||||
END
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
;; test FHP and FTG for carry
|
|
||||||
ADD $FF ; Acc = $FF
|
|
||||||
FHP 0 ; shouldn't hop (CF = 0)
|
|
||||||
ADD 2 ; Acc = $01 and CF = 1
|
|
||||||
FHP 0 ; hop! (CF = 1)
|
|
||||||
END
|
|
||||||
SUB 1 ; Acc = $00, CF = 0
|
|
||||||
SUB 1 ; Acc = $FF, CF = 1
|
|
||||||
FTG 0 ; CF = 0
|
|
||||||
END
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
;; test overflow flag
|
|
||||||
; https://www.righto.com/2012/12/the-6502-overflow-flag-explained.html
|
|
||||||
|
|
||||||
LDA $50
|
|
||||||
ADD $10 ; CF, OF: 0 0
|
|
||||||
LDA $50
|
|
||||||
ADD $50 ; CF, OF: 0 1
|
|
||||||
LDA $50
|
|
||||||
ADD $90 ; CF, OF: 0 0
|
|
||||||
LDA $50
|
|
||||||
ADD $D0 ; CF, OF: 1 0
|
|
||||||
LDA $D0
|
|
||||||
ADD $10 ; CF, OF: 0 0
|
|
||||||
LDA $D0
|
|
||||||
ADD $50 ; CF, OF: 1 0
|
|
||||||
LDA $D0
|
|
||||||
ADD $90 ; CF, OF: 1 1
|
|
||||||
LDA $D0
|
|
||||||
ADD $D0 ; CF, OF: 1 0
|
|
||||||
|
|
||||||
LDA $50
|
|
||||||
SUB $F0 ; CF, OF: 1 0
|
|
||||||
LDA $50
|
|
||||||
SUB $B0 ; CF, OF: 1 1
|
|
||||||
LDA $50
|
|
||||||
SUB $70 ; CF, OF: 1 0
|
|
||||||
LDA $50
|
|
||||||
SUB $30 ; CF, OF: 0 0
|
|
||||||
LDA $D0
|
|
||||||
SUB $F0 ; CF, OF: 1 0
|
|
||||||
LDA $D0
|
|
||||||
SUB $B0 ; CF, OF: 0 0
|
|
||||||
LDA $D0
|
|
||||||
SUB $70 ; CF, OF: 0 1
|
|
||||||
LDA $D0
|
|
||||||
SUB $30 ; CF, OF: 0 0
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
;; test jumping to a label
|
|
||||||
|
|
||||||
ADD 15
|
|
||||||
ADD 10 ; should set CF
|
|
||||||
JMP @end
|
|
||||||
ADD 1
|
|
||||||
ADD 2
|
|
||||||
ADD 3
|
|
||||||
@end
|
|
||||||
END
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
;; Test keypad input
|
|
||||||
;; 2023-08-16
|
|
||||||
|
|
||||||
; The latest keypress is shown in the top left corner of the display.
|
|
||||||
; A loop counter is shown in the top right corner; the program ends when it reaches zero.
|
|
||||||
; (For a 4x4 display.)
|
|
||||||
|
|
||||||
#LOOPCOUNT $80
|
|
||||||
|
|
||||||
#Z 1 ; the zero flag is #1
|
|
||||||
#keypad $20 ; magic memory location containing latest key pressed
|
|
||||||
#loopIter $FF ; address of loop iterator
|
|
||||||
#iterPx $03 ; where to display iterator
|
|
||||||
#keyPx $00 ; where to display key
|
|
||||||
|
|
||||||
LDA #LOOPCOUNT
|
|
||||||
STO #loopIter
|
|
||||||
|
|
||||||
@loop
|
|
||||||
LDA (#loopIter)
|
|
||||||
STO #iterPx ; display loop iterator
|
|
||||||
LDA (#keypad)
|
|
||||||
STO #keyPx ; display latest keypress
|
|
||||||
LDA (#loopIter)
|
|
||||||
SUB 1
|
|
||||||
STO #loopIter
|
|
||||||
FTG #Z
|
|
||||||
FHP #Z
|
|
||||||
END
|
|
||||||
JMP @loop
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
;; Conway's Game of Life
|
|
||||||
; n loewen & Elizabeth Pankratz
|
|
||||||
; 2023-08-23 -
|
|
||||||
|
|
||||||
; Flag numbers for easier reference
|
|
||||||
#Carry 0
|
|
||||||
#Zero 1
|
|
||||||
|
|
||||||
#live_colour $FF
|
|
||||||
#dead_colour $00
|
|
||||||
|
|
||||||
#top_left $00
|
|
||||||
#top_right $04
|
|
||||||
#bot_left $14
|
|
||||||
#bot_right $18
|
|
||||||
|
|
||||||
#px_ptr $00
|
|
||||||
#live_neighbours_ptr $FF
|
|
||||||
|
|
||||||
; start of code
|
|
||||||
|
|
||||||
* $1D
|
|
||||||
|
|
||||||
@loop
|
|
||||||
LDA (#px_ptr)
|
|
||||||
|
|
||||||
; do something...
|
|
||||||
|
|
||||||
; increment pixel pointer
|
|
||||||
LDA (#px_ptr)
|
|
||||||
STA #px_ptr
|
|
||||||
JMP @loop
|
|
||||||
|
|
||||||
@check_for_tl_corner
|
|
||||||
LDA (#px_ptr)
|
|
||||||
; choose a memory location to stash result. 0=false, 1=true
|
|
||||||
HOP
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
||||||
; Draw a pixel, and move it when a key is pressed
|
|
||||||
; 2023-08-26
|
|
||||||
|
|
||||||
#flagZ 1
|
|
||||||
#flagN 2
|
|
||||||
#keypad $1B ; contains latest key pressed
|
|
||||||
|
|
||||||
; Starting (x, y) coordinates
|
|
||||||
#input_x 0
|
|
||||||
#input_y 0
|
|
||||||
|
|
||||||
; Some handy shortcuts
|
|
||||||
#x $FA
|
|
||||||
#y $FB
|
|
||||||
#px_addr $FD ; holds return value from @xy2id
|
|
||||||
#return_addr_ptr $FE
|
|
||||||
|
|
||||||
; Main variables:
|
|
||||||
; F8
|
|
||||||
; F9 - xy2id temp
|
|
||||||
; FA - x coord
|
|
||||||
; FB - y coord
|
|
||||||
; FC - xy2id temp
|
|
||||||
; FD - xy2id return value / xy2id temp
|
|
||||||
; FE - Return address for subroutine
|
|
||||||
|
|
||||||
|
|
||||||
@setup
|
|
||||||
LDA #input_x
|
|
||||||
STO #x
|
|
||||||
LDA #input_y
|
|
||||||
STO #y
|
|
||||||
LDA @update
|
|
||||||
STO #return_addr_ptr
|
|
||||||
JMP @xy2id
|
|
||||||
|
|
||||||
|
|
||||||
@update
|
|
||||||
; draw pixel
|
|
||||||
LDA $FF
|
|
||||||
STO (#px_addr)
|
|
||||||
|
|
||||||
; determine direction
|
|
||||||
#up 5
|
|
||||||
#left 7
|
|
||||||
#down 8
|
|
||||||
#right 9
|
|
||||||
|
|
||||||
; test up
|
|
||||||
lda (#keypad)
|
|
||||||
sub #up
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @up
|
|
||||||
|
|
||||||
; test left
|
|
||||||
lda (#keypad)
|
|
||||||
sub #left
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @left
|
|
||||||
|
|
||||||
; test right
|
|
||||||
lda (#keypad)
|
|
||||||
sub #right
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @right
|
|
||||||
|
|
||||||
; test down
|
|
||||||
lda (#keypad)
|
|
||||||
sub #down
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @down
|
|
||||||
|
|
||||||
;; no key pressed...
|
|
||||||
jmp @stay_put
|
|
||||||
|
|
||||||
|
|
||||||
@up
|
|
||||||
lda (#y)
|
|
||||||
sub 1
|
|
||||||
ftg #flagN
|
|
||||||
fhp #flagN
|
|
||||||
jmp @stay_put
|
|
||||||
sto #y
|
|
||||||
jmp @xy2id
|
|
||||||
|
|
||||||
@left
|
|
||||||
lda (#x)
|
|
||||||
sub 1
|
|
||||||
ftg #flagN
|
|
||||||
fhp #flagN
|
|
||||||
jmp @stay_put
|
|
||||||
sto #x
|
|
||||||
jmp @xy2id
|
|
||||||
|
|
||||||
@right
|
|
||||||
lda (#x)
|
|
||||||
sub 4
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @stay_put
|
|
||||||
lda (#x)
|
|
||||||
add 1
|
|
||||||
sto #x
|
|
||||||
jmp @xy2id
|
|
||||||
|
|
||||||
@down
|
|
||||||
lda (#y)
|
|
||||||
sub 4
|
|
||||||
ftg #flagZ
|
|
||||||
fhp #flagZ
|
|
||||||
jmp @stay_put
|
|
||||||
lda (#y)
|
|
||||||
add 1
|
|
||||||
sto #y
|
|
||||||
jmp @xy2id
|
|
||||||
|
|
||||||
@stay_put
|
|
||||||
; draw pixel
|
|
||||||
LDA $FF
|
|
||||||
STO (#px_addr)
|
|
||||||
; TODO
|
|
||||||
; END
|
|
||||||
|
|
||||||
|
|
||||||
;; Convert a pair of (x, y) coords
|
|
||||||
;; to the address of a pixel on the display
|
|
||||||
;;
|
|
||||||
;; Call with:
|
|
||||||
;; - x in #x
|
|
||||||
;; - y in #y
|
|
||||||
;; - return address in #return_addr_ptr
|
|
||||||
;;
|
|
||||||
;; Returns:
|
|
||||||
;; - pixel address in #px_addr
|
|
||||||
@xy2id
|
|
||||||
; stash x, y...
|
|
||||||
#xy2id_y $FC
|
|
||||||
#xy2id_x $F9
|
|
||||||
LDA (#y)
|
|
||||||
STO #xy2id_y
|
|
||||||
LDA (#x)
|
|
||||||
STO #xy2id_x
|
|
||||||
STO #px_addr
|
|
||||||
|
|
||||||
; check if this is row 0...
|
|
||||||
LDA (#xy2id_y)
|
|
||||||
FHP #flagZ
|
|
||||||
JMP @xy2id_loop
|
|
||||||
JMP (#return_addr_ptr) ; if row 0, we're done
|
|
||||||
|
|
||||||
@xy2id_loop
|
|
||||||
LDA (#px_addr)
|
|
||||||
ADD 5 ; add 5 to get to the next row
|
|
||||||
STO #px_addr
|
|
||||||
LDA (#xy2id_y) ; decrement y (it's acting as a loop counter) ...
|
|
||||||
SUB 1
|
|
||||||
STO #xy2id_y
|
|
||||||
FHP #flagZ
|
|
||||||
JMP @xy2id_loop
|
|
||||||
JMP (#return_addr_ptr)
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
;; test NOP
|
|
||||||
ADD $01
|
|
||||||
NOP
|
|
||||||
NOP
|
|
||||||
NOP
|
|
||||||
END
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
;; Test referencing address of line being assembled
|
|
||||||
|
|
||||||
* 30
|
|
||||||
|
|
||||||
NOP ; Push the const below to a later address
|
|
||||||
#initAddr *
|
|
||||||
|
|
||||||
LDA *
|
|
||||||
STO $25
|
|
||||||
FHP 0 ; hop if carry set
|
|
||||||
JMP @setCarry
|
|
||||||
LDA #initAddr
|
|
||||||
END
|
|
||||||
|
|
||||||
@setCarry
|
|
||||||
FTG 0
|
|
||||||
JMP ($25)
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
;; test re-locating display memory
|
|
||||||
LDA $10
|
|
||||||
STO $20 ; change pointer-to-display-memory to $10
|
|
||||||
STO $10
|
|
||||||
STO $11
|
|
||||||
STO $12
|
|
||||||
STO $13
|
|
||||||
END
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
;; sketching around subroutines with return stack
|
|
||||||
|
|
||||||
; I think the sketching below contains some useful ideas,
|
|
||||||
; but the new `*ADDR` assembly op should make this a whole lot simpler
|
|
||||||
|
|
||||||
; sketches follow ..........
|
|
||||||
|
|
||||||
; jump table
|
|
||||||
; ----------
|
|
||||||
; each function has a label
|
|
||||||
; and you can get to it with `JMP @label`
|
|
||||||
; ...but you can't push a label onto a stack
|
|
||||||
; so instead we give each function a number
|
|
||||||
; and stash that number in $24 when jumping to a subroutine
|
|
||||||
; then when the subroutine ends, it jumps here
|
|
||||||
; where that number gets mapped back onto the function's label
|
|
||||||
|
|
||||||
=*reentryPoint
|
|
||||||
=routine1 $1
|
|
||||||
|
|
||||||
lda =routine1
|
|
||||||
sto $19 ; contains ID # for the next fn to jump to
|
|
||||||
|
|
||||||
@jump_table
|
|
||||||
hop $1
|
|
||||||
jmp @jt2
|
|
||||||
jmp @example_computation
|
|
||||||
|
|
||||||
@jt2
|
|
||||||
hop $2
|
|
||||||
; jmp @jt3
|
|
||||||
nop
|
|
||||||
; etc …
|
|
||||||
|
|
||||||
jmp @end
|
|
||||||
|
|
||||||
@example_computation
|
|
||||||
lda 5
|
|
||||||
sto $20
|
|
||||||
lda 3
|
|
||||||
sto $21
|
|
||||||
; $19 still has the # for this routine
|
|
||||||
; but let’s pretend it doesn’t and demonstrate updating it
|
|
||||||
lda $1
|
|
||||||
sto $19
|
|
||||||
jmp @greater?
|
|
||||||
|
|
||||||
; call with numbers to test in $20 and $21
|
|
||||||
; result is stored in acc
|
|
||||||
@greater?
|
|
||||||
; lda ($20)
|
|
||||||
; sub ($21)
|
|
||||||
; todo…
|
|
||||||
; wouldn’t it be great to have a “hop if neg” op…
|
|
||||||
; do we have to just subtract numbers until we get 0?
|
|
||||||
|
|
||||||
; no!
|
|
||||||
; here’s an approach that’s at least better than that
|
|
||||||
lda ($21)
|
|
||||||
sto $22 ; stash
|
|
||||||
@loop
|
|
||||||
lda ($21)
|
|
||||||
sub $1
|
|
||||||
sto $22 ; stash
|
|
||||||
sub ($20)
|
|
||||||
hop $0
|
|
||||||
jmp @loop
|
|
||||||
sto $1
|
|
||||||
jmp $jmp_table
|
|
||||||
; ok this isn’t quite it… we also need to chexk if we hit 0 by just deceementinf and if so retuen 0
|
|
||||||
|
|
||||||
@end
|
|
||||||
END
|
|
||||||
Loading…
Reference in New Issue