summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-04-11 18:52:37 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-04-11 18:52:37 +1000
commit10fedb851f6654874a644f4b158a4d9d404da14e (patch)
tree63ccd3c4aa407cde6509081fd3593706bc013c6f
parent79a679f3a3d443b631ad5437b69e729550522fcb (diff)
just shifting over to PC
-rwxr-xr-xa.outbin34808 -> 30760 bytes
-rw-r--r--instruction-init.h8
-rw-r--r--interpreter.c11
3 files changed, 10 insertions, 9 deletions
diff --git a/a.out b/a.out
index 7013c34..45940d6 100755
--- a/a.out
+++ b/a.out
Binary files differ
diff --git a/instruction-init.h b/instruction-init.h
index 2e0e29c..c2f85ed 100644
--- a/instruction-init.h
+++ b/instruction-init.h
@@ -16,13 +16,13 @@ void setIT(int i, uintptr_t p, Addressing r){
}
uintptr_t getITFunction(int i){ //Segmentation fault is occurring here, likely in next one too
- uintptr_t* r = (IT + (sizeof(uintptr_t)*i));
- return *r;
+ uintptr_t r = (IT + (sizeof(uintptr_t)*i));
+ return r;
}
Addressing getITAddressing(int i){
- Addressing* r = (IT + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
- return *r;
+ Addressing r = (IT + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
+ return r;
}
diff --git a/interpreter.c b/interpreter.c
index 652c181..4598d2f 100644
--- a/interpreter.c
+++ b/interpreter.c
@@ -33,7 +33,7 @@ int main(){
m += dCharToNum(fgetc(stdin));
dPageDump(m);
break;
- case ' ':
+ case ' ': case '\n':
break;
}
}else{ // RUN INSTRUCTION
@@ -43,16 +43,17 @@ int main(){
// Pass in Value
address pass = 0x0000;
int range = fAddressGetLength(getITAddressing(inst));
+ printf("range = %d\n", range); //DEBUG
range = ((2*range)-2);
c = fgetc(stdin);
for(int i = 0; i < range; i++){
- if (c != ' ' && c != EOF){
+ if ((c == ' ') || (c == '\n')){
+ i--;
+ }else{
pass <<= 4;
pass += c;
- c = fgetc(stdin);
- }else{
- break;
}
+ c = fgetc(stdin);
}
current_instruction = getITFunction(inst);
callIT(current_instruction, pass);