registers.h
This commit is contained in:
parent
51ef24bb53
commit
fe6d690251
@ -20,18 +20,6 @@ str ArgumentType_toString(ArgumentType t){
|
||||
return _ArgumentType_str[t];
|
||||
}
|
||||
|
||||
RegisterCode RegisterCode_parse(str r){
|
||||
if(str_equals(r, STR("ax")))
|
||||
return RegisterCode_ax;
|
||||
if(str_equals(r, STR("bx")))
|
||||
return RegisterCode_bx;
|
||||
if(str_equals(r, STR("cx")))
|
||||
return RegisterCode_cx;
|
||||
if(str_equals(r, STR("dx")))
|
||||
return RegisterCode_dx;
|
||||
return RegisterCode_Unset;
|
||||
}
|
||||
|
||||
|
||||
void Section_init(Section* sec, str name){
|
||||
sec->name = name;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "../std.h"
|
||||
#include "../string/str.h"
|
||||
#include "../instructions/instructions.h"
|
||||
#include "../instructions/registers.h"
|
||||
#include "../collections/List.h"
|
||||
|
||||
typedef enum ArgumentType {
|
||||
@ -15,16 +16,6 @@ typedef enum ArgumentType {
|
||||
|
||||
str ArgumentType_toString(ArgumentType t);
|
||||
|
||||
typedef enum RegisterCode {
|
||||
RegisterCode_Unset,
|
||||
RegisterCode_ax,
|
||||
RegisterCode_bx,
|
||||
RegisterCode_cx,
|
||||
RegisterCode_dx
|
||||
} RegisterCode;
|
||||
|
||||
RegisterCode RegisterCode_parse(str register_name);
|
||||
|
||||
typedef struct Argument {
|
||||
ArgumentType type;
|
||||
union {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "../instructions.h"
|
||||
#include "../registers.h"
|
||||
|
||||
#define readVar(VAR) {\
|
||||
if(!VM_dataRead(vm, &VAR, vm->current_pos, sizeof(VAR))) \
|
||||
@ -16,6 +17,7 @@
|
||||
|
||||
#define readRegisterVar(VAR) {\
|
||||
readVar(VAR);\
|
||||
VAR -= 1;\
|
||||
validateRegisterIndex(VAR);\
|
||||
}
|
||||
|
||||
|
||||
13
src/instructions/registers.c
Normal file
13
src/instructions/registers.c
Normal file
@ -0,0 +1,13 @@
|
||||
#include "registers.h"
|
||||
|
||||
RegisterCode RegisterCode_parse(str r){
|
||||
if(str_equals(r, STR("ax")))
|
||||
return RegisterCode_ax;
|
||||
if(str_equals(r, STR("bx")))
|
||||
return RegisterCode_bx;
|
||||
if(str_equals(r, STR("cx")))
|
||||
return RegisterCode_cx;
|
||||
if(str_equals(r, STR("dx")))
|
||||
return RegisterCode_dx;
|
||||
return RegisterCode_Unset;
|
||||
}
|
||||
13
src/instructions/registers.h
Normal file
13
src/instructions/registers.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "../std.h"
|
||||
#include "../string/str.h"
|
||||
|
||||
typedef enum RegisterCode {
|
||||
RegisterCode_Unset,
|
||||
RegisterCode_ax,
|
||||
RegisterCode_bx,
|
||||
RegisterCode_cx,
|
||||
RegisterCode_dx
|
||||
} RegisterCode;
|
||||
|
||||
RegisterCode RegisterCode_parse(str register_name);
|
||||
Loading…
Reference in New Issue
Block a user