Move the Main instruction from register to virtual
also needs a branch in register. This way the register level is self sufficient (noticed while writing debugger)
This commit is contained in:
@ -112,6 +112,7 @@ module Arm
|
||||
end
|
||||
Arm::ArmMachine.init
|
||||
require_relative "passes/call_implementation"
|
||||
require_relative "passes/branch_implementation"
|
||||
require_relative "passes/syscall_implementation"
|
||||
require_relative "passes/save_implementation"
|
||||
require_relative "passes/transfer_implementation"
|
||||
@ -119,4 +120,3 @@ require_relative "passes/get_implementation"
|
||||
require_relative "passes/set_implementation"
|
||||
require_relative "passes/return_implementation"
|
||||
require_relative "passes/constant_implementation"
|
||||
require_relative "passes/main_implementation"
|
||||
|
17
lib/arm/passes/branch_implementation.rb
Normal file
17
lib/arm/passes/branch_implementation.rb
Normal file
@ -0,0 +1,17 @@
|
||||
module Arm
|
||||
# This implements branch logic, which is simply assembler branch
|
||||
#
|
||||
# The only target for a call is a Block, so we just need to get the address for the code
|
||||
# and branch to it.
|
||||
#
|
||||
class BranchImplementation
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Register::Branch
|
||||
br = ArmMachine.b( code.block )
|
||||
block.replace(code , br )
|
||||
end
|
||||
end
|
||||
end
|
||||
Virtual.machine.add_pass "Arm::BranchImplementation"
|
||||
end
|
@ -1,17 +0,0 @@
|
||||
module Arm
|
||||
|
||||
# "Boot" the register machine at the function given
|
||||
# meaning jump to that function currently. Maybe better to do some machine setup
|
||||
# and possibly some cleanup/exit has to tie in, but that is not this day
|
||||
|
||||
class MainImplementation
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
next unless code.is_a? Register::RegisterMain
|
||||
call = ArmMachine.b( code.method )
|
||||
block.replace(code , call )
|
||||
end
|
||||
end
|
||||
end
|
||||
Virtual.machine.add_pass "Arm::MainImplementation"
|
||||
end
|
Reference in New Issue
Block a user