The most hardcore calculator you’ve ever seen
Yanes is a software-based device model (simulator), which implements 6502-like CPU instructions, memory address space, a screen and a keyboard.
OpCodes: http://www.6502.org/tutorials/6502opcodes.html
Address Space Layout:
-
CPU Data: 0x0000 – 0x00FF
- The latest keypress in form of ASCII code is stored at 0x00FF.
-
Stack: 0x0100 – 0x01FF
-
VGA Buffer: 0x0200 – 0x05FF
-
Program Space: 0x8000 – 0xFFF0
- Therefore, max size is 0x7FF0 bytes.
- Programs are executable machine code sequences for this simulator. You can either write one manually using a hex editor of your choice or use an assembler to produce it.
-
Reset Vector: 0xFFFC
-
IRQ Vector: 0xFFFE
- If you want to override
BRK
behavior, you can write an address of your custom procedure there. In case you want to revert its default behavior (program termination), you just need to null the IRQ Vector.
- If you want to override
Let’s look into the example/
directory:
This program draws 0 or 1 depending on whether 0
or 1
was pressed on the keyboard.
Let’s compile our example assembly script using my fork of @jenra-uwu's asm6502: asm6502/target/release/asm6502 -o examples/draw_0_or_1.bin -d examples/draw_0_or_1.s
.
After that we can run the compiled program using yanes: target/release/yanes examples/draw_0_or_1.bin
.
We see, that infinite loop works correctly. Now, if we press 0
:
We'll see a drawn zero. And if we press 1
:
The screen will be cleared and a drawn 1 will appear. To exit Yanes, press ESC
.
ESC
key injects BRK
instruction at the PC
register position and, therefore, terminates the program. After that, a CPU dump will be printed into the STDOUT
in form of state of all registers at the moment of program termination:
- Install the Rust toolchain using rustup.rs.
git clone --recurse-submodules
this repo.- Pull your favourite C/C++ compiler (Windows, Linux, MacOS).
- Run
cargo build --release
there and inasm6502/
directory.
Vyacheslav Bespalov – Other projects
Distributed under the MIT license. See LICENSE
for more information.
- Fork it
- Commit your changes
- Create a new Pull Request