From 7d663615b2a44715e7447a40cae467d7d4e38b9c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 14 Sep 2019 00:52:24 +0200 Subject: Start on opengl test, fix stack alignment before call (sys-v) --- include/bytecode/bytecode.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'include/bytecode') diff --git a/include/bytecode/bytecode.h b/include/bytecode/bytecode.h index c495d7a..a93fe4f 100644 --- a/include/bytecode/bytecode.h +++ b/include/bytecode/bytecode.h @@ -8,8 +8,8 @@ #include -/*doc(Opcode) - Variable length opcodes. Sizes range from 1 to 5 bytes. +/*doc(Instructions) + Variable length instructions. Instruction size ranges from 1 to 5 bytes. # Instruction formats Instructions can be in 7 different formats: 1. 1 byte: Opcode(u8) @@ -25,7 +25,8 @@ 6.1 Opcode(u8) + register(i8) + label(i16)\ 6.2 Opcode(u8) + register(i8) + intermediate(u16)\ 6.3 Opcode(u8) + register(i8) + data(u16)\ - 6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16) + 6.4 Opcode(u8) + flags(u8) + num_local_var_reg(u16)\ + 6.5 Opcode(u8) + stack_offset(i24) 7. 5 bytes: Opcode(u8) + index(u8) + index(u16) + num_args(u8) # Registers Registers have a range of 128. Local variables start from register 0 and increment while parameters start from -1 @@ -93,6 +94,19 @@ typedef struct { } BytecodeHeaderFunction; #pragma pack(pop) +/* TODO: Make sure this pragma pack works on all platforms */ +#pragma pack(push, 1) +typedef struct { + u8 num_params; + u32 params_num_pointers; + u32 params_fixed_size; + + u8 num_return_types; + u32 return_types_num_pointers; + u32 return_types_fixed_size; +} BytecodeHeaderExternFunction; +#pragma pack(pop) + /* TODO: Make sure this pragma pack works on all platforms */ #pragma pack(push, 1) typedef struct { -- cgit v1.2.3