2017-01-19 09:02:29 +02:00
|
|
|
module Risc
|
2015-06-22 22:48:42 +03:00
|
|
|
|
|
|
|
# name says it all really
|
|
|
|
# only arg is the method syscall name
|
|
|
|
# how the layer below executes these is really up to it
|
|
|
|
|
|
|
|
# Any function issuing a Syscall should also save the current message
|
|
|
|
# and restore it after the syscall, saving the return value in Return_index
|
|
|
|
|
|
|
|
class Syscall < Instruction
|
|
|
|
|
2015-07-27 12:13:39 +03:00
|
|
|
def initialize source ,name
|
|
|
|
super(source)
|
2015-06-22 22:48:42 +03:00
|
|
|
@name = name
|
2018-03-22 18:38:19 +02:00
|
|
|
raise "must have name" unless name
|
2015-06-22 22:48:42 +03:00
|
|
|
end
|
|
|
|
attr_reader :name
|
2015-07-24 13:23:56 +03:00
|
|
|
|
2020-03-18 17:49:23 +02:00
|
|
|
# return an array of names of registers that is used by the instruction
|
2020-03-20 13:58:40 +02:00
|
|
|
def register_attributes
|
2020-03-18 17:49:23 +02:00
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2015-07-24 13:23:56 +03:00
|
|
|
def to_s
|
2018-03-22 18:38:19 +02:00
|
|
|
class_source name
|
2015-07-24 13:23:56 +03:00
|
|
|
end
|
2020-03-16 17:31:14 +02:00
|
|
|
end
|
2015-07-24 13:23:56 +03:00
|
|
|
|
2020-03-16 17:31:14 +02:00
|
|
|
# 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)
|
2015-06-22 22:48:42 +03:00
|
|
|
end
|
|
|
|
end
|