1
0
Fork 0
mirror of https://github.com/pnx/m16vm synced 2026-06-16 03:44:55 +02:00

move src/instr.h to include/instr.h because it will be needed by assembler for code generation.

This commit is contained in:
Henrik Hautakoski 2018-11-01 14:57:10 +01:00
parent 817642b7e4
commit cf752ab682
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA
5 changed files with 32 additions and 7 deletions

View file

@ -29,7 +29,7 @@
#include "cpu.h"
#include "mm.h"
#include "syscall.h"
#include "instr.h"
#include "instr_decode.h"
/* Program */
unsigned char *instr_mem = NULL;

View file

@ -1,4 +1,4 @@
/* instr.c
/* instr_decode.c
*
* Copyright (C) 2012,2014 Henrik Hautakoski <henrik.hautakoski@gmail.com>
*
@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "instr.h"
#include "instr_decode.h"
void instr_decode(unsigned char *instr, struct instr *out) {

View file

@ -1,4 +1,4 @@
/* instr.h
/* instr_decode.h
*
* Copyright (C) 2012,2014 Henrik Hautakoski <henrik.hautakoski@gmail.com>
*
@ -17,55 +17,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef INSTR_H
#define INSTR_H
#ifndef INSTR_DECODE_H
#define INSTR_DECODE_H
#include <stdint.h>
/* Opcodes */
#define OP_NOOP 0
#define OP_ADD 1
#define OP_MOVL 2
#define OP_MOVH 3
#define OP_LW 4
#define OP_SW 5
#define OP_BEQ 6
#define OP_JMP 7
#define OP_JR 8
#define OP_INT 15
/* Register type */
struct instr_R {
uint8_t rs;
uint8_t r0;
uint8_t r1;
};
struct instr_RI {
uint8_t rs;
uint8_t r0;
int8_t offset;
};
struct instr_I {
uint8_t rs;
int8_t imm;
};
struct instr_J {
uint16_t addr;
};
struct instr {
uint8_t opcode;
union {
struct instr_R r;
struct instr_RI ri;
struct instr_I i;
struct instr_J j;
};
};
#include <instr.h>
void instr_decode(unsigned char *nibble, struct instr *instr);
#endif /* INSTR_H */
#endif /* INSTR_DECODE_H */