Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research problems #17

Open
ascherer opened this issue Jan 9, 2024 · 1 comment
Open

Research problems #17

ascherer opened this issue Jan 9, 2024 · 1 comment

Comments

@ascherer
Copy link
Owner

ascherer commented Jan 9, 2024

At various places in the MMIX sources, Don Knuth asks the interested reader to make significant changes for advanced system features:

  • Unicode support using wchar for Char (MMOTYPE§27, MMIXAL§§{7,30})
  • octa as single 64-bit integer, e.g., using uint64_t instead of the current struct with two tetras (ILP64 interface) (MMIX-ARITH§1)
  • Graphical interface (MMIX-SIM§1)
  • Implement MMIXAL-style expressions for interactive debugging (MMIX-SIM§24)

Time permitting, I'll try to look up the relevant sections in the codes.

@ascherer ascherer changed the title Reseach problems Research problems Jun 24, 2024
@ascherer
Copy link
Owner Author

Copilot suggests these changes for mmotype.w:

#include <wchar.h>

// Change to wide character buffer
wchar_t sym_buf[sym_length_max];
wchar_t *sym_ptr;

// Example function update for reading wide characters
wchar_t read_wchar() {
    wchar_t wc;
    if (fgetwc(mmo_file, &wc) != 1) {
        fprintf(stderr, "Unexpected end of file after %d characters!\n", count);
        exit(-3);
    }
    return wc;
}

// Update the print function
void print_stab() {
    register int m = read_byte();
    register wchar_t c;
    if (m & 0x40) print_stab();
    if (m & 0x2f) {
        c = read_wchar();
        *sym_ptr++ = c;
        if (sym_ptr == &sym_buf[sym_length_max]) {
            fwprintf(stderr, L"Oops, the symbol is too long!\n");
            exit(-7);
        }
        if (m & 0xf) {
            // Update printing logic for wide characters
            *sym_ptr = L'\0';
            fwprintf(stdout, L"    %ls (%d)\n", sym_buf, m & 0xf);
        }
        if (m & 0x20) print_stab();
        sym_ptr--;
    }
    if (m & 0x10) print_stab();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant