diff --git a/.file_8814.tmp b/.file_8814.tmp new file mode 100644 index 0000000..66b3123 Binary files /dev/null and b/.file_8814.tmp differ diff --git a/OPTIONS.md b/OPTIONS.md index e5a0346..18893e2 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -6,6 +6,7 @@ - ```--debug / -d - display debugging info``` - ```--mem / -m - asm output memory size``` - ```--nfull / -n - no print all debug info``` +- ```--unasm / -u - disassembly file``` ## Опция HELP Может быть вызвана как ```--help``` или ```-h```. Эта опция выводит краткую справку. @@ -14,7 +15,7 @@ Эта опция выводит версию программы. ## Опция ASM Может быть вызвана как ```--asm``` или ```-a```. -Эта опция переводит программу в режим компиляции ассемблера. +Эта опция переводит программу в режим ассемблера. ## Опция OUT Может быть вызвана как ```--out``` или ```-o```. Эта опция выводит скомпилированную ассемблерную программу в файл. @@ -27,4 +28,7 @@ Рекомендуется к использованию всегда. ## Опция NFULL Может быть вызвана как ```--nfull``` или ```-n```. -Эта опция выключаеть вывод аддресов и запрос выполнения в [режиме отладки](#опция-debug). \ No newline at end of file +Эта опция выключаеть вывод аддресов и запрос выполнения в [режиме отладки](#опция-debug). +## Опция UNASM +Может быть вызвана как ```--unasm``` или ```-u```. +Эта опция переводит программу в режим дизассемблере. \ No newline at end of file diff --git a/dis.asm b/dis.asm new file mode 100644 index 0000000..1d868b2 --- /dev/null +++ b/dis.asm @@ -0,0 +1,727 @@ +; 4D5AF1000800 +0x00000001: push +0x00000001: or +0x00000001: and +0x00000001: xor +0x00000001: jmp +0x00000001: bnez +0x00000001: bez +0x00000002: push.string +0x00000004: push +0x00000004: or +0x00000004: and +0x00000004: xor +0x00000004: jmp +0x00000004: bnez +0x00000004: bez +0x00000005: neq +0x00000006: push +0x00000006: or +0x00000006: and +0x00000006: xor +0x00000006: jmp +0x00000006: bnez +0x00000006: bez +0x00000007: push.string +0x00000008: push +0x00000008: or +0x00000008: and +0x00000008: xor +0x00000008: jmp +0x00000008: bnez +0x00000008: bez +0x00000009: push +0x00000009: or +0x00000009: and +0x00000009: xor +0x00000009: jmp +0x00000009: bnez +0x00000009: bez +0x0000000B: push.string +0x0000000D: push +0x0000000D: or +0x0000000D: and +0x0000000D: xor +0x0000000D: jmp +0x0000000D: bnez +0x0000000D: bez +0x0000000E: push.string +0x0000000F: pop +0x0000000F: syscall +0x0000000F: swap +0x0000000F: dup +0x0000000F: copy +0x0000000F: set +0x0000000F: mov +0x0000000F: call +0x00000010: push +0x00000010: or +0x00000010: and +0x00000010: xor +0x00000010: jmp +0x00000010: bnez +0x00000010: bez +0x00000011: push +0x00000011: or +0x00000011: and +0x00000011: xor +0x00000011: jmp +0x00000011: bnez +0x00000011: bez +0x00000012: pop +0x00000012: syscall +0x00000012: swap +0x00000012: dup +0x00000012: copy +0x00000012: set +0x00000012: mov +0x00000012: call +0x00000013: push.string +0x00000015: push.string +0x00000016: sub +0x00000017: push.string +0x00000019: push +0x00000019: or +0x00000019: and +0x00000019: xor +0x00000019: jmp +0x00000019: bnez +0x00000019: bez +0x0000001A: push.string +0x0000001B: push +0x0000001B: or +0x0000001B: and +0x0000001B: xor +0x0000001B: jmp +0x0000001B: bnez +0x0000001B: bez +0x0000001C: push +0x0000001C: or +0x0000001C: and +0x0000001C: xor +0x0000001C: jmp +0x0000001C: bnez +0x0000001C: bez +0x0000001E: push.string +0x00000020: push +0x00000020: or +0x00000020: and +0x00000020: xor +0x00000020: jmp +0x00000020: bnez +0x00000020: bez +0x00000021: push.string +0x00000022: mul +0x00000023: push +0x00000023: or +0x00000023: and +0x00000023: xor +0x00000023: jmp +0x00000023: bnez +0x00000023: bez +0x00000025: push +0x00000025: or +0x00000025: and +0x00000025: xor +0x00000025: jmp +0x00000025: bnez +0x00000025: bez +0x00000026: push.string +0x00000027: eq +0x00000028: push +0x00000028: or +0x00000028: and +0x00000028: xor +0x00000028: jmp +0x00000028: bnez +0x00000028: bez +0x0000002A: push +0x0000002A: or +0x0000002A: and +0x0000002A: xor +0x0000002A: jmp +0x0000002A: bnez +0x0000002A: bez +0x0000002B: push.string +0x0000002D: push +0x0000002D: or +0x0000002D: and +0x0000002D: xor +0x0000002D: jmp +0x0000002D: bnez +0x0000002D: bez +0x00000030: push.string +0x00000051: push +0x00000051: or +0x00000051: and +0x00000051: xor +0x00000051: jmp +0x00000051: bnez +0x00000051: bez +0x00000052: push +0x00000052: or +0x00000052: and +0x00000052: xor +0x00000052: jmp +0x00000052: bnez +0x00000052: bez +0x00000053: pop +0x00000053: syscall +0x00000053: swap +0x00000053: dup +0x00000053: copy +0x00000053: set +0x00000053: mov +0x00000053: call +0x00000054: push +0x00000054: or +0x00000054: and +0x00000054: xor +0x00000054: jmp +0x00000054: bnez +0x00000054: bez +0x00000056: push +0x00000056: or +0x00000056: and +0x00000056: xor +0x00000056: jmp +0x00000056: bnez +0x00000056: bez +0x00000057: push.string +0x00000058: push.string +0x00000059: push +0x00000059: or +0x00000059: and +0x00000059: xor +0x00000059: jmp +0x00000059: bnez +0x00000059: bez +0x0000005A: push +0x0000005A: or +0x0000005A: and +0x0000005A: xor +0x0000005A: jmp +0x0000005A: bnez +0x0000005A: bez +0x0000005B: push.string +0x0000005C: push +0x0000005C: or +0x0000005C: and +0x0000005C: xor +0x0000005C: jmp +0x0000005C: bnez +0x0000005C: bez +0x0000005D: push +0x0000005D: or +0x0000005D: and +0x0000005D: xor +0x0000005D: jmp +0x0000005D: bnez +0x0000005D: bez +0x0000005F: push.string +0x00000060: push +0x00000060: or +0x00000060: and +0x00000060: xor +0x00000060: jmp +0x00000060: bnez +0x00000060: bez +0x00000061: pop +0x00000061: syscall +0x00000061: swap +0x00000061: dup +0x00000061: copy +0x00000061: set +0x00000061: mov +0x00000061: call +0x00000062: pop +0x00000062: syscall +0x00000062: swap +0x00000062: dup +0x00000062: copy +0x00000062: set +0x00000062: mov +0x00000062: call +0x00000065: pop +0x00000065: syscall +0x00000065: swap +0x00000065: dup +0x00000065: copy +0x00000065: set +0x00000065: mov +0x00000065: call +0x00000066: push +0x00000066: or +0x00000066: and +0x00000066: xor +0x00000066: jmp +0x00000066: bnez +0x00000066: bez +0x00000067: push.string +0x00000068: push +0x00000068: or +0x00000068: and +0x00000068: xor +0x00000068: jmp +0x00000068: bnez +0x00000068: bez +0x00000069: push +0x00000069: or +0x00000069: and +0x00000069: xor +0x00000069: jmp +0x00000069: bnez +0x00000069: bez +0x0000006B: push.string +0x0000006D: pop +0x0000006D: syscall +0x0000006D: swap +0x0000006D: dup +0x0000006D: copy +0x0000006D: set +0x0000006D: mov +0x0000006D: call +0x0000006E: push +0x0000006E: or +0x0000006E: and +0x0000006E: xor +0x0000006E: jmp +0x0000006E: bnez +0x0000006E: bez +0x0000006F: push.string +0x00000070: push +0x00000070: or +0x00000070: and +0x00000070: xor +0x00000070: jmp +0x00000070: bnez +0x00000070: bez +0x00000071: push +0x00000071: or +0x00000071: and +0x00000071: xor +0x00000071: jmp +0x00000071: bnez +0x00000071: bez +0x00000073: push.string +0x00000074: push +0x00000074: or +0x00000074: and +0x00000074: xor +0x00000074: jmp +0x00000074: bnez +0x00000074: bez +0x00000075: push.string +0x00000076: pop +0x00000076: syscall +0x00000076: swap +0x00000076: dup +0x00000076: copy +0x00000076: set +0x00000076: mov +0x00000076: call +0x00000077: push +0x00000077: or +0x00000077: and +0x00000077: xor +0x00000077: jmp +0x00000077: bnez +0x00000077: bez +0x00000078: add +0x00000079: push.string +0x0000007A: push +0x0000007A: or +0x0000007A: and +0x0000007A: xor +0x0000007A: jmp +0x0000007A: bnez +0x0000007A: bez +0x0000007B: push.string +0x0000007C: push +0x0000007C: or +0x0000007C: and +0x0000007C: xor +0x0000007C: jmp +0x0000007C: bnez +0x0000007C: bez +0x0000007D: push +0x0000007D: or +0x0000007D: and +0x0000007D: xor +0x0000007D: jmp +0x0000007D: bnez +0x0000007D: bez +0x0000007F: push.string +0x00000080: push +0x00000080: or +0x00000080: and +0x00000080: xor +0x00000080: jmp +0x00000080: bnez +0x00000080: bez +0x00000081: pop +0x00000081: syscall +0x00000081: swap +0x00000081: dup +0x00000081: copy +0x00000081: set +0x00000081: mov +0x00000081: call +0x00000082: up +0x00000083: push +0x00000083: or +0x00000083: and +0x00000083: xor +0x00000083: jmp +0x00000083: bnez +0x00000083: bez +0x00000084: push.string +0x00000086: push +0x00000086: or +0x00000086: and +0x00000086: xor +0x00000086: jmp +0x00000086: bnez +0x00000086: bez +0x00000087: push +0x00000087: or +0x00000087: and +0x00000087: xor +0x00000087: jmp +0x00000087: bnez +0x00000087: bez +0x00000088: pop +0x00000088: syscall +0x00000088: swap +0x00000088: dup +0x00000088: copy +0x00000088: set +0x00000088: mov +0x00000088: call +0x00000089: push.string +0x0000008B: push.string +0x0000008C: setsp +0x0000008D: pop +0x0000008D: syscall +0x0000008D: swap +0x0000008D: dup +0x0000008D: copy +0x0000008D: set +0x0000008D: mov +0x0000008D: call +0x0000008E: push.string +0x0000009D: push +0x0000009D: or +0x0000009D: and +0x0000009D: xor +0x0000009D: jmp +0x0000009D: bnez +0x0000009D: bez +0x0000009E: push +0x0000009E: or +0x0000009E: and +0x0000009E: xor +0x0000009E: jmp +0x0000009E: bnez +0x0000009E: bez +0x0000009F: pop +0x0000009F: syscall +0x0000009F: swap +0x0000009F: dup +0x0000009F: copy +0x0000009F: set +0x0000009F: mov +0x0000009F: call +0x000000A0: push +0x000000A0: or +0x000000A0: and +0x000000A0: xor +0x000000A0: jmp +0x000000A0: bnez +0x000000A0: bez +0x000000A2: push +0x000000A2: or +0x000000A2: and +0x000000A2: xor +0x000000A2: jmp +0x000000A2: bnez +0x000000A2: bez +0x000000A3: push.string +0x000000A5: push +0x000000A5: or +0x000000A5: and +0x000000A5: xor +0x000000A5: jmp +0x000000A5: bnez +0x000000A5: bez +0x000000A7: push +0x000000A7: or +0x000000A7: and +0x000000A7: xor +0x000000A7: jmp +0x000000A7: bnez +0x000000A7: bez +0x000000A8: pop +0x000000A8: syscall +0x000000A8: swap +0x000000A8: dup +0x000000A8: copy +0x000000A8: set +0x000000A8: mov +0x000000A8: call +0x000000A9: push +0x000000A9: or +0x000000A9: and +0x000000A9: xor +0x000000A9: jmp +0x000000A9: bnez +0x000000A9: bez +0x000000AA: push +0x000000AA: or +0x000000AA: and +0x000000AA: xor +0x000000AA: jmp +0x000000AA: bnez +0x000000AA: bez +0x000000AB: push.string +0x000000AD: push +0x000000AD: or +0x000000AD: and +0x000000AD: xor +0x000000AD: jmp +0x000000AD: bnez +0x000000AD: bez +0x000000AE: push +0x000000AE: or +0x000000AE: and +0x000000AE: xor +0x000000AE: jmp +0x000000AE: bnez +0x000000AE: bez +0x000000AF: push.string +0x000000B0: push +0x000000B0: or +0x000000B0: and +0x000000B0: xor +0x000000B0: jmp +0x000000B0: bnez +0x000000B0: bez +0x000000B1: push +0x000000B1: or +0x000000B1: and +0x000000B1: xor +0x000000B1: jmp +0x000000B1: bnez +0x000000B1: bez +0x000000B3: push.string +0x000000B4: push +0x000000B4: or +0x000000B4: and +0x000000B4: xor +0x000000B4: jmp +0x000000B4: bnez +0x000000B4: bez +0x000000B5: push.string +0x000000B6: pop +0x000000B6: syscall +0x000000B6: swap +0x000000B6: dup +0x000000B6: copy +0x000000B6: set +0x000000B6: mov +0x000000B6: call +0x000000B7: push +0x000000B7: or +0x000000B7: and +0x000000B7: xor +0x000000B7: jmp +0x000000B7: bnez +0x000000B7: bez +0x000000B8: getsp +0x000000B9: push.string +0x000000BA: push +0x000000BA: or +0x000000BA: and +0x000000BA: xor +0x000000BA: jmp +0x000000BA: bnez +0x000000BA: bez +0x000000BB: push.string +0x000000BD: push +0x000000BD: or +0x000000BD: and +0x000000BD: xor +0x000000BD: jmp +0x000000BD: bnez +0x000000BD: bez +0x000000BE: push +0x000000BE: or +0x000000BE: and +0x000000BE: xor +0x000000BE: jmp +0x000000BE: bnez +0x000000BE: bez +0x000000BF: push.string +0x000000C0: push +0x000000C0: or +0x000000C0: and +0x000000C0: xor +0x000000C0: jmp +0x000000C0: bnez +0x000000C0: bez +0x000000C1: push +0x000000C1: or +0x000000C1: and +0x000000C1: xor +0x000000C1: jmp +0x000000C1: bnez +0x000000C1: bez +0x000000C3: push.string +0x000000C5: pop +0x000000C5: syscall +0x000000C5: swap +0x000000C5: dup +0x000000C5: copy +0x000000C5: set +0x000000C5: mov +0x000000C5: call +0x000000C6: push +0x000000C6: or +0x000000C6: and +0x000000C6: xor +0x000000C6: jmp +0x000000C6: bnez +0x000000C6: bez +0x000000C7: pop +0x000000C7: syscall +0x000000C7: swap +0x000000C7: dup +0x000000C7: copy +0x000000C7: set +0x000000C7: mov +0x000000C7: call +0x000000C8: up +0x000000C9: getsp +0x000000CA: pop +0x000000CA: syscall +0x000000CA: swap +0x000000CA: dup +0x000000CA: copy +0x000000CA: set +0x000000CA: mov +0x000000CA: call +0x000000CB: push +0x000000CB: or +0x000000CB: and +0x000000CB: xor +0x000000CB: jmp +0x000000CB: bnez +0x000000CB: bez +0x000000CC: push.string +0x000000CD: push +0x000000CD: or +0x000000CD: and +0x000000CD: xor +0x000000CD: jmp +0x000000CD: bnez +0x000000CD: bez +0x000000CE: push +0x000000CE: or +0x000000CE: and +0x000000CE: xor +0x000000CE: jmp +0x000000CE: bnez +0x000000CE: bez +0x000000D0: push.string +0x000000D2: pop +0x000000D2: syscall +0x000000D2: swap +0x000000D2: dup +0x000000D2: copy +0x000000D2: set +0x000000D2: mov +0x000000D2: call +0x000000D3: push +0x000000D3: or +0x000000D3: and +0x000000D3: xor +0x000000D3: jmp +0x000000D3: bnez +0x000000D3: bez +0x000000D4: push.string +0x000000D6: push +0x000000D6: or +0x000000D6: and +0x000000D6: xor +0x000000D6: jmp +0x000000D6: bnez +0x000000D6: bez +0x000000D8: push +0x000000D8: or +0x000000D8: and +0x000000D8: xor +0x000000D8: jmp +0x000000D8: bnez +0x000000D8: bez +0x000000D9: push.string +0x000000DB: push +0x000000DB: or +0x000000DB: and +0x000000DB: xor +0x000000DB: jmp +0x000000DB: bnez +0x000000DB: bez +0x000000DC: neq +0x000000DD: push +0x000000DD: or +0x000000DD: and +0x000000DD: xor +0x000000DD: jmp +0x000000DD: bnez +0x000000DD: bez +0x000000DE: pop +0x000000DE: syscall +0x000000DE: swap +0x000000DE: dup +0x000000DE: copy +0x000000DE: set +0x000000DE: mov +0x000000DE: call +0x000000DF: push +0x000000DF: or +0x000000DF: and +0x000000DF: xor +0x000000DF: jmp +0x000000DF: bnez +0x000000DF: bez +0x000000E1: push.string +0x000000E3: up +0x000000E4: push +0x000000E4: or +0x000000E4: and +0x000000E4: xor +0x000000E4: jmp +0x000000E4: bnez +0x000000E4: bez +0x000000E5: push +0x000000E5: or +0x000000E5: and +0x000000E5: xor +0x000000E5: jmp +0x000000E5: bnez +0x000000E5: bez +0x000000E6: pop +0x000000E6: syscall +0x000000E6: swap +0x000000E6: dup +0x000000E6: copy +0x000000E6: set +0x000000E6: mov +0x000000E6: call +0x000000E7: push +0x000000E7: or +0x000000E7: and +0x000000E7: xor +0x000000E7: jmp +0x000000E7: bnez +0x000000E7: bez diff --git a/ntsys b/ntsys index 4e214ff..6476a46 100755 Binary files a/ntsys and b/ntsys differ diff --git a/ntsys-disassembler.h b/ntsys-disassembler.h new file mode 100644 index 0000000..76d4049 --- /dev/null +++ b/ntsys-disassembler.h @@ -0,0 +1,84 @@ +/* + * ntsys-disassembler.h + * + * Copyright 2026 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * + */ + +#if (!defined(__LIB_mKOdwuwdww332_H_)) +#define __LIB_mKOdwuwdww332_H_ + +int ntsys_unassembly_file(char* filename, char* asm_out) { + FILE* fp = fopen(filename, "rb"); + FILE* out = fopen(asm_out, "w"); + if (fp == NULL || out == NULL) { + ntsys_error("Cannot open file!"); + if (fp != NULL) fclose(fp); + if (out != NULL) fclose(out); + return EXIT_FAILURE; + } + fputs("; ", out); + size_t g = 0; + while (g < 8) { + __e_byte_t c = getc(fp); + fprintf(out, "%X", c); + g ++; + } + fputc('\n', out); + char buf[64]; + while (ferror(fp) == 0 && feof(fp) == 0) { + __e_byte_t c = getc(fp); + size_t i = 0; + while (i < ntsys_command_count) { + size_t t = 0; + while (t < strlen(ntsys_asm_table[i])) { + if (ntsys_asm_table[i][t] == '=') break; + t ++; + } + strncpy(buf, ntsys_asm_table[i], t); + buf[t] = '\0'; + char* name = buf; + __e_byte_t f = 0; + char* se = &ntsys_asm_table[i][t + 1]; + while (strlen(se) > 1) { + char is[3]; + strncpy(is, se, 2); + is[2] = '\0'; + if (is[0] != ':') { + __e_byte_t d = atoi(is); + if (d == c && f == 0 + && strcmp(name, "exit") + && strcmp(name, "rcall") + && strcmp(name, "global") + ) { + f = 1; + fprintf(out, "0x%08lX: %s \n", ftell(fp) - 8, name); + } + } + se += sizeof(char) * 2; + } + i ++; + } + } + fclose(fp); + fclose(out); + return EXIT_SUCCESS; +} + +#endif /* __LIB_mKOdwuwdww332_H_ */ diff --git a/ntsys.h b/ntsys.h index 470f77e..7dbb7be 100644 --- a/ntsys.h +++ b/ntsys.h @@ -28,6 +28,13 @@ #define NTSYS_VERSION "1.0" + +#if defined(__WIN32) || defined(__WIN64) +#define NTSYS_STANDARD_ASM_OUT "NUL" +#else +#define NTSYS_STANDARD_ASM_OUT "/dev/null" +#endif + #define NAME_OF_32_BITS_TYPE unsigned int #define NAME_OF_64_BITS_TYPE unsigned long int #define NAME_OF_16_BITS_TYPE unsigned short int @@ -68,6 +75,7 @@ void ntsys_error(char* _err) { word_t fGH6VSEzu7qNiGVE_mem_size = NTSYS_ASSEMBLE_STANDARD_MEMORY_SIZE; #include "ntsys-assembler.h" +#include "ntsys-disassembler.h" static void __help(void) { puts ( @@ -86,7 +94,8 @@ static void __help(void) { " " "--out / -o - set output file name" "\n" " " "--debug / -d - display debugging info" "\n" " " "--mem / -m - asm output memory size" "\n" - " " "--nfull / -n - no print all debug info" "\0" + " " "--nfull / -n - no print all debug info" "\n" + " " "--unasm / -u - disassembly file" "\0" ); } static int __exe_run(__e_byte_t* memory, __e_byte_t fulldebug, unsigned int memorysize, unsigned long filesize, FILE* fp, __e_byte_t debug) { @@ -210,7 +219,7 @@ int ntsys_api_call(char* filename, unsigned char debug, unsigned char isFullDebu int _lib_ntsys_main(int argc, char** argv) { unsigned int t = 1; char* filename = NULL; - char* asm_out = "out.exe"; + char* asm_out = NTSYS_STANDARD_ASM_OUT; char mode = 'R'; unsigned char out = 0; unsigned char debug = 0; @@ -240,12 +249,15 @@ int _lib_ntsys_main(int argc, char** argv) { break; case 'o': out = 1; - mode = 'A'; + if (mode != 'U') mode = 'A'; break; case 'm': mem = 1; mode = 'A'; break; + case 'u': + mode = 'U'; + break; default: ntsys_error("Unknown option!"); return EXIT_FAILURE; @@ -268,6 +280,7 @@ int _lib_ntsys_main(int argc, char** argv) { return EXIT_FAILURE; } if (mode == 'R') return ntsys_api_call(filename, debug, is_full_deb); + else if (mode == 'U') return ntsys_unassembly_file(filename, asm_out); return ntsys_compile_asm(filename, asm_out); }