Skip to content

Commit 84096e0

Browse files
committed
Remove _rom variable
1 parent eb8147a commit 84096e0

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/cpu/worker.mlog.jinja

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#% set labels.next_tick = 14
2929

30-
#% set labels.end_instruction_with_rd_and_poll_interrupts = 154
30+
#% set labels.end_instruction_with_rd_and_poll_interrupts = 153
3131
#% set labels.end_instruction_with_rd_and_fire_interrupts = _labels_vals|last + 1
3232
#% set labels.end_instruction_with_rd = _labels_vals|last + 1
3333
#% set labels.end_instruction = _labels_vals|last + 2
@@ -69,7 +69,20 @@ reset:
6969
#directive start_fetch
7070

7171
#% 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+
7386
read __etext prev_proc "__etext"
7487
read _address prev_proc "_address"
7588
read address prev_proc "address"
@@ -112,20 +125,6 @@ reset:
112125
read ret2 prev_proc "ret2"
113126
read ret3 prev_proc "ret3"
114127
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) }}"
129128
#% endmacro
130129

131130
#{ fetch_variables()
@@ -913,43 +912,44 @@ swap_endianness:
913912
# loads a word from ROM
914913
# address -> result
915914
load_rom_word_unchecked:
916-
#% do reset_locals()
915+
#% do declare_locals("$$rom", "$$str_index")
917916
# align to 4 bytes
918917
op and $address address 0xfffffffc
919918

920919
# get rom proc data
921920
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}}
923922

924923
op mod $rom_x $rom_index MEMORY_WIDTH
925924
op add $rom_x $rom_x MEMORY_X
926925

927926
op idiv $rom_y $rom_index MEMORY_WIDTH
928927
op add $rom_y $rom_y MEMORY_Y
929928

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"
932931

932+
#% do declare_locals("$$rom", "$$str_index")
933933
# read bytes of word
934-
read $byte0 _rom $str_index
934+
read $byte0 $$rom $$str_index
935935

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
938938

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
941941

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
944944

945945
# merge into big endian
946946
op shl $byte1 $byte1 8
947947
op shl $byte2 $byte2 16
948-
op shl _rom _rom 24
948+
op shl $$rom $$rom 24
949949

950950
op add result $byte0 $byte1
951951
op add result result $byte2
952-
op add result result _rom
952+
op add result result $$rom
953953

954954
op sub result result {{# ROM_BYTE_OFFSET * (1 + 2**8 + 2**16 + 2**24) }}
955955
op max result result 0 # if we're reading out of bounds, default to 0

0 commit comments

Comments
 (0)