rename acc -> flag since it really doesnt accumulate anything, could be confusing to devs

This commit is contained in:
zongor 2025-09-20 08:46:09 -07:00
parent b8832a7116
commit cf0318e96f
2 changed files with 18 additions and 18 deletions

View File

@ -105,7 +105,7 @@ typedef struct vm_s {
u32 rp; /* return stack pointer (top of stack) */ u32 rp; /* return stack pointer (top of stack) */
u32 mp; /* memory pointer (last allocated value) */ u32 mp; /* memory pointer (last allocated value) */
u32 dc; /* device count */ 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 */ Frame frames[FRAMES_SIZE]; /* function call frames */
u32 stack[STACK_SIZE]; /* main stack */ u32 stack[STACK_SIZE]; /* main stack */
u32 return_stack[STACK_SIZE]; /* return stack (for call recursion) */ u32 return_stack[STACK_SIZE]; /* return stack (for call recursion) */

View File

@ -155,15 +155,15 @@ bool step_vm(VM *vm) {
if (dev) { if (dev) {
if (dev->ops->open) { if (dev->ops->open) {
vm->acc = dev->ops->open(dev->data, mode); vm->flag = dev->ops->open(dev->data, mode);
} else { } else {
vm->acc = 1; /* success, no open needed */ vm->flag = 1; /* success, no open needed */
} }
} else { } else {
vm->acc = 0; /* error */ vm->flag = 0; /* error */
} }
} else { } else {
vm->acc = 0; /* error: not enough arguments */ vm->flag = 0; /* error: not enough arguments */
} }
return true; return true;
} }
@ -181,13 +181,13 @@ bool step_vm(VM *vm) {
dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]); dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]);
if (dev && dev->ops->read) { if (dev && dev->ops->read) {
vm->acc = vm->flag =
dev->ops->read(dev->data, (u8 *)&vm->memory[buffer_ptr], size); dev->ops->read(dev->data, (u8 *)&vm->memory[buffer_ptr], size);
} else { } else {
vm->acc = 0; vm->flag = 0;
} }
} else { } else {
vm->acc = 0; /* error: not enough arguments */ vm->flag = 0; /* error: not enough arguments */
} }
return true; return true;
} }
@ -204,13 +204,13 @@ bool step_vm(VM *vm) {
dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]); dev = find_device_by_path(vm, (const char *)&vm->memory[path_ptr + 4]);
if (dev && dev->ops->write) { 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); size);
} else { } else {
vm->acc = 0; vm->flag = 0;
} }
} else { } else {
vm->acc = 0; /* error: not enough arguments */ vm->flag = 0; /* error: not enough arguments */
} }
return true; return true;
} }
@ -226,12 +226,12 @@ bool step_vm(VM *vm) {
if (dev && dev->ops->close) { if (dev && dev->ops->close) {
i32 result = dev->ops->close(dev->data); i32 result = dev->ops->close(dev->data);
vm->acc = result; vm->flag = result;
} else { } else {
vm->acc = 0; vm->flag = 0;
} }
} else { } else {
vm->acc = 0; /* error: not enough arguments */ vm->flag = 0; /* error: not enough arguments */
} }
return true; return true;
} }
@ -251,12 +251,12 @@ bool step_vm(VM *vm) {
if (dev && dev->ops && dev->ops->ioctl) { if (dev && dev->ops && dev->ops->ioctl) {
i32 result = dev->ops->ioctl(dev->data, cmd, &vm->memory[args_ptr]); i32 result = dev->ops->ioctl(dev->data, cmd, &vm->memory[args_ptr]);
vm->acc = result; vm->flag = result;
} else { } else {
vm->acc = 0; /* error or no ioctl support */ vm->flag = 0; /* error or no ioctl support */
} }
} else { } else {
vm->acc = 0; /* error: not enough arguments */ vm->flag = 0; /* error: not enough arguments */
} }
return true; return true;
} }
@ -266,7 +266,7 @@ bool step_vm(VM *vm) {
} }
default: { default: {
vm->acc = 0; /* unknown syscall */ vm->flag = 0; /* unknown syscall */
return true; return true;
} }
} }