diff --git a/src/hence/emulator.cr b/src/hence/emulator.cr index f9470bb..269d1fd 100644 --- a/src/hence/emulator.cr +++ b/src/hence/emulator.cr @@ -79,7 +79,7 @@ module Hence @reg_inp = 0_u16, @reg_out = 0_u16, @stack = Slice(UInt16).new({{ 8 * 1024 }}), - @memory = Slice(UInt16).new({{ 24 * 1024 }}) + @memory = Slice(UInt16).new({{ 16 * 1024 }}) ) end @@ -226,8 +226,10 @@ module Hence @program[address].to_u16 elsif address < {{ 40 * 1024 }} @stack[address - {{ 32 * 1024 }}] - else + elsif address < {{ 56 * 1024 }} @memory[address - {{ 40 * 1024 }}] + else + 0_u16 end end @@ -238,8 +240,10 @@ module Hence @stack[address - {{ 32 * 1024 }}] = value value - else + elsif address < {{ 56 * 1024 }} @memory[address - {{ 40 * 1024 }}] = value + else + 0_u16 end end end diff --git a/src/hence/firmware/documentation.md.ecr b/src/hence/firmware/documentation.md.ecr index 693d6a4..048d5b7 100644 --- a/src/hence/firmware/documentation.md.ecr +++ b/src/hence/firmware/documentation.md.ecr @@ -29,7 +29,7 @@ Opcode | Name <% output = " " + output unless output.blank? -%> Opcode | Argument | Stack ---|---|--- -`0x<%= sorted_opcodes.find! { |opc| opc[1].name == opcode.name }[0].to_s(16).rjust(2, '0') %>` | <%= opcode.arg && "`#{opcode.arg}`" %> | <%= (opcode.stack.input.size > 0 && opcode.stack.output.size > 0) ? "`#{input}--#{output}`" : nil %> +`0x<%= sorted_opcodes.find! { |opc| opc[1].name == opcode.name }[0].to_s(16).rjust(2, '0') %>` | <%= opcode.arg && "`#{opcode.arg}`" %> | <%= (opcode.stack.input.size > 0 || opcode.stack.output.size > 0) ? "`#{input}--#{output}`" : nil %> <%- if opcode.example -%> ```gnuassembler