hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
715 stars 56 forks source link

Feature Request: Different number base options for annotated text output. #166

Closed Retro-Jon closed 1 year ago

Retro-Jon commented 1 year ago

When outputting an annotated text file, we get something like the following:

outp | addr | data

100:0 | 100 | ; test: 100:0 | 100 | 00 ; nop 101:0 | 101 | 01 01 00 ; jmp test

This uses hexadecimal, which is excellent but not always suitable for the use case.

For example, I'm designing an 8-bit computer similar to the Altair 8800 that will have toggle switches on the front to enter programs into memory. While hex is great for visualizing memory, I typically find it easier to use octal to represent instructions and addresses when manually entering a program.

I use these files rather than binaries because I can see the addresses, opcodes, and assembly on the same line which simplifies entering and debugging a program.

In short, it would be awesome if the user could choose a different number base for annotated text files.

hlorenzi commented 1 year ago

Absolutely! I want to expand the variety of options for formatted outputs, allowing you to select an arbitrary base and digit grouping. Maybe using some kind of structured command-line arguments? Such as customasm prog.asm -f{annotated, base=8, group=4} which would even allow you to specify multiple output formats in the same run.

In the meantime, perhaps you can find some usefulness in the annotated-bin format. Unfortunately there's no annotated-oct format yet!

Retro-Jon commented 1 year ago

annotated-bin is great! I think that the -f{annotated, base=8, group=4} option would be the best approach due to the offered flexibility.

annotated-oct would still be amazing!

hlorenzi commented 1 year ago

I've implemented this on my development branch, and it should be available in the next release! The new syntax for format-specific arguments is -f annotated,base:8,group:4, for example.