From 79585194e655f142e603bd397f86a9aceded5eb0 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 28 Mar 2024 16:33:20 -0400 Subject: [PATCH 1/2] 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, From 89b709c7f87da4594d93f9a45c1a95b0b72b15bc Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 28 Mar 2024 16:55:55 -0400 Subject: [PATCH 2/2] make it clearer that explicit lib is required, note that exit is from stdlib.h, exit codes are unsigned, tweak "see below" for spacing, clarify that assembly can be used with C tests as well --- doc/sim65.sgml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index e4b6762d4..c70e06412 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -115,12 +115,12 @@ PVExit ($01) Creating a Test in C

-For a C test compiled and linked with ). +a set of built-in paravirtualization functions (see ). Example: @@ -149,9 +149,11 @@ int main() Creating a Test in Assembly

-Assembly tests may similarly be assembled and linked with - @@ -213,8 +215,8 @@ 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, The