diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-04-11 11:55:26 +1000 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-04-11 11:55:26 +1000 |
commit | 3f3574efb1e1c27d2f471c9b4a87a9786326e773 (patch) | |
tree | 856a3d24011eba1d13998967926e477de3bc8587 /interpreter.c | |
parent | 2cf25a4fb232939191147896366b0c68d09c985e (diff) |
work on instruction table data and interpreter
Diffstat (limited to 'interpreter.c')
-rw-r--r-- | interpreter.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/interpreter.c b/interpreter.c index a3275f3..766d387 100644 --- a/interpreter.c +++ b/interpreter.c @@ -1,12 +1,10 @@ /* * interpreter.c WILL BE a tool which can be used to interpret 6502 machine code inline. * Machine code is expected as hexadecimal of length 2 or 6, depending on the instruction. - * Note that zero-page addressing is not fully emulated yet; it will still address the zero-page - section of memory but the instructions still take an address of length 4. - This will be fixed later when the whole system is functional. * There are a few special characters which print debug information - d Prints main system information - mXXXX Prints contents of particular memory location + Q - Quit + P - Processor status dump + M - Dump a page of memory */ #include"include.h" @@ -19,46 +17,42 @@ int main(){ c = getchar(); // Exit condition - if ( (c == 'X') || (c == 'x') || (c == EOF) ) break; + if ( (c == 'Q') || (c == 'q') || (c == EOF) ) break; - if (dChar2Num(c) == -1){ + if (dCharToNum(c) == -1){ // Debug print conditions switch(c){ - case 'P': case 'p': // Print debug information - debug_print(); + // Print debug information + case 'P': case 'p': + dStatusDump(); break; - case 'M': case 'm': // Dump memory page - dChar2Num(getchar()); - printf("Address %d has %x", m, Memory[m]); + // Dump memory page + case 'M': case 'm': + dPageDump(); break; case ' ': break; } }else{ // Run Instruction - byte inst = c - - - } - - a += dChar2Num(c, 0x10); - // Pass 2 - c = getchar(); if (c == EOF) break; - a += dChar2Num(c, 0x01); - //Check for next value - c = getchar(); - if (!(c == EOF || c == ' ')) { - // Four passes - b += charToNum(c, 0x1000); - c = getchar(); if (c == EOF) break; - b += charToNum(c, 0x0100); - c = getchar(); if (c == EOF) break; - b += charToNum(c, 0x0010); - c = getchar(); if (c == EOF) break; - b += charToNum(c, 0x0001); + byte inst = dCharToNum(c) << 4; + inst += dCharToNum(getch()); + address pass = 0; + int temp = fAddressGetLength(getITAddressing(inst)); + temp *= 2; + c = getch(); + for(int i = 0; i < temp; i++) + if (c != ' ' && c != EOF){ + pass <<= 4; + pass += c; + c = getch(); + }else{ + break; + } + } + current_instruction = IT[inst]; + callIT(current_instruction, pass); } - //runInstruction(a, b); - c = getchar(); if (c == EOF) break; } return 0; }
\ No newline at end of file |