mirror of
https://github.com/guilhermewerner/machine
synced 2025-06-16 13:14:18 +00:00
Update heap, stack and opcodes
This commit is contained in:
@ -17,7 +17,7 @@ pub fn LoadRegister(vm: &mut Machine) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn SaveRegister(vm: &mut Machine) -> bool {
|
||||
pub fn StoreRegister(vm: &mut Machine) -> bool {
|
||||
let (addr, reg) = Payload::GetAddressRegister(vm);
|
||||
|
||||
let data = vm.registry.Get(reg);
|
||||
@ -28,6 +28,28 @@ pub fn SaveRegister(vm: &mut Machine) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub fn IncrementRegister(vm: &mut Machine) -> bool {
|
||||
let r0 = Payload::GetRegister(vm);
|
||||
|
||||
let a = u32::from_be_bytes(vm.registry.Get(r0));
|
||||
|
||||
vm.registry.Set(r0, (a + 1).to_be_bytes());
|
||||
vm.Walk(2);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
pub fn DecrementRegister(vm: &mut Machine) -> bool {
|
||||
let r0 = Payload::GetRegister(vm);
|
||||
|
||||
let a = u32::from_be_bytes(vm.registry.Get(r0));
|
||||
|
||||
vm.registry.Set(r0, (a - 1).to_be_bytes());
|
||||
vm.Walk(2);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn Move(_vm: &mut Machine) -> bool {
|
||||
false
|
||||
|
Reference in New Issue
Block a user