rename machine to linker
even work is not quite finished, but helps root out offenders (needless to say this is wip, deep red wip)
This commit is contained in:
parent
57fc67ddf6
commit
e10092a4be
@ -24,7 +24,8 @@ require_relative "risc/position/position"
|
|||||||
require_relative "risc/platform"
|
require_relative "risc/platform"
|
||||||
require "parfait"
|
require "parfait"
|
||||||
require_relative "risc/parfait_adapter"
|
require_relative "risc/parfait_adapter"
|
||||||
require_relative "risc/machine"
|
require_relative "risc/parfait_boot"
|
||||||
|
require_relative "risc/linker"
|
||||||
require_relative "risc/method_compiler"
|
require_relative "risc/method_compiler"
|
||||||
require_relative "risc/assembler"
|
require_relative "risc/assembler"
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ require_relative "collector"
|
|||||||
require_relative "binary_writer"
|
require_relative "binary_writer"
|
||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
# The Risc Machine is an abstraction of the register level. This is seperate from the
|
|
||||||
# actual assembler level to allow for several cpu architectures.
|
|
||||||
# The Instructions (see class Instruction) define what the machine can do (ie load/store/maths)
|
|
||||||
|
|
||||||
# From code, the next step down is Vool, then Mom (in two steps)
|
# From code, the next step down is Vool, then Mom (in two steps)
|
||||||
#
|
#
|
||||||
@ -12,14 +9,13 @@ module Risc
|
|||||||
# executes. The step after transforms to Arm, which creates executables.
|
# executes. The step after transforms to Arm, which creates executables.
|
||||||
#
|
#
|
||||||
|
|
||||||
class Machine
|
class Linker
|
||||||
include Util::Logging
|
include Util::Logging
|
||||||
log_level :info
|
log_level :info
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@risc_init = nil
|
@risc_init = nil
|
||||||
@constants = []
|
@constants = []
|
||||||
@next_address = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :constants , :cpu_init
|
attr_reader :constants , :cpu_init
|
||||||
@ -42,16 +38,6 @@ module Risc
|
|||||||
@constants << const
|
@constants << const
|
||||||
end
|
end
|
||||||
|
|
||||||
# hand out a return address for use as constant the address is added
|
|
||||||
def get_address
|
|
||||||
10.times do # 10 for whole pages
|
|
||||||
@next_address = Parfait::ReturnAddress.new(0,@next_address)
|
|
||||||
add_constant( @next_address )
|
|
||||||
end unless @next_address
|
|
||||||
addr = @next_address
|
|
||||||
@next_address = @next_address.next_integer
|
|
||||||
addr
|
|
||||||
end
|
|
||||||
|
|
||||||
# To create binaries, objects (and labels) need to have a position
|
# To create binaries, objects (and labels) need to have a position
|
||||||
# (so objects can be loaded and branches know where to jump)
|
# (so objects can be loaded and branches know where to jump)
|
||||||
@ -139,23 +125,12 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def boot
|
|
||||||
initialize
|
|
||||||
Position.clear_positions
|
|
||||||
Builtin.boot_functions
|
|
||||||
self
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Module function to retrieve singleton
|
# module method to reset, and init
|
||||||
def self.machine
|
def self.boot
|
||||||
unless defined?(@machine)
|
Position.clear_positions
|
||||||
@machine = Machine.new
|
Builtin.boot_functions
|
||||||
end
|
|
||||||
@machine
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative "parfait_boot"
|
|
@ -5,7 +5,8 @@ module Risc
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
@machine = Risc.machine.boot
|
Risc.boot
|
||||||
|
@machine = Linker.new
|
||||||
end
|
end
|
||||||
def test_objects
|
def test_objects
|
||||||
objects = @machine.object_positions
|
objects = @machine.object_positions
|
Loading…
x
Reference in New Issue
Block a user