fixin up mov arguments
This commit is contained in:
@ -36,9 +36,9 @@ module Arm
|
||||
end
|
||||
|
||||
def string_load block , str_lit , reg
|
||||
block << add( "r#{reg}".to_sym , :extra => str_lit ) #right is pc, implicit
|
||||
block << add( "r#{reg}".to_sym , str_lit , nil ) #right is pc, implicit
|
||||
#second arg is a hack to get the stringlength without coding
|
||||
block << mov( "r#{reg+1}".to_sym , right: str_lit.length )
|
||||
block << mov( "r#{reg+1}".to_sym , str_lit.length )
|
||||
str_lit
|
||||
end
|
||||
|
||||
@ -50,7 +50,7 @@ module Arm
|
||||
end
|
||||
|
||||
def main_start entry
|
||||
entry << mov( :fp , right: 0 )
|
||||
entry << mov( :fp , 0 )
|
||||
end
|
||||
def main_exit exit
|
||||
syscall(exit , 1)
|
||||
@ -66,9 +66,9 @@ module Arm
|
||||
# assumes string in r0 and r1 and moves them along for the syscall
|
||||
def write_stdout block
|
||||
block.instance_eval do
|
||||
mov( :r2 , right: :r1 )
|
||||
mov( :r1 , right: :r0 )
|
||||
mov( :r0 , right: 1 ) # 1 == stdout
|
||||
mov( :r2 , :r1 )
|
||||
mov( :r1 , :r0 )
|
||||
mov( :r0 , 1 ) # 1 == stdout
|
||||
end
|
||||
syscall( block , 4 )
|
||||
end
|
||||
@ -97,7 +97,7 @@ module Arm
|
||||
end
|
||||
|
||||
def syscall block , num
|
||||
block << mov( :r7 , right: num )
|
||||
block << mov( :r7 , num )
|
||||
block << swi( 0 , {})
|
||||
Vm::Integer.new(0) #small todo, is this actually correct for all (that they return int)
|
||||
end
|
||||
|
@ -3,8 +3,8 @@ module Arm
|
||||
class MoveInstruction < Vm::MoveInstruction
|
||||
include Arm::Constants
|
||||
|
||||
def initialize(first , attributes)
|
||||
super(first , attributes)
|
||||
def initialize(to , from , attributes)
|
||||
super(to , from , attributes)
|
||||
@attributes[:update_status] = 0 if @attributes[:update_status] == nil
|
||||
@attributes[:condition_code] = :al if @attributes[:condition_code] == nil
|
||||
@attributes[:opcode] = attributes[:opcode]
|
||||
@ -20,7 +20,7 @@ module Arm
|
||||
end
|
||||
|
||||
def build
|
||||
right = @attributes[:right]
|
||||
right = @from
|
||||
if right.is_a?(Vm::StringConstant)
|
||||
# do pc relative addressing with the difference to the instuction
|
||||
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
|
||||
@ -55,7 +55,7 @@ module Arm
|
||||
build
|
||||
instuction_class = 0b00 # OPC_DATA_PROCESSING
|
||||
val = shift(@operand , 0)
|
||||
val |= shift(reg_code(@first) , 12)
|
||||
val |= shift(reg_code(@to) , 12)
|
||||
val |= shift(reg_code(@rn) , 12+4)
|
||||
val |= shift(@attributes[:update_status] , 12+4+4)#20
|
||||
val |= shift(op_bit_code , 12+4+4 +1)
|
||||
|
Reference in New Issue
Block a user