Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-alvin committed Dec 1, 2023
1 parent c3fb56d commit ba304a4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
9 changes: 7 additions & 2 deletions libjas/aaa.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
#include "write.h"
#include <stdint.h>

jasErrorCode_t aaa(jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, uint8_t **buffer, jasInstance_t instance) {
*buffer = write8(buffer, 0x37, sizeof(buffer) / sizeof(uint8_t));
jasErrorCode_t aaa(jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, jasInstance_t *instance) {
if (instance->mode == JAS_MODE_64)
return JAS_ERROR_NON_LONG_MODE_INSTRUCTION;

instance->buffer = write8(instance->buffer, 0x37, instance->bufferLen);
instance->bufferLen++;

return JAS_NO_ERROR;
}
2 changes: 1 addition & 1 deletion libjas/include/aaa.h → libjas/aaa.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include "init.h"
#include <stdint.h>

jasErrorCode_t aaa(jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, uint8_t *buffer, jasInstance_t instance);
jasErrorCode_t aaa(jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, jasInstance_t *instance);
8 changes: 5 additions & 3 deletions libjas/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
#include "null.h"
#include <stdint.h>

jasErrorCode_t codegen(jasInstruction_t instruction, jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, uint8_t *buf, jasInstance_t instance) {
if (buf == NULL)
jasErrorCode_t codegen(jasInstruction_t instruction, jasOperand_t op1, jasOperand_t op2, jasOperand_t op3, jasOperand_t op4, jasInstance_t *instance) {
if (instance->buffer == NULL)
return JAS_ERROR_UNDEFINED_POINTER;

jasInstructionEncoderPointerArray_t jasInstructionEncoder = {&aaa};

if (instruction > sizeof(jasInstructionEncoder) / sizeof(&aaa))
return JAS_ERROR_INVALID_INSTRUCTION;

return jasInstructionEncoder[instruction](op1, op2, op3, op4, &buf, instance);
const jasErrorCode_t errorCode = jasInstructionEncoder[instruction](op1, op2, op3, op4, instance);

return errorCode;
}
2 changes: 1 addition & 1 deletion libjas/include/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ typedef union {
uint64_t u64;
} jasOperand_t;

typedef jasErrorCode_t (*jasInstructionEncoderPointerArray_t[])(jasOperand_t, jasOperand_t, jasOperand_t, jasOperand_t, uint8_t *, jasInstance_t);
typedef jasErrorCode_t (*jasInstructionEncoderPointerArray_t[])(jasOperand_t, jasOperand_t, jasOperand_t, jasOperand_t, jasInstance_t);
1 change: 1 addition & 0 deletions libjas/include/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef enum {
JAS_NO_ERROR,
JAS_ERROR_UNDEFINED_POINTER,
JAS_ERROR_INVALID_INSTRUCTION,
JAS_ERROR_NON_LONG_MODE_INSTRUCTION,
} jasErrorCode_t;

/**
Expand Down

0 comments on commit ba304a4

Please sign in to comment.