all repos — xyw @ 222bddd8e5928387441036c5685f84d8455cbb98

A minimal virtual machine and assembler for terminals.

xyw.c

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
#include <stdio.h>
#include <string.h>
#include "xyw.h"

int xyw_debug = 0;

//// Main Function
int main(int argc, char *argv[])
{
    (void)argc;
    for (int i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--debug") == 0)
        {
            xyw_debug = 1;
        }
        else
        {
            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;
            }
        }
    }
}