lib/haxor/vm/cpu/unit/arithmetic.rb in haxor-0.1.0 vs lib/haxor/vm/cpu/unit/arithmetic.rb in haxor-0.2.0
- old
+ new
@@ -36,20 +36,20 @@
end
def op_div
a = operand
av = @vm.subsystem(:mem).read a
- arv = @vm.subsystem(:mem).read 'ar'
- @vm.subsystem(:mem).write 'ar', (arv / av)
- @vm.subsystem(:mem).write 'dr', (arv % av)
+ arv = @vm.subsystem(:registers).read 'ar'
+ @vm.subsystem(:registers).write 'ar', (arv / av)
+ @vm.subsystem(:registers).write 'dr', (arv % av)
end
def op_mul
a = operand
av = @vm.subsystem(:mem).read a
- arv = @vm.subsystem(:mem).read 'ar'
- @vm.subsystem(:mem).write 'ar', (arv * av)
+ arv = @vm.subsystem(:registers).read 'ar'
+ @vm.subsystem(:registers).write 'ar', (arv * av)
end
def op_inc
a = operand
av = @vm.subsystem(:mem).read a
@@ -65,26 +65,12 @@
def op_cmp
a, b = operands
av = @vm.subsystem(:mem).read a
bv = @vm.subsystem(:mem).read b
v = av - bv
- fr_set Consts::FR_ZERO, (v == 0)
- fr_set Consts::FR_SIGN, v < 0
- end
- def fr_set(b, enable)
- flags = fetch_cell 'fr'
- if enable
- flags |= b
- else
- flags &= ~b
- end
- replace_cell 'fr', flags
- end
-
- def fr_if(b)
- flags = fetch_cell 'fr'
- (flags & b) > 0
+ @vm.subsystem(:registers).flag Consts::FR_ZERO, v == 0
+ @vm.subsystem(:registers).flag Consts::FR_SIGN, v < 0
end
end
end
end
end