Skip to content

limitedeternity/yanes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yanes

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.

Spec

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

    • Layout:

      image

    • Color Codes:

      yanes

  • 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.

Example

Let’s look into the example/ directory:

1

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.

loop

We see, that infinite loop works correctly. Now, if we press 0:

0

We'll see a drawn zero. And if we press 1:

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:

dump

Building

  1. Install the Rust toolchain using rustup.rs.
  2. git clone --recurse-submodules this repo.
  3. Pull your favourite C/C++ compiler (Windows, Linux, MacOS).
  4. Run cargo build --release there and in asm6502/ directory.

Meta

Vyacheslav Bespalov – Other projects

Distributed under the MIT license. See LICENSE for more information.

@limitedeternity

Contributing

  1. Fork it
  2. Commit your changes
  3. Create a new Pull Request