move message to stack_pointer

changing a bunch of register names
some of which get names now
This commit is contained in:
2020-03-22 11:29:56 +02:00
parent a93a3c8af5
commit be684c0c43
17 changed files with 78 additions and 68 deletions

View File

@ -47,6 +47,14 @@ module Risc
trigger(:state_changed , old , state )
end
# return the name of the register that the argument is mapped to
# this info is in the Platform object in the linker instance
# eg: syscall_1 maps to :r0 , and :message to :r13
# So as not to hardcode values (as used to )
def std_reg(name)
@linker.platform.assign_reg?(name)
end
# set all flags to false
def reset_flags
@flags = { :zero => false , :plus => false ,
@ -258,7 +266,7 @@ module Risc
set_instruction(nil)
return false
when :died
raise "Method #{@registers[:r1]} not found for #{@registers[:r0].receiver}"
raise "Method #{@registers[std_reg(:syscall_2)]} not found for #{@registers[std_reg(:syscall_2)]}"
else
raise "un-implemented syscall #{name}"
end

View File

@ -20,7 +20,7 @@ module Risc
# does not include :message
# could be in interpreter and arm, but here for now
def register_names
(1 ... 16).collect{|i| "r#{i}".to_sym }
(0 .. 12).collect{|i| "r#{i}".to_sym }
end
# return the Allocator for the platform
@ -35,13 +35,13 @@ module Risc
def assign_reg?(name)
case name
when :message
:r0
:r13
when :syscall_1
:r0
when :syscall_2
:r1
when :saved_message
:r15
:r14
else
nil
end