2525#% set labels = namespace()
2626#% set _labels_vals = (labels|namespace_dict).values()
2727
28- #% set labels.next_tick = 14
28+ #% set labels.next_tick = 13
2929
30- #% set labels.end_instruction_with_rd_and_poll_interrupts = 157
30+ #% set labels.end_instruction_with_rd_and_poll_interrupts = 156
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
@@ -47,10 +47,9 @@ reset:
4747 read MEMORY_X {{CONFIG}} "MEMORY_X"
4848 read MEMORY_Y {{CONFIG}} "MEMORY_Y"
4949 read MEMORY_WIDTH {{CONFIG}} "MEMORY_WIDTH"
50- read PROGRAM_ROM_SIZE {{CONFIG}} "ROM_SIZE "
50+ read PROGRAM_ROM_ICACHE_SIZE {{CONFIG}} "PROGRAM_ROM_ICACHE_SIZE "
5151 read ROM_SIZE {{CONFIG}} "ROM_SIZE"
5252 read RAM_SIZE {{CONFIG}} "RAM_SIZE"
53- read ICACHE_SIZE {{CONFIG}} "ICACHE_SIZE"
5453 read RAM_END {{CONFIG}} "RAM_END"
5554 read ICACHE_END {{CONFIG}} "ICACHE_END"
5655 read RAM_ICACHE_OFFSET {{CONFIG}} "RAM_ICACHE_OFFSET"
@@ -2731,27 +2730,31 @@ MLOGSYS:
27312730 jump ILLEGAL_OP lessThan privilege_mode 0b11
27322731
27332732 # round up to the nearest page boundary
2734- op div rs1 rs1 4096
2735- op ceil rs1 rs1
2736- op mul rs1 rs1 4096
2733+ # if we're exactly on a page boundary, this results in decoding one extra page
2734+ # we use "variable" for this so we don't need to use an instruction to explicitly set it to null
2735+ # since we know reading from INCR at a numeric address will return null
2736+ op add variable rs1 4096
2737+ op and variable variable 0xfffff000
27372738
2738- op min __etext rs1 PROGRAM_ROM_SIZE
2739- op min __etext __etext ICACHE_SIZE
2739+ op min __etext variable PROGRAM_ROM_ICACHE_SIZE
27402740
2741- set address 0
2742- set variable null
2741+ # start at -4 so the first address read is 0
2742+ set address -4
2743+
2744+ #% set mlogsys_decode_loop = 5
2745+ #directive start_assert_length {{ mlogsys_decode_loop }}
2746+ op add address address 4
2747+ read variable {{INCR}} variable
27432748
2744- MLOGSYS__decode_loop:
27452749 # load_rom_word_unchecked does not clobber ram or variable
27462750 op add ret @counter 1
2747- jump load_rom_word_unchecked always
2748-
2749- op add ret3 @counter 1
2750- jump decode_value_in_result always
2751- read variable {{INCR}} variable
2751+ jump load_rom_word_unchecked lessThan address __etext
27522752
2753- op add address address 4
2754- jump MLOGSYS__decode_loop lessThan address __etext
2753+ # if address is in range, decode returns to the top of this loop
2754+ # otherwise, we continue to end_instruction
2755+ op sub ret3 @counter {{# mlogsys_decode_loop }}
2756+ #directive end_assert_length
2757+ jump decode_value_in_result lessThan address __etext
27552758
27562759 jump end_instruction always
27572760
0 commit comments