Update structure to a binary and machine util and a64inst modules

This commit is contained in:
sBubshait 2024-06-12 15:55:15 +01:00
parent c4e3493fdc
commit 954be5f8f4
21 changed files with 22 additions and 23 deletions

View File

@ -1,7 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "emulator/a64instruction/a64instruction.h" #include "shared/a64instruction/a64instruction.h"
#include "emulator/a64instruction/a64instruction_global.h" #include "shared/a64instruction/a64instruction_global.h"
#include "emulator/emulator.h" #include "emulator/emulator.h"
#include "emulator/fileio.h" #include "emulator/fileio.h"
#include "global.h" #include "global.h"

View File

@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "decode.h" #include "decode.h"
#include "binary_util.h" #include "../shared/binary_util.h"
// Given a binary word, return its internal representation as an a64instruction struct encoding the same // Given a binary word, return its internal representation as an a64instruction struct encoding the same
// information. // information.

View File

@ -1,5 +1,5 @@
#include "../global.h" #include "../global.h"
#include "a64instruction/a64instruction.h" #include "../shared/a64instruction/a64instruction.h"
#define HALT_WORD 0x8a000000 #define HALT_WORD 0x8a000000

View File

@ -3,14 +3,6 @@
#include "../global.h" #include "../global.h"
#include <stdbool.h> #include <stdbool.h>
/************************************
* DEFINITIONS
************************************/
#define BYTE_BITS 8
#define WORD_BITS (BYTE_BITS * sizeof(word))
#define DWORD_BITS (BYTE_BITS * sizeof(dword))
/************************************ /************************************
* STRUCTS * STRUCTS
************************************/ ************************************/

View File

@ -2,7 +2,7 @@
#include <assert.h> #include <assert.h>
#include "execute.h" #include "execute.h"
#include "print.h" #include "print.h"
#include "binary_util.h" #include "../shared/binary_util.h"
#include "machine_util.h" #include "machine_util.h"
// Defines the maximum value that can be held in a register // Defines the maximum value that can be held in a register

View File

@ -1,6 +1,6 @@
#ifndef __EXECUTE__ #ifndef __EXECUTE__
#define __EXECUTE__ #define __EXECUTE__
#include "a64instruction/a64instruction.h" #include "../shared/a64instruction/a64instruction.h"
#include "emulator.h" #include "emulator.h"
void execute(Machine *state, a64inst_instruction *inst); void execute(Machine *state, a64inst_instruction *inst);

View File

@ -1,10 +1,10 @@
/** Machine Util */ /** Machine Util */
#include "assert.h" #include "assert.h"
#include "machine_util.h" #include "machine_util.h"
#include "a64instruction/a64instruction_global.h" #include "../shared/a64instruction/a64instruction_global.h"
#include "../global.h" #include "../global.h"
#include "emulator.h" #include "emulator.h"
#include "binary_util.h" #include "../shared/binary_util.h"
// Returns the dword starting at address. The value is truncated if regType is a 64-bit register. // Returns the dword starting at address. The value is truncated if regType is a 64-bit register.
dword readMemory(byte *memory, uint32_t address, a64inst_regType regType) { dword readMemory(byte *memory, uint32_t address, a64inst_regType regType) {

View File

@ -1,7 +1,7 @@
#ifndef __MACHINE_UTIL__ #ifndef __MACHINE_UTIL__
#define __MACHINE_UTIL__ #define __MACHINE_UTIL__
#include "../global.h" #include "../global.h"
#include "a64instruction/a64instruction_global.h" #include "../shared/a64instruction/a64instruction_global.h"
#include "emulator.h" #include "emulator.h"

View File

@ -2,7 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#include "print.h" #include "print.h"
#include "a64instruction/a64instruction_global.h" #include "../shared/a64instruction/a64instruction_global.h"
#include "emulator.h" #include "emulator.h"
#include "machine_util.h" #include "machine_util.h"

View File

@ -9,6 +9,11 @@
#define __GLOBAL__ #define __GLOBAL__
#include <stdint.h> #include <stdint.h>
/************************************
* DEFINITIONS
************************************/
// Number of General Purpose Registers. // Number of General Purpose Registers.
#define REGISTER_COUNT 31 #define REGISTER_COUNT 31
// Register identifier interpreted as the 'zero register' // Register identifier interpreted as the 'zero register'
@ -27,4 +32,8 @@ typedef uint32_t word;
// Double word is a 64-bit unsigned integer. // Double word is a 64-bit unsigned integer.
typedef uint64_t dword; typedef uint64_t dword;
#define BYTE_BITS 8
#define WORD_BITS (BYTE_BITS * sizeof(word))
#define DWORD_BITS (BYTE_BITS * sizeof(dword))
#endif #endif

View File

@ -1,6 +1,5 @@
#include <stdbool.h> #include <stdbool.h>
#include "a64instruction_global.h" #include "a64instruction_global.h"
#include "../../global.h"
typedef enum { typedef enum {
a64inst_UNCONDITIONAL = 0, a64inst_UNCONDITIONAL = 0,

View File

@ -1,4 +1,4 @@
#include "../../global.h" #include "./a64instruction_global.h"
typedef struct { typedef struct {
dword value; dword value;

View File

@ -1,6 +1,5 @@
#include <stdbool.h> #include <stdbool.h>
#include "a64instruction_global.h" #include "a64instruction_global.h"
#include "../../global.h"
typedef enum { typedef enum {
a64inst_SINGLE_TRANSFER_SINGLE_DATA_TRANSFER = 1, a64inst_SINGLE_TRANSFER_SINGLE_DATA_TRANSFER = 1,

View File

@ -1,6 +1,7 @@
#ifndef __A64INSTRUCTION_GLOBAL__ #ifndef __A64INSTRUCTION_GLOBAL__
#define __A64INSTRUCTION_GLOBAL__ #define __A64INSTRUCTION_GLOBAL__
#include <stdint.h> #include <stdint.h>
#include "../../global.h"
// Specifies the register being referred to // Specifies the register being referred to
typedef uint8_t a64inst_regSpecifier; typedef uint8_t a64inst_regSpecifier;

View File

@ -1,10 +1,9 @@
#ifndef __BINARY_UTIL__ #ifndef __BINARY_UTIL__
#define __BINARY_UTIL__ #define __BINARY_UTIL__
#include "emulator.h" #include "../global.h"
#include "a64instruction/a64instruction_global.h" #include "a64instruction/a64instruction_global.h"
word getBits(word wrd, uint8_t lsb, uint8_t msb); word getBits(word wrd, uint8_t lsb, uint8_t msb);
dword max(dword a, dword b); dword max(dword a, dword b);