some helper functions
for when i started the assembler div10 in the end i did the div10 in some, so no need
This commit is contained in:
parent
4a8bb32039
commit
9ab3de234d
@ -16,6 +16,9 @@ module Register
|
||||
"LoadConstant: #{register} <- #{constant_str}"
|
||||
end
|
||||
|
||||
def self.load source , constant , register
|
||||
LoadConstant.new source , constant , register
|
||||
end
|
||||
private
|
||||
def constant_str
|
||||
case @constant
|
||||
|
@ -13,6 +13,9 @@ module Register
|
||||
"OperatorInstruction: #{left} #{operator} #{right}"
|
||||
end
|
||||
|
||||
def self.op source , operator , left , right
|
||||
OperatorInstruction.new source , operator , left , right
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -29,5 +29,8 @@ module Register
|
||||
"RegisterTransfer: #{from} -> #{to}"
|
||||
end
|
||||
|
||||
def self.transfer source , from , to
|
||||
RegisterTransfer.new source , from , to
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -119,6 +119,12 @@ module Soml
|
||||
return reg
|
||||
end
|
||||
|
||||
def copy reg , source
|
||||
copied = use_reg reg.type
|
||||
add_code Reister.transfer source , reg , copied
|
||||
copied
|
||||
end
|
||||
|
||||
# releasing a register (accuired by use_reg) makes it available for use again
|
||||
# thus avoiding possibly using too many registers
|
||||
def release_reg reg
|
||||
|
Loading…
Reference in New Issue
Block a user