|
27 | 27 |
|
28 | 28 | #% set labels.next_tick = 14 |
29 | 29 |
|
30 | | -#% set labels.end_instruction_with_rd_and_poll_interrupts = 154 |
| 30 | +#% set labels.end_instruction_with_rd_and_poll_interrupts = 153 |
31 | 31 | #% set labels.end_instruction_with_rd_and_fire_interrupts = _labels_vals|last + 1 |
32 | 32 | #% set labels.end_instruction_with_rd = _labels_vals|last + 1 |
33 | 33 | #% set labels.end_instruction = _labels_vals|last + 2 |
@@ -69,7 +69,20 @@ reset: |
69 | 69 | #directive start_fetch |
70 | 70 |
|
71 | 71 | #% macro fetch_variables() |
72 | | - read _rom prev_proc "_rom" |
| 72 | +#% do reset_locals() |
| 73 | + read {{local_variable()}} prev_proc "{{ local_variable(1) }}" |
| 74 | + read {{local_variable()}} prev_proc "{{ local_variable(2) }}" |
| 75 | + read {{local_variable()}} prev_proc "{{ local_variable(3) }}" |
| 76 | + read {{local_variable()}} prev_proc "{{ local_variable(4) }}" |
| 77 | + read {{local_variable()}} prev_proc "{{ local_variable(5) }}" |
| 78 | + read {{local_variable()}} prev_proc "{{ local_variable(6) }}" |
| 79 | + read {{local_variable()}} prev_proc "{{ local_variable(7) }}" |
| 80 | + read {{local_variable()}} prev_proc "{{ local_variable(8) }}" |
| 81 | + read {{local_variable()}} prev_proc "{{ local_variable(9) }}" |
| 82 | + |
| 83 | + read nonlocal1 prev_proc "nonlocal1" |
| 84 | + read nonlocal2 prev_proc "nonlocal2" |
| 85 | + |
73 | 86 | read __etext prev_proc "__etext" |
74 | 87 | read _address prev_proc "_address" |
75 | 88 | read address prev_proc "address" |
@@ -112,20 +125,6 @@ reset: |
112 | 125 | read ret2 prev_proc "ret2" |
113 | 126 | read ret3 prev_proc "ret3" |
114 | 127 | read ret4 prev_proc "ret4" |
115 | | - |
116 | | - read nonlocal1 prev_proc "nonlocal1" |
117 | | - read nonlocal2 prev_proc "nonlocal2" |
118 | | - |
119 | | -#% do reset_locals() |
120 | | - read {{local_variable()}} prev_proc "{{ local_variable(1) }}" |
121 | | - read {{local_variable()}} prev_proc "{{ local_variable(2) }}" |
122 | | - read {{local_variable()}} prev_proc "{{ local_variable(3) }}" |
123 | | - read {{local_variable()}} prev_proc "{{ local_variable(4) }}" |
124 | | - read {{local_variable()}} prev_proc "{{ local_variable(5) }}" |
125 | | - read {{local_variable()}} prev_proc "{{ local_variable(6) }}" |
126 | | - read {{local_variable()}} prev_proc "{{ local_variable(7) }}" |
127 | | - read {{local_variable()}} prev_proc "{{ local_variable(8) }}" |
128 | | - read {{local_variable()}} prev_proc "{{ local_variable(9) }}" |
129 | 128 | #% endmacro |
130 | 129 |
|
131 | 130 | #{ fetch_variables() |
@@ -913,43 +912,44 @@ swap_endianness: |
913 | 912 | # loads a word from ROM |
914 | 913 | # address -> result |
915 | 914 | load_rom_word_unchecked: |
916 | | -#% do reset_locals() |
| 915 | +#% do declare_locals("$$rom", "$$str_index") |
917 | 916 | # align to 4 bytes |
918 | 917 | op and $address address 0xfffffffc |
919 | 918 |
|
920 | 919 | # get rom proc data |
921 | 920 | op idiv $rom_index $address {{ROM_PROC_BYTES}} |
922 | | - op mod $str_index $address {{ROM_PROC_BYTES}} |
| 921 | + op mod $$str_index $address {{ROM_PROC_BYTES}} |
923 | 922 |
|
924 | 923 | op mod $rom_x $rom_index MEMORY_WIDTH |
925 | 924 | op add $rom_x $rom_x MEMORY_X |
926 | 925 |
|
927 | 926 | op idiv $rom_y $rom_index MEMORY_WIDTH |
928 | 927 | op add $rom_y $rom_y MEMORY_Y |
929 | 928 |
|
930 | | - getblock building _rom $rom_x $rom_y |
931 | | - read _rom _rom "v" |
| 929 | + getblock building $$rom $rom_x $rom_y |
| 930 | + read $$rom $$rom "v" |
932 | 931 |
|
| 932 | +#% do declare_locals("$$rom", "$$str_index") |
933 | 933 | # read bytes of word |
934 | | - read $byte0 _rom $str_index |
| 934 | + read $byte0 $$rom $$str_index |
935 | 935 |
|
936 | | - op add $str_index $str_index 1 |
937 | | - read $byte1 _rom $str_index |
| 936 | + op add $$str_index $$str_index 1 |
| 937 | + read $byte1 $$rom $$str_index |
938 | 938 |
|
939 | | - op add $str_index $str_index 1 |
940 | | - read $byte2 _rom $str_index |
| 939 | + op add $$str_index $$str_index 1 |
| 940 | + read $byte2 $$rom $$str_index |
941 | 941 |
|
942 | | - op add $str_index $str_index 1 |
943 | | - read _rom _rom $str_index # clear _rom to avoid issues with the vars menu and block data size |
| 942 | + op add $$str_index $$str_index 1 |
| 943 | + read $$rom $$rom $$str_index # overwrite rom variable to avoid issues with the vars menu and block data size |
944 | 944 |
|
945 | 945 | # merge into big endian |
946 | 946 | op shl $byte1 $byte1 8 |
947 | 947 | op shl $byte2 $byte2 16 |
948 | | - op shl _rom _rom 24 |
| 948 | + op shl $$rom $$rom 24 |
949 | 949 |
|
950 | 950 | op add result $byte0 $byte1 |
951 | 951 | op add result result $byte2 |
952 | | - op add result result _rom |
| 952 | + op add result result $$rom |
953 | 953 |
|
954 | 954 | op sub result result {{# ROM_BYTE_OFFSET * (1 + 2**8 + 2**16 + 2**24) }} |
955 | 955 | op max result result 0 # if we're reading out of bounds, default to 0 |
|
0 commit comments