tests for word macros

This commit is contained in:
2019-09-11 18:53:20 +03:00
parent f264aec94a
commit e8bfb9a58c
10 changed files with 148 additions and 13 deletions

View File

@ -6,7 +6,7 @@ module Mom
integer_tmp = builder.allocate_int
builder.build do
object! << message[:receiver]
integer! << message[:arg1] #"at"
integer! << message[:arg1] #"at"
integer.reduce_int
object <= object[integer]
integer_tmp[Parfait::Integer.integer_index] << object
@ -16,4 +16,19 @@ module Mom
end
end
end
class GetInternalByte < ::Mom::Instruction
def to_risc(compiler)
builder = compiler.builder(compiler.source)
integer_tmp = builder.allocate_int
builder.build do
object! << message[:receiver]
integer! << message[:arg1] #"at"
integer.reduce_int
object <= object[integer]
integer_tmp[Parfait::Integer.integer_index] << object
message[:return_value] << integer_tmp
end
return compiler
end
end
end

View File

@ -13,4 +13,16 @@ module Mom
end
end
end
class Putstring < ::Mom::Instruction
def to_risc(compiler)
builder = compiler.builder(compiler.source)
builder.prepare_int_return # makes integer_tmp variable as return
builder.build do
word! << message[:receiver]
integer! << word[Parfait::Word.get_length_index]
end
Mom::Builtin.emit_syscall( builder , :putstring )
compiler
end
end
end

View File

@ -6,7 +6,7 @@ module Mom
word! << message[:receiver]
integer_reg! << message[:arg2] #VALUE
message[:return_value] << integer_reg
integer! << message[:arg1] #"index"
integer! << message[:arg1] #"index"
integer.reduce_int
integer_reg.reduce_int
word[integer] <= integer_reg
@ -15,4 +15,18 @@ module Mom
end
end
end
class SetInternalByte < ::Mom::Instruction
def to_risc(compiler)
compiler.builder(compiler.source).build do
word! << message[:receiver]
integer_reg! << message[:arg2] #VALUE
message[:return_value] << integer_reg
integer! << message[:arg1] #"index"
integer.reduce_int
integer_reg.reduce_int
word[integer] <= integer_reg
end
return compiler
end
end
end

View File

@ -14,4 +14,17 @@ module Mom
end
end
end
class SetInternalWord < ::Mom::Instruction
def to_risc(compiler)
compiler.builder(compiler.source).build do
object! << message[:receiver]
integer! << message[:arg1] # "index"
object_reg! << message[:arg2]#"value"
integer.reduce_int
object[integer] << object_reg
message[:return_value] << object_reg
end
return compiler
end
end
end