Add number of registers to platform
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
module Risc
|
||||
|
||||
# A BlockCompiler is much like a MethodCompiler, exept for it's for blocks
|
||||
# This only changes scoping for variables, lsee slot_type
|
||||
# This only changes scoping for variables, see slot_type
|
||||
# (dynamic resolve, as needed when the block is passed, is not implemented)
|
||||
#
|
||||
class BlockCompiler < CallableCompiler
|
||||
|
||||
|
@ -25,6 +25,7 @@ module Risc
|
||||
end
|
||||
attr_reader :risc_instructions , :constants , :callable , :current
|
||||
|
||||
# find the return label. Every methd should have exactly one
|
||||
def return_label
|
||||
@risc_instructions.each do |ins|
|
||||
next unless ins.is_a?(Label)
|
||||
@ -33,6 +34,7 @@ module Risc
|
||||
end
|
||||
|
||||
# add a constant (which get created during compilation and need to be linked)
|
||||
# constants must be Parfait instances
|
||||
def add_constant(const)
|
||||
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
|
||||
@constants << const
|
||||
|
@ -29,7 +29,7 @@ module Risc
|
||||
@registers = {}
|
||||
@flags = { :zero => false , :plus => false ,
|
||||
:minus => false , :overflow => false }
|
||||
(0...12).each do |reg|
|
||||
(0...InterpreterPlatform.new.num_registers).each do |reg|
|
||||
set_register "r#{reg}".to_sym , "r#{reg}:unknown"
|
||||
end
|
||||
@linker = linker
|
||||
|
@ -10,6 +10,9 @@ module Risc
|
||||
def padding
|
||||
0x100 - loaded_at
|
||||
end
|
||||
def num_registers
|
||||
16
|
||||
end
|
||||
end
|
||||
class Instruction
|
||||
def nil_next
|
||||
|
@ -13,6 +13,11 @@ module Risc
|
||||
# return an integer where the binary is loaded
|
||||
def loaded_at
|
||||
end
|
||||
|
||||
# return the number of registers the platform supports
|
||||
def num_registers
|
||||
end
|
||||
|
||||
# Factory method to create a Platform object according to the platform
|
||||
# string given.
|
||||
# Currently only "Arm" and "Interpreter"
|
||||
|
Reference in New Issue
Block a user