From 3cc41b8b5afda4e7f86069fdab3a17e40e6e8451 Mon Sep 17 00:00:00 2001 From: n loewen Date: Tue, 29 Aug 2023 08:34:01 -0400 Subject: [PATCH] Remove 'test-programs' dir --- test-programs/add-sub.asm | 18 -- test-programs/constants.asm | 6 - test-programs/draw-xy.asm | 69 -------- test-programs/fill-display.asm | 26 --- test-programs/flag-carry--fhp-ftg.asm | 10 -- test-programs/flag-overflow.asm | 36 ---- test-programs/jmp-to-label.asm | 10 -- test-programs/keypad.asm | 30 ---- test-programs/life.asm | 37 ---- test-programs/move-pixel-with-keypad.asm | 164 ------------------ test-programs/nop.asm | 6 - ...encing-program-counter-during-assembly.asm | 17 -- test-programs/relocate-display-mem.asm | 8 - test-programs/subroutines.asm | 73 -------- 14 files changed, 510 deletions(-) delete mode 100644 test-programs/add-sub.asm delete mode 100644 test-programs/constants.asm delete mode 100644 test-programs/draw-xy.asm delete mode 100644 test-programs/fill-display.asm delete mode 100644 test-programs/flag-carry--fhp-ftg.asm delete mode 100644 test-programs/flag-overflow.asm delete mode 100644 test-programs/jmp-to-label.asm delete mode 100644 test-programs/keypad.asm delete mode 100644 test-programs/life.asm delete mode 100644 test-programs/move-pixel-with-keypad.asm delete mode 100644 test-programs/nop.asm delete mode 100644 test-programs/referencing-program-counter-during-assembly.asm delete mode 100644 test-programs/relocate-display-mem.asm delete mode 100644 test-programs/subroutines.asm diff --git a/test-programs/add-sub.asm b/test-programs/add-sub.asm deleted file mode 100644 index 2052728..0000000 --- a/test-programs/add-sub.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/constants.asm b/test-programs/constants.asm deleted file mode 100644 index 3fb4978..0000000 --- a/test-programs/constants.asm +++ /dev/null @@ -1,6 +0,0 @@ -;; Test constants -#foo $01 -#bar $02 -ADD #foo -STO #bar -STO (#bar) \ No newline at end of file diff --git a/test-programs/draw-xy.asm b/test-programs/draw-xy.asm deleted file mode 100644 index 8db87f3..0000000 --- a/test-programs/draw-xy.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/fill-display.asm b/test-programs/fill-display.asm deleted file mode 100644 index 1c28218..0000000 --- a/test-programs/fill-display.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/flag-carry--fhp-ftg.asm b/test-programs/flag-carry--fhp-ftg.asm deleted file mode 100644 index cee29d2..0000000 --- a/test-programs/flag-carry--fhp-ftg.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/flag-overflow.asm b/test-programs/flag-overflow.asm deleted file mode 100644 index 86dabb4..0000000 --- a/test-programs/flag-overflow.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/jmp-to-label.asm b/test-programs/jmp-to-label.asm deleted file mode 100644 index 258c806..0000000 --- a/test-programs/jmp-to-label.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/keypad.asm b/test-programs/keypad.asm deleted file mode 100644 index 91e7350..0000000 --- a/test-programs/keypad.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/life.asm b/test-programs/life.asm deleted file mode 100644 index 9107e96..0000000 --- a/test-programs/life.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/move-pixel-with-keypad.asm b/test-programs/move-pixel-with-keypad.asm deleted file mode 100644 index 23cebc7..0000000 --- a/test-programs/move-pixel-with-keypad.asm +++ /dev/null @@ -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) \ No newline at end of file diff --git a/test-programs/nop.asm b/test-programs/nop.asm deleted file mode 100644 index 81f8793..0000000 --- a/test-programs/nop.asm +++ /dev/null @@ -1,6 +0,0 @@ -;; test NOP -ADD $01 -NOP -NOP -NOP -END \ No newline at end of file diff --git a/test-programs/referencing-program-counter-during-assembly.asm b/test-programs/referencing-program-counter-during-assembly.asm deleted file mode 100644 index 1a43688..0000000 --- a/test-programs/referencing-program-counter-during-assembly.asm +++ /dev/null @@ -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) \ No newline at end of file diff --git a/test-programs/relocate-display-mem.asm b/test-programs/relocate-display-mem.asm deleted file mode 100644 index 784066b..0000000 --- a/test-programs/relocate-display-mem.asm +++ /dev/null @@ -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 \ No newline at end of file diff --git a/test-programs/subroutines.asm b/test-programs/subroutines.asm deleted file mode 100644 index 137e951..0000000 --- a/test-programs/subroutines.asm +++ /dev/null @@ -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 \ No newline at end of file