define and use syscall_XX registers
rather than use hardcoded r0 etc use syscall_X change the syscalls and interpreter to use them later use platform to map from syscall_X to actually used register (like r0 in arm)
This commit is contained in:
@ -19,6 +19,13 @@ module Risc
|
||||
def to_s
|
||||
class_source name
|
||||
end
|
||||
end
|
||||
|
||||
# return the nth register that a sycall needs
|
||||
# these map to different physical registers in the Platform
|
||||
# first arg is (running 1..) integer, second (optional) type
|
||||
def self.syscall_reg( number , type = nil)
|
||||
type = :Integer unless type
|
||||
RegisterValue.new("syscall_#{number}".to_sym , type)
|
||||
end
|
||||
end
|
||||
|
@ -257,12 +257,12 @@ module Risc
|
||||
else
|
||||
raise "un-implemented syscall #{name}"
|
||||
end
|
||||
set_register( :r0 , ret_value ) # syscalls return into r0 , usually some int
|
||||
set_register( :syscall_1 , ret_value ) # syscalls return into syscall_1
|
||||
true
|
||||
end
|
||||
|
||||
def handle_putstring
|
||||
str = get_register( :r1 ) # should test length, ie r2
|
||||
str = get_register( :"syscall_1" ) # should test length, ie r2
|
||||
case str
|
||||
when Symbol
|
||||
@stdout << str.to_s
|
||||
|
Reference in New Issue
Block a user