From 1bd765dbce40112a20911a0774bbb7827c64595b Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Fri, 9 Feb 2018 16:46:53 +0000 Subject: [PATCH] Begin using static in the demo game. --- HISTORY.md | 1 + README.md | 8 -------- eg/proto-game.60p | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 24c3593..cba79b4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ History of SixtyPical as `ld a, [ptr] + y` and `st a, [ptr] + y`. * Implements the "union rule for trashes" when analyzing `if` blocks. * Even if we `goto` another routine, we can't trash an output. +* `static` storage locations local to routines can now be defined within routines. * Fixed bug where `trash` was not marking the location as being virtually altered. 0.11 diff --git a/README.md b/README.md index 1a99d5f..6def8c8 100644 --- a/README.md +++ b/README.md @@ -59,14 +59,6 @@ This should be tracked in the abstract interpretation. Range-checking buffers might be too difficult. Range checking tables will be easier. If a value is ANDed with 15, its range must be 0-15, etc. -### Routine-local static memory locations - -These would not need to appear in the inputs/outputs/trashes sets of the routines -that call this routine. - -These might be forced to specify an initial value so that they can always be -assumed to be meaningful. - ### Re-order routines and optimize tail-calls to fallthroughs Not because it saves 3 bytes, but because it's a neat trick. Doing it optimally diff --git a/eg/proto-game.60p b/eg/proto-game.60p index 3eeb21d..dd9578f 100644 --- a/eg/proto-game.60p +++ b/eg/proto-game.60p @@ -37,7 +37,7 @@ typedef routine outputs button_down, dispatch_game_state, actor_pos, actor_delta, actor_logic, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - trashes a, x, y, c, z, n, v, pos, new_pos, delta, ptr, save_x, compare_target, dispatch_logic + trashes a, x, y, c, z, n, v, pos, new_pos, delta, ptr, compare_target, dispatch_logic game_state_routine // @@ -93,7 +93,6 @@ vector logic_routine dispatch_logic byte button_down : 0 // effectively static-local to check_button byte table[32] press_fire_msg: "PRESS`FIRE`TO`PLAY" -byte save_x word compare_target // @@ -410,6 +409,7 @@ define game_state_title_screen game_state_routine } define game_state_play game_state_routine +static byte save_x : 0 { ld x, 0 repeat {