2019-10-03 20:07:55 +02:00
|
|
|
module SlotMachine
|
2019-09-11 19:17:43 +02:00
|
|
|
class Div10 < Macro
|
2019-09-11 18:23:56 +02:00
|
|
|
def to_risc(compiler)
|
|
|
|
s = "div_10 "
|
|
|
|
builder = compiler.builder(compiler.source)
|
|
|
|
integer_tmp = builder.allocate_int
|
2020-03-04 11:39:52 +01:00
|
|
|
integer_1 = builder.register( :integer_1 )
|
|
|
|
integer_reg = builder.register( :integer_reg )
|
|
|
|
integer_const = builder.register( :integer_const )
|
2019-09-11 18:23:56 +02:00
|
|
|
builder.build do
|
2020-03-11 21:54:20 +01:00
|
|
|
integer_self = message[:receiver].reduce_int(false)
|
2020-03-04 11:39:52 +01:00
|
|
|
transfer( integer_self , integer_1)
|
|
|
|
transfer( integer_self , integer_reg)
|
|
|
|
|
2020-03-08 11:05:25 +01:00
|
|
|
load_object( 1 , integer_const)
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :>> , integer_const , integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 2
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :>> , integer_const, integer_reg
|
|
|
|
integer_reg.op :+ , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 4
|
|
|
|
integer_1 << integer_reg
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :>> , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :+ , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 8
|
|
|
|
integer_1 << integer_reg
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :>> , integer_const, integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :+ , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 16
|
|
|
|
integer_1 << integer_reg
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :>> , integer_const, integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :+ , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 3
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :>> , integer_const, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 10
|
|
|
|
integer_1 << integer_reg
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :* , integer_const, integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_self.op :- , integer_1, integer_self
|
2019-09-11 18:23:56 +02:00
|
|
|
integer_1 << integer_self
|
|
|
|
|
|
|
|
integer_const << 6
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :+ , integer_const, integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_const << 4
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_1.op :>> , integer_const, integer_1
|
2019-09-11 18:23:56 +02:00
|
|
|
|
2020-03-14 11:47:29 +01:00
|
|
|
integer_reg.op :+ , integer_1, integer_reg
|
2019-09-11 18:23:56 +02:00
|
|
|
|
|
|
|
integer_tmp[Parfait::Integer.integer_index] << integer_reg
|
|
|
|
message[:return_value] << integer_tmp
|
|
|
|
|
|
|
|
end
|
|
|
|
return compiler
|
|
|
|
end
|
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|