small bugfixes,

This commit is contained in:
zongor 2026-02-11 22:46:24 -08:00
parent 3ee4442b3d
commit 7fdd4b66b0
3 changed files with 6 additions and 5 deletions

View File

@ -18,8 +18,8 @@ bool init_vm() {
return true;
}
u32 syscall(u32 id, u32 size, u32 mem_ptr) {
USED(size);
u32 syscall(u32 id, u32 device, u32 mem_ptr) {
USED(device);
switch(id) {
case SYSCALL_CONSOLE_WRITE: {
u32 size = *(u32*)&mem[mem_ptr];
@ -30,6 +30,7 @@ u32 syscall(u32 id, u32 size, u32 mem_ptr) {
return 0;
}
case SYSCALL_CONSOLE_READ: {
u32 size;
u8 *ptr = &mem[mp];
mcpy(ptr, &size, sizeof(u32));
ptr += 4;

View File

@ -608,7 +608,7 @@ bool step_vm() {
u32 i = 0, j = 0;
i32 q = (i32)locals[src1];
char buffer[MAX_LEN_INT32];
char buffer[12];
u32 int_part, frac_part;
if (q < 0) {
@ -641,7 +641,7 @@ bool step_vm() {
frac_part &= 0xFFFF;
}
locals[dest] = str_alloc(buffer + i, MAX_LEN_INT32 - i);
locals[dest] = str_alloc(buffer + i, 12 - i);
return pc;
}

View File

@ -32,7 +32,7 @@ typedef enum {
OP_HALT, /* halt : A : all zeros : halt execution */
OP_CALL, /* call : A : dest args return : creates a new frame */
OP_RETURN, /* return : B : dest return_flags : returns from a frame to the parent frame */
OP_SYSCALL, /* syscall : A : id args mem_ptr : does a system call based on id with args */
OP_SYSCALL, /* syscall : A : id device mem_ptr : does a system call based on id with args */
OP_LOAD_IMM, /* load_immediate : B : locals[dest] = const as u16 */
OP_LOAD_UPPER_IMM, /* load_upper_immediate : B : locals[dest] = const as u32 << 16 | u16 */
OP_LOAD_IND_8, /* load_indirect_8 : A : locals[dest] = memory[locals[src1]] as u8 */