all repos — xyw @ 0a1cdfba77bcf17705ff23db3e26d7c5b0c28136

A minimal virtual machine and assembler for terminals.

Updated instructions, change extension for image file, other fixes.
h3rald h3rald@h3rald.com
Mon, 01 Dec 2025 09:41:49 +0100
commit

0a1cdfba77bcf17705ff23db3e26d7c5b0c28136

parent

8f9fd6bc840cbf233b5eac4ba798cd041bdfc518

5 files changed, 19 insertions(+), 52 deletions(-)

jump to
M .gitignore.gitignore

@@ -1,4 +1,4 @@

xyw.exe *.o example* -*.xywi +*.xim
M devices.xywdevices.xyw

@@ -3,13 +3,8 @@ .macro system.state $FF00

.macro system.error $FF01 .macro system.ssp $FF02 .macro system.usp $FF03 -.macro system.x $FF04 -.macro system.y $FF05 -.macro system.xw $FF06 -.macro system.yw $FF08 -.macro system.pc $FF0a -.macro system.page $FF0c -.macro system.on_error $FF0d +.macro system.page $FF04 +.macro system.on_error $FF05 ;console .macro console.input $FF10
D xyw

          
M xyw.cxyw.c

@@ -10,27 +10,21 @@ {

(void)argc; for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) + if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--debug") == 0) { xyw_debug = 1; } - } - // If first argument is a file ending in .xyw, assemble it - if (argc >= 2) - { - const char *input_file = argv[1]; - // Output file is the same as input but with .rom extension - char output_file[256]; - snprintf(output_file, sizeof(output_file), "%.*s.xywi", (int)(strlen(input_file) - 4), input_file); - if (xyw_assemble(input_file, output_file) != 0) + else { - fprintf(stderr, "Assembly failed for file: %s\n", input_file); - return -1; + const char *input_file = argv[i]; + // Output file is the same as input but with .rom extension + char output_file[256]; + snprintf(output_file, sizeof(output_file), "%.*s.xim", (int)(strlen(input_file) - 4), input_file); + if (xyw_assemble(input_file, output_file) != 0) + { + fprintf(stderr, "Assembly failed for file: %s\n", input_file); + return -1; + } } - } - else - { - fprintf(stderr, "Usage: %s <input_file.xyw>\n", argv[0]); - return -1; } }
M xywasm.cxywasm.c

@@ -65,12 +65,12 @@ } xyw_token_terminator;

// Instruction mnemonics static char xyw_instructions[][4] = { - "BRK", "PSH", "POP", "NOT", - "LDR", "STR", "LDD", "STD", - "ILD", "LDI", "DLD", "LDD", + "BRK", "PSH", "POP", "LDR", + "LDA", "STA", "LDD", "STD", + "INC", "DEC", "SHL", "SHR", "ADD", "SUB", "MUL", "DIV", "EQU", "NEQ", "GTH", "LTH", - "AND", "IOR", "XOR", "SFT", + "AND", "IOR", "XOR", "NOT", "SWP", "DUP", "OVR", "ROT", "JMP", "JCN", "JSR", "RTS"};

@@ -529,23 +529,6 @@ }

//// Directive processing -static int process_directive_org(xyw_context *ctx) -{ - xyw_token_terminator r = next_token(ctx); - if (r == TOKEN_END_INVALID) - { - return -1; - } - if (process_number(ctx) != 0) - { - return -1; - } - dbg("Directive:\t.org %s\n", token); - // Move the pointer to the specified address - ptr = (xyw_word)token_value; - return validate_single_directive_argument(ctx, r); -} - static int process_directive_label(xyw_context *ctx) { xyw_token_terminator r = next_token(ctx);

@@ -712,10 +695,6 @@ else if (strcmpn(token, ".string", 7) == 0)

{ r = process_directive_string(ctx); } - else if (strcmpn(token, ".org", 4) == 0) - { - r = process_directive_org(ctx); - } else if (strcmpn(token, ".byte", 5) == 0) { r = process_directive_byte(ctx);

@@ -817,8 +796,7 @@ }

else if (in_comment) { ctx->column++; - token[token_length++] = (char)c; - token[token_length] = '\0'; + // Not storing comment context in token for now } else if (c == '"') {