diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-06 11:21:12 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2019-12-06 11:21:12 -0500 |
commit | b4f547ecb600729e0e1b980c27c154b2a99bbca1 (patch) | |
tree | 3873c155918deadfa0bbaa91551deb31d62793e3 /asmmon.c | |
parent | 5962c60342b9ed6562d7fb0f71a50ca9700b3735 (diff) |
Finally got multithreading support working!!
I have also added a program that computes the
Fibonacci sequence that I wrote in Sux assembly.
Diffstat (limited to 'asmmon.c')
-rw-r--r-- | asmmon.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -1,6 +1,8 @@ #include "opcode.h" #include <string.h> +#define debug 1 + #define SETOP(num, _mne, _IMM, _ZM, _ZMX, _ZMY, _ABS, _IMPL) \ {opcodes[num].mnemonic[3] = '\0'; strncpy(opcodes[num].mnemonic, _mne, 3); \ opcodes[num].imm = _IMM; \ @@ -59,7 +61,7 @@ int asmmon() { SETOP(46, "ROL", 0x71, 0x75, 0x00, 0x00, 0x73, 0x00); SETOP(47, "SSP", 0x00, 0x00, 0x00, 0x00, 0x00, 0x78); SETOP(48, "BNE", 0x00, 0x00, 0x00, 0x00, 0x80, 0x00); - SETOP(49, "ROL", 0x81, 0x85, 0x00, 0x00, 0x83, 0x00); + SETOP(49, "ROR", 0x81, 0x85, 0x00, 0x00, 0x83, 0x00); SETOP(50, "CSP", 0x00, 0x00, 0x00, 0x00, 0x00, 0x88); SETOP(51, "BVS", 0x00, 0x00, 0x00, 0x00, 0x90, 0x00); SETOP(52, "MUL", 0x91, 0x95, 0x00, 0x00, 0x93, 0x00); @@ -150,7 +152,9 @@ int asmmon() { done |= 6; oprand = strtok(oprand, "$"); address = strtoull(oprand, NULL, 16); + #if debug printf("Origin for program code is now at address $%llx.\n", address); + #endif } if (strcasecmp(ins, ".byte") == 0 || strcasecmp(ins, ".word") == 0 || strcasecmp(ins, ".dword") == 0 || strcasecmp(ins, ".qword") == 0) { done |= 6; @@ -181,8 +185,9 @@ int asmmon() { addr[address+7] = value >> 56; address+=8; } - + #if debug printf("The value $%llx was placed at address $%llx.\n", value, address); + #endif } } @@ -206,7 +211,15 @@ int asmmon() { if (mode[0] == '$') { value = strtoull(oprand, NULL, 16); if (value & 0xFFFFFFFF) { - addrmode = 2; + char *stf[] = {"BPO", "BNG", "BCS", "BCC", "BEQ", "BNE", "BVS", "BVC"}; + for (int i = 0; i < 8; i++) { + if (strcasecmp(ins, stf[i]) == 0) { + addrmode = 5; + break; + } else { + addrmode = 2; + } + } } else if (value & 0xFFFFFFFF00000000) { addrmode = 5; } @@ -394,6 +407,7 @@ int asmmon() { } break; } + #if debug if (!(done & 6)) printf("instruction: %s, ", ins); #if (!__GLIBC__) || (__TINYC__) @@ -402,6 +416,7 @@ int asmmon() { printf("Postfix: %s, ", (postfix[0] != '\0') ? postfix : "none"); #endif printf("Operand: %s, Address: $%llx\n", (oprand != NULL) ? oprand : "none", address); + #endif } } } |