Skip to content

Commit

Permalink
Relocated 'exe.bin', Combined decode.cpp & fetch.cpp
Browse files Browse the repository at this point in the history
Hylia Expects to find 'exe.bin' in './bin/'.

decode.cpp & fetch.cpp -> fetchdecode.cpp
  • Loading branch information
Ash1569 committed Jan 22, 2022
1 parent 826b399 commit c95f119
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
all:
"g++" ".\src\main.cpp" ".\src\hylia\init.cpp" ".\src\hylia\cpu\fetch.cpp" ".\src\hylia\cpu\decode.cpp" ".\src\hylia\cpu\execute.cpp" -o ".\bin\hyliaDEV"
"g++" ".\src\main.cpp" ".\src\hylia\init.cpp" ".\src\hylia\cpu\fetchdecode.cpp" ".\src\hylia\cpu\execute.cpp" -o ".\bin\hyliaDEV"
10 changes: 0 additions & 10 deletions src/hylia/cpu/decode.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions src/hylia/cpu/decode.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/hylia/cpu/execute.h

This file was deleted.

3 changes: 0 additions & 3 deletions src/hylia/cpu/fetch.h

This file was deleted.

9 changes: 9 additions & 0 deletions src/hylia/cpu/fetch.cpp → src/hylia/cpu/fetchdecode.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#include <iostream>

// Takes the Interger provided by hFetch and isolates each operand byte.
void hDecode(uint32_t instruction, uint8_t* opCode, uint8_t* reg1, uint8_t* reg2, uint8_t* reg3, int* immediateValue) {
*opCode = (instruction&0xFF000000)>>24;
*reg1 = (instruction&0x00FF0000)>>16;
*reg2 = (instruction&0x0000FF00)>>8;
*reg3 = (instruction&0x000000FF);
*immediateValue = (instruction&0x0000FFFF);
}

// Gets then next instruction from the RAM Buffer and returns for decoding
uint32_t hFetch(uint8_t Ram[1024], int32_t Registers[15]) {
// Encodes as LE/Little Endian
Expand Down
4 changes: 2 additions & 2 deletions src/hylia/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

void hInit(uint8_t Ram[1024]) {
// Load the file exe.bin into the 1MB Ram Buffer.
FILE *f = fopen("exe.bin", "rb");
FILE *f = fopen("./bin/exe.bin", "rb");
if(f){
fseek(f, 0, SEEK_END);
size_t file_size = ftell(f);
Expand All @@ -11,7 +11,7 @@ void hInit(uint8_t Ram[1024]) {
fread(Ram, 1, file_size, f);
fclose(f);
} else if (f == NULL) {
printf("Can't open exe.bin\n");
printf("Can't open './bin/exe.bin'\n");
exit(1);
}
}
3 changes: 0 additions & 3 deletions src/hylia/init.h

This file was deleted.

6 changes: 0 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include <iostream>
#include <fstream>
#include "hylia/hylia.h"
/**
* #include "hylia/init.h"
* #include "hylia/cpu/fetch.h"
* #include "hylia/cpu/decode.h"
* #include "hylia/cpu/execute.h"
**/

int isRunning = 1;

Expand Down

0 comments on commit c95f119

Please sign in to comment.