yu830425 / MOS-6502-Simulator

A MOS 6502 simulator written in C++.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MOS-6502-Simulator

A MOS 6502 simulator written in C++.

Prerequisites

How to Use

Compile Simulator

msbuild  "MOS 6502 Emulator.sln" -target:MOS_6502_Executable:Rebuild -p:Configuration=Debug,Platform=x86

Note: It only allows to use "Debug | x86" mode to compile.

Create a Hello World C Program

The memory address 0xFFFF is mapping to the console, so writing into the address means to print the word to console.

File: helloworld.c

int main()
{
    char *console = (char *)0xFFFF;
    *console = 'H';
    *console = 'E';
    *console = 'L';
    *console = 'L';
    *console = 'O';
    *console = 'W';
    *console = 'O';
    *console = 'R';
    *console = 'L';
    *console = 'D';
    *console = '\n';

    return 0;
}

Compile Program to Binary

cc65 helloworld.c --target sim6502
ca65 helloworld.s
ld65 -o helloworld -t sim6502 helloworld.o sim6502.lib

Note: Please don't use cl65 to compile the c code. I don't know why, but it's not working.

Run Binary on Simulator

Please put the simulator MOS_6502_Executable.exe and the binary helloworld in the same folder, and then type

MOS_6502_Executable.exe helloworld

you will see the output likes blew

the number of the arguments: 2
HELLOWORLD
Emulator is terminated. return code = 0

About

A MOS 6502 simulator written in C++.

License:MIT License


Languages

Language:C++ 99.9%Language:C 0.1%