Implemented basic arduino vm.

Updated LDA to be M[D] = RX + IMM
Updated STA to be RD = M[RX + IMM]
Updated SYS to be RD = SYSCALL(RX, IMM)
Added error callback to VM, replaced printfs with callback.

Added syscalls.
This commit is contained in:
2018-10-22 00:01:47 +01:00
parent 6abacd4c1d
commit 600be14336
5 changed files with 377 additions and 113 deletions

View File

@@ -40,6 +40,10 @@ limitations under the License.
#define OP_JEQ 0xe
#define OP_JLT 0xf
#define VM_ERR_MISALIGN 0x1
#define VM_ERR_UNKNOWN_OP 0x2
#define VM_ERR_OUT_OF_BOUNDS 0x3
#ifdef __cplusplus
extern "C" {
#endif
@@ -59,7 +63,8 @@ struct VM_t {
uint8_t M[VM_MEM_SIZE];
uint8_t carry;
bool halted;
uint8_t (*syscall)(struct VM_t* vm, uint8_t callno);
uint8_t (*syscall)(struct VM_t* vm, uint8_t callno, uint8_t imm);
void (*error)(uint8_t err);
};
typedef struct VM_t VM;