began assembler
This commit is contained in:
parent
b30a4b1832
commit
885a091400
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -1,5 +1,7 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"ram.h": "c"
|
||||
"ram.h": "c",
|
||||
"stdint.h": "c",
|
||||
"carg-parse.h": "c"
|
||||
}
|
||||
}
|
49
asm/asm_const.h
Normal file
49
asm/asm_const.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef ASM_ASM_CONST_H
|
||||
#define ASM_ASM_CONST_H
|
||||
|
||||
#include "../emu/cpu_const.h"
|
||||
#include "../emu/cpu_human.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char label[64];
|
||||
char instruction[4];
|
||||
char arg1[64];
|
||||
char arg2[64];
|
||||
} AsmInstruction;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t length;
|
||||
AsmInstruction *instruction;
|
||||
} AsmInstructionArray;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CpuInstructions instruction;
|
||||
ArgumentInfo arg1Info;
|
||||
ArgumentInfo arg2Info;
|
||||
uint16_t arg1;
|
||||
uint16_t arg2;
|
||||
} BinaryInstruction;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t length;
|
||||
BinaryInstruction *instructions;
|
||||
} BinaryInstructionArray;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char label[64];
|
||||
uint16_t location;
|
||||
} AsmLabel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t length;
|
||||
AsmLabel *labels;
|
||||
} AsmLabelArray;
|
||||
|
||||
#endif
|
14
asm/assembler.c
Normal file
14
asm/assembler.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "./assembler.h"
|
||||
#include "../emu/cpu_const.h"
|
||||
#include "../emu/cpu_human.h"
|
||||
#include "./asm_const.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
AsmInstructionArray InterpretAssembly(char *data)
|
||||
{
|
||||
char *d = data;
|
||||
|
||||
|
||||
}
|
6
asm/assembler.h
Normal file
6
asm/assembler.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef ASM_ASSEMBLER_H
|
||||
#define ASM_ASSEMBLER_H
|
||||
|
||||
|
||||
|
||||
#endif
|
16
asm/main.c
Normal file
16
asm/main.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include "../emu/cpu_const.h"
|
||||
#include "../emu/cpu_human.h"
|
||||
#include "../lib/carg-parse/carg-parse.h"
|
||||
#include "./asm_const.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
carg_parse_data* args = carg_parse(argc, argv);
|
||||
|
||||
carg_parse_free(args);
|
||||
|
||||
return 0;
|
||||
}
|
5
build.sh
5
build.sh
@ -1,2 +1,5 @@
|
||||
mkdir ./bin
|
||||
clang -o ./bin/r16e ./emu/main.c ./emu/cpu/instruction.c ./emu/cpu/ram.c ./emu/cpu/register.c ./emu/cpu/stack.c ./lib/carg-parse/carg-parse.c
|
||||
clang -O2 -o ./bin/r16emu ./emu/main.c ./emu/cpu/instruction.c ./emu/cpu/ram.c ./emu/cpu/register.c ./emu/cpu/stack.c ./lib/carg-parse/carg-parse.c
|
||||
echo "built emulator"
|
||||
clang -O2 -o ./bin/r16asm ./asm/main.c ./lib/carg-parse/carg-parse.c
|
||||
echo "built assemblor"
|
@ -4,12 +4,7 @@
|
||||
#define RAM_DO_NULL_CHECK
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union
|
||||
{
|
||||
int16_t s;
|
||||
uint16_t u;
|
||||
} r16_int;
|
||||
#include "../cpu_const.h"
|
||||
|
||||
void InitRam();
|
||||
void SetValue(r16_int address, r16_int value);
|
||||
|
@ -51,6 +51,12 @@ typedef enum
|
||||
pointerInRegister = 0x3
|
||||
} ArgumentInfo;
|
||||
|
||||
typedef union
|
||||
{
|
||||
int16_t s;
|
||||
uint16_t u;
|
||||
} r16_int;
|
||||
|
||||
#define INSTRUCTION_BIT_MASK 0b0000000011111111
|
||||
#define INSTRUCTION_ARG_1_INFO_MASK 0b0011000000000000
|
||||
#define INSTRUCTION_ARG_2_INFO_MASK 0b1100000000000000
|
||||
|
Loading…
Reference in New Issue
Block a user