Cleans up some files and adds the README files
parent
2964ff3b60
commit
d27cd2c3e4
@ -1,5 +1,5 @@
|
|||||||
# RE6502
|
# RE6502
|
||||||
|
|
||||||
RE6502 is an emulator for the 6502 cpu written in rust. The project comes with a very basic virtual machine for testing (it just has simple I/O functionality) as well as some test programs (find these in simple_test_machine/programs). The test programs can be built with the win2c64 (or lin2c64, or mac2c64) assembler which can be found here: https://www.aartbik.com/retro.php. Theoretically any 6502 assembler should work but win2c64 is the one I've been using for testing.
|
RE6502 is an emulator for the 6502 cpu written in rust. The project comes with a very basic virtual machine for testing (it just has simple I/O functionality) as well as some test programs (find these in simple_test_machine/programs). The test programs can be built with the win2c64 (or lin2c64, or mac2c64) assembler which can be found here: https://www.aartbik.com/retro.php. Theoretically any 6502 assembler should work but win2c64 is the one I've been using for testing.
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
The emulator doesn't really do anything on it's own but you can build it with the normal `cargo build` or `cargo run` if you run this program it will just do some simple internal tests. There are also unit tests you can run with `cargo test`. To make better use of the emulator you'll need to use it as a component of a larger emulator/vm. Take a look a the Simple Test Machine project to see how to use the RE6502 as a component.
|
||||||
@ -1,8 +1,18 @@
|
|||||||
|
|
||||||
# The Simple Test Machine
|
# The Simple Test Machine
|
||||||
|
The Simple Test Machine is a very basic virtual machine that uses the RE6502 as the cpu and a custom Console for simple I/O operations. There are example programs in the programs directory for reference/testing. The important memory addresses (I/O buffers, bit flags, etc) are listed in the src/machine.rs file.
|
||||||
|
|
||||||
# Running the Simple Test Machine
|
# Running the Simple Test Machine
|
||||||
|
To build the project you can `cd simple_test_machine` then `cargo build` or `cargo run`. If you run it on it's own it will just run some basic internal test programs. To run a specific progam you can pass the name of the binary to load when the machine starts up. To do this with cargo try `cargo run -- path/to/the/program` (ex. `cargo run -- programs/bin/hello.rw`).
|
||||||
|
|
||||||
# Assembling Programs for the Simple Test Machine
|
# Assembling Programs for the Simple Test Machine
|
||||||
|
Program binaries are not included in this repo but you can build them from the .asm files in the programs subdirectory. I've tested building these programs with the `win2c64` assembler (it also has linux `lin2c64` and mac `mac2c64` versions) that can be found here: https://www.aartbik.com/retro.php.
|
||||||
|
|
||||||
|
To use the assembler you can invoke it directly or use the `assemble.bat` script in the programs subdirectory.
|
||||||
|
|
||||||
|
## Using the assemble.bat script
|
||||||
|
To use the assemble.bat script you'll need to cd into the programs directory: `cd programs` (or, if you're in the project root: `cd simple_test_machine/programs`) then you can run the script with `.\assemble.bat hello.asm`. The script will move the resulting binary into the bin directory.
|
||||||
|
|
||||||
|
## Using win2c64 directly
|
||||||
|
You can invoke win2c64 directly with `win2c64.exe -R my_program.asm` The `-R` option is necessary to have the assembler output the binary in the correct format.
|
||||||
|
|
||||||
|
|||||||
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
; Multiply 7 with 10 and print the result
|
|
||||||
; For testing this program was assembled with c64 (using the -R option):
|
|
||||||
; https://www.aartbik.com/MISC/c64.html
|
|
||||||
|
|
||||||
; FAST MULTIPLY program from:
|
|
||||||
; http://6502.org/source/integers/fastx10.htm
|
|
||||||
main LDA #7 ; load 7 into the accumulator
|
|
||||||
ASL ;multiply by 2
|
|
||||||
STA TEMP ;temp store in TEMP
|
|
||||||
ASL ;again multiply by 2 (*4)
|
|
||||||
ASL ;again multiply by 2 (*8)
|
|
||||||
CLC
|
|
||||||
ADC TEMP ;as result, A = x*8 + x*2
|
|
||||||
|
|
||||||
; PRINT RESULT
|
|
||||||
STA $A0 ; 0x85, 0xA0, ; store A into the console output address
|
|
||||||
LDX #0 ; 0xA2, 0x00, ; null terminator
|
|
||||||
STX $A1 ; 0x86, 0xA1, ; store null terminator to output addr + 1
|
|
||||||
|
|
||||||
; Set flag to do the print
|
|
||||||
LDX #1 ; 0xA2, 0x01,
|
|
||||||
STX $9F ; 0x86, 0x9F, ; Print byte flag is at 0x9F
|
|
||||||
|
|
||||||
; End the program
|
|
||||||
RTS ; 0x60
|
|
||||||
|
|
||||||
; Variables
|
|
||||||
TEMP .byte 0
|
|
||||||
Loading…
Reference in New Issue