Since I have the time I'll write bit more...
To generate executable code from cc65 it needs a few more things than just the compiler. It's a more or less complete set of tools that work in the same way as "the big boys" tools do on a desktop or server system - compiler, assembler and linker. Additionally you need a target platform which specifies the code (& data) load and execution addresses.
The target lets you pick the machine you're running it on - there are many pre-defined such as Apple II, BBC Micro, Commodore PET, OSI and so on. These affect the libraries, load addresses and so on.
The godbolt site is as it says; a compiler explorer. It's designed to let you see and compare the output ff various compilers and not to generate actual runnable code.
So the first thing you need to do is get the cc65 suite installed locally.
Then just write a simple assembly program (and I'm assuming that as you've written an emulator you're familiar with 6502 assembler)
You can then assemble with
ca65 -g myfile.s -o myfile.o -l myfile.lThat generates a relocatable object file called myfile.o with a listing file of myfile.l
To turn this into an executable binary file then:
ld65 -t none -S 0x8000 -vm -m myfile.m -o myfile myfile.oThat takes your relocatable object file, converts it into a standalone binary with a starting address of $8000 and a map file of myfile.m.
Here is a small example: Add numbers in locations 0 and 1 and store the result in 2:
myfile.s:
Code:
; Example
loop:
clc
lda $0
adc $1
sta $2
jmp loop
the assemble command and list the output:
Code:
% ca65 -g myfile.s -o myfile.o -l myfile.l
% cat myfile.l
ca65 V2.17 - Git cd72f816
Main file : myfile.s
Current file: myfile.s
000000r 1 ; Example
000000r 1 18 clc
000001r 1 A5 00 lda $0
000003r 1 65 01 adc $1
000005r 1 85 02 sta $2
000007r 1 4C rr rr jmp loop
The 'r' in the address field means it's a relocatable value as is the 'rr' in the JMP instruction.
Linking and displaying the object file:
Code:
% ld65 -t none -S 0x8000 -vm -m myfile.m -o myfile myfile.o
% odx myfile
000000 18 a5 00 65 01 85 02 4c 00 80 >...e...L..<
Note the % symbol is my prompt and the odx command is a hex dump command I use. Also note the address after the 4C in the dump - 00 80 which the linker has translated into an absolute value based on the start address given on the command line.
There are many, many more ways to drive the cc65 suite but this is about the simplest.
Hope that helps....
Gordon
(Also writing an emulator after many years using real CPUs!)
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/