diff --git a/src/opcodes.h b/src/opcodes.h index e42ab70..d1b1acf 100644 --- a/src/opcodes.h +++ b/src/opcodes.h @@ -105,7 +105,7 @@ typedef struct vm_s { u32 rp; /* return stack pointer (top of stack) */ u32 mp; /* memory pointer (last allocated value) */ u32 dc; /* device count */ - u32 acc; /* accumulator (temporary results like SYSCALL status) */ + u32 flag; /* flag (temporary results like SYSCALL status) */ Frame frames[FRAMES_SIZE]; /* function call frames */ u32 stack[STACK_SIZE]; /* main stack */ u32 return_stack[STACK_SIZE]; /* return stack (for call recursion) */ diff --git a/src/vm.c b/src/vm.c index 395893c..5efb9bc 100644 --- a/src/vm.c +++ b/src/vm.c @@ -155,15 +155,15 @@ bool step_vm(VM *vm) { if (dev) { if (dev->ops->open) { - vm->acc = dev->ops->open(dev->data, mode); + vm->flag = dev->ops->open(dev->data, mode); } else { - vm->acc = 1; /* success, no open needed */ + vm->flag = 1; /* success, no open needed */ } } else { - vm->acc = 0; /* error */ + vm->flag = 0; /* error */ } } else { - vm->acc = 0; /* error: not enough arguments */ + vm->flag = 0; /* error: not enough arguments */ } return true; } @@ -181,13 +181,13 @@ bool step_vm(VM *vm) { dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]); if (dev && dev->ops->read) { - vm->acc = + vm->flag = dev->ops->read(dev->data, (u8 *)&vm->memory[buffer_ptr], size); } else { - vm->acc = 0; + vm->flag = 0; } } else { - vm->acc = 0; /* error: not enough arguments */ + vm->flag = 0; /* error: not enough arguments */ } return true; } @@ -204,13 +204,13 @@ bool step_vm(VM *vm) { dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]); if (dev && dev->ops->write) { - vm->acc = dev->ops->write(dev->data, (const u8 *)&vm->memory[buffer_ptr + 4], + vm->flag = dev->ops->write(dev->data, (const u8 *)&vm->memory[buffer_ptr + 4], size); } else { - vm->acc = 0; + vm->flag = 0; } } else { - vm->acc = 0; /* error: not enough arguments */ + vm->flag = 0; /* error: not enough arguments */ } return true; } @@ -226,12 +226,12 @@ bool step_vm(VM *vm) { if (dev && dev->ops->close) { i32 result = dev->ops->close(dev->data); - vm->acc = result; + vm->flag = result; } else { - vm->acc = 0; + vm->flag = 0; } } else { - vm->acc = 0; /* error: not enough arguments */ + vm->flag = 0; /* error: not enough arguments */ } return true; } @@ -251,12 +251,12 @@ bool step_vm(VM *vm) { if (dev && dev->ops && dev->ops->ioctl) { i32 result = dev->ops->ioctl(dev->data, cmd, &vm->memory[args_ptr]); - vm->acc = result; + vm->flag = result; } else { - vm->acc = 0; /* error or no ioctl support */ + vm->flag = 0; /* error or no ioctl support */ } } else { - vm->acc = 0; /* error: not enough arguments */ + vm->flag = 0; /* error: not enough arguments */ } return true; } @@ -266,7 +266,7 @@ bool step_vm(VM *vm) { } default: { - vm->acc = 0; /* unknown syscall */ + vm->flag = 0; /* unknown syscall */ return true; } }