From 79585194e655f142e603bd397f86a9aceded5eb0 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 28 Mar 2024 16:33:20 -0400 Subject: [PATCH] provide simple examples for using sim65 with C and assembly code --- doc/sim65.sgml | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index c2740bbad..e4b6762d4 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -124,11 +124,28 @@ Exit codes are limited to 8 bits. The standard C library high level file input and output is functional. A sim65 application can be written like a command line application, -providing arguments to ). +Example: + + +#include +int main() +{ + printf("Hello!\n"); + return 5; +} + +// Build and run: +// cc65 -o example.s example.c +// ca65 -o example.o example.s +// ld65 -t sim6502 -o example.prg example.o sim6502.lib +// sim65 example.prg + Creating a Test in Assembly

@@ -141,11 +158,25 @@ and the sim65 library provides two ways to return an 8-bit exit code: Return from -The binary file has a 12 byte header: +Example: + + +.export _main +_main: + lda #5 + rts + +; Build and run: +; ca65 -o example.o example.s +; ld65 -t sim6502 -o example.prg example.o sim6502.lib +; sim65 example.prg + + +Internally, the binary program file has a 12 byte header provided by the library: @@ -182,6 +213,9 @@ These use cc65 calling conventions, and are intended for use with the sim65 targ The sim6502 or sim65c02 targets provide a default configuration, +but if customization is needed,