Skip to content

Aransentin/DeiMOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeiMOS

A MOS 6502 superoptimizer, capable of synthezising programs up to ~11 bytes.

An article explaining the design of the program is available here.

Usage

Specifying the task to be synthesized is done in src/config.zig.

First, modify the test_generate, test_run, and test_verify functions as appropriate for your task. Also specify how many test cases there are; generally 256.

There are a few options as well on what code the superoptimizer should explore. Most of them should be self-explanatory. For example, if you feel the process is slow you might want to limit the amount of zero-page addresses and immediate values the program can utilize.

When this is done, build the program using zig build, preferably using -Doptimize=ReleaseFast for obvious reasons.

By default, the program waits for "phobos" workers to connect to port 6502, so that it can distribute work to them. You may automatically spawn such workers as subprocesses, like so:

./zig-out/bin/deimos zig-out/bin/phobos 8

The above example will (in addition to the master process) automatically spawn 8 workers, which will die when the program exits.

By default, the superoptimizer tries to find an optimal popcnt(A) program. Run it and it should eventually print:

info: Program found: bytes: 9, cycles (total): 15623, cycles (worst case): 68
C000 A2    LDX #$FF
C001 FF
C002 E8    INX
C003 0A    ASL A
C004 B0    BCS $FC (C002)
C005 FC
C006 D0    BNE $FB (C003)
C007 FB
C008 8A    TXA

About

A MOS 6502 superoptimizer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages