mirror of
https://github.com/irmen/prog8.git
synced 2024-12-22 18:30:01 +00:00
comment about implementation in life example
This commit is contained in:
parent
44fec2c729
commit
d4d8e1b1ba
@ -1,14 +1,20 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
TODO creates buggy code in 6502: (ok in IR)
|
||||
TODO creates buggy code in 6502 (except PET!!!): (also ok in IR)
|
||||
main {
|
||||
sub start() {
|
||||
uword active_world = memory("world", 80*50, 0)
|
||||
uword cell_off = 500
|
||||
const uword STRIDE = 40
|
||||
sys.memset(active_world, 80*50, 1)
|
||||
|
||||
txt.print_ub(active_world[500] + active_world[501]) ; TODO prints 1, must be 2
|
||||
txt.nl()
|
||||
txt.print_ub(active_world[cell_off] + active_world[cell_off_1]) ; TODO prints 1, must be 2
|
||||
txt.nl()
|
||||
txt.print_ub(count()) ; TODO prints 1, must be 8
|
||||
txt.nl()
|
||||
|
||||
sub count() -> ubyte {
|
||||
return active_world[cell_off-STRIDE-1] + active_world[cell_off-STRIDE] + active_world[cell_off-STRIDE+1] +
|
||||
|
@ -95,6 +95,13 @@ main {
|
||||
if active_world == world1
|
||||
new_world = world2
|
||||
|
||||
; To avoid re-calculating word index lookups into the new- and active world arrays,
|
||||
; we calculate the required pointer values upfront.
|
||||
; Inside the loop we can use ptr+x just fine (results in efficient LDA (ptr),Y instruction because x is a byte type),
|
||||
; and for each row we simply add the stride to the pointer.
|
||||
; It's more readable to use active_world[offset] etc, but offset is a word value, and this produces
|
||||
; inefficient assembly code because we can't use a register indexed mode in this case. Costly inside a loop.
|
||||
|
||||
uword @requirezp new_world_ptr = new_world + STRIDE+1-DXOFFSET
|
||||
uword @requirezp active_world_ptr = active_world + STRIDE+1-DXOFFSET
|
||||
|
||||
|
@ -5,10 +5,17 @@
|
||||
main {
|
||||
sub start() {
|
||||
uword active_world = memory("world", 80*50, 0)
|
||||
uword cell_off = 500
|
||||
uword @shared cell_off = 500
|
||||
uword @shared cell_off_1 = cell_off+1
|
||||
const uword STRIDE = 40
|
||||
sys.memset(active_world, 80*50, 1)
|
||||
|
||||
txt.print_ub(active_world[500] + active_world[501]) ; TODO prints 1, must be 2
|
||||
txt.nl()
|
||||
txt.print_ub(active_world[cell_off] + active_world[cell_off_1]) ; TODO prints 1, must be 2
|
||||
txt.nl()
|
||||
txt.print_ub(count()) ; TODO prints 1, must be 8
|
||||
txt.nl()
|
||||
|
||||
sub count() -> ubyte {
|
||||
return active_world[cell_off-STRIDE-1] + active_world[cell_off-STRIDE] + active_world[cell_off-STRIDE+1] +
|
||||
|
Loading…
Reference in New Issue
Block a user