Merge branch 'main' into 5x5-display

This commit is contained in:
n loewen 2023-08-15 20:58:38 +01:00
commit 190592813d
4 changed files with 126 additions and 2 deletions

View File

@ -137,6 +137,8 @@ function decodeInstructions(line) {
addressingMode = "indirect";
arg_str = arg_str.replace("(=", "");
arg_str = arg_str.replace(")", "");
// FIXME - a quick hack to get around problems caused by another use of lower-casing to sanitize input:
arg_str = arg_str.toLowerCase();
dbg(2, `INDY - operand references '${arg_str}'`);
arg_str = constants[arg_str];

View File

@ -0,0 +1,60 @@
# Dev notes — 2023-08-12
Brainstorming/sketching around subroutines with a return stack...
; need an instruction for IP → A i guess?
; ideally…
; but a jump table would work
; put that at beginning of the code
; then store numbers for subroutine labels in a designated memory slot
lda $1
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 lets pretend it doesnt 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…
; wouldnt it be great to have a “hop if neg” op…
; do we have to just subtract numbers until we get 0?
; no!
; heres an approach thats 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 isnt quite it… we also need to chexk if we hit 0 by just deceementinf and if so retuen 0
jmp @jump_table

View File

@ -6,11 +6,11 @@
- [x] 'opcodes' and 'operands'
- [x] fix $00 contains $20 bug
- [ ] Review planned changes to the system
- [x] Review planned changes to the system
- [x] CHP, CFC -> FHP, FTG -- dev note 2023-08-07
- [/] bank-switching flag in 0 page
- added notes below, but decided to leave implementation for another day
- [ ] ? 5x5 display
- [x] ? 5x5 display
- [ ] Implement any changes necessary for writing a program?
- [ ] Write a program

View File

@ -0,0 +1,62 @@
;; sketching around subroutines with return stack
; 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
lda $1
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 lets pretend it doesnt 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…
; wouldnt it be great to have a “hop if neg” op…
; do we have to just subtract numbers until we get 0?
; no!
; heres an approach thats 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 isnt quite it… we also need to chexk if we hit 0 by just deceementinf and if so retuen 0
jmp @jump_table