bshell: re-organise build into three separate components
bshell: the front-end binary bshell.runtime: contains the parser, compiler, and classes needed to run bshell scripts bshell.core: contains the builtin commandlets and aliases
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#include <bshell/runtime/opcode.h>
|
||||
#include <fx/int.h>
|
||||
|
||||
#define BSHELL_OPCODE_MAX 0xFF
|
||||
#define ARG_MAX 0xFFFFFF
|
||||
|
||||
bshell_instruction bshell_instruction_encode(
|
||||
enum bshell_opcode opcode,
|
||||
uint32_t arg)
|
||||
{
|
||||
if (opcode > BSHELL_OPCODE_MAX) {
|
||||
return BSHELL_INSTRUCTION_INVALID;
|
||||
}
|
||||
|
||||
return fx_u32_htob((opcode & BSHELL_OPCODE_MAX) | (arg & ARG_MAX) << 8);
|
||||
}
|
||||
|
||||
void bshell_instruction_decode(
|
||||
bshell_instruction instr,
|
||||
enum bshell_opcode *out_opcode,
|
||||
uint32_t *out_arg)
|
||||
{
|
||||
instr = fx_u32_btoh(instr);
|
||||
*out_opcode = (instr & BSHELL_OPCODE_MAX);
|
||||
*out_arg = ((instr >> 8) & ARG_MAX);
|
||||
}
|
||||
Reference in New Issue
Block a user