From 79585194e655f142e603bd397f86a9aceded5eb0 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 28 Mar 2024 16:33:20 -0400 Subject: [PATCH 1/5] 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/5] 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 From fa1a426c2968f1429e7129ea592065c2a57b73ce Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Tue, 16 Apr 2024 14:06:45 -0400 Subject: [PATCH 3/5] add -t sim6502 to cc65 and ca65 examples --- doc/sim65.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index c70e06412..ebd73c2cc 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -141,8 +141,8 @@ int main() } // Build and run: -// cc65 -o example.s example.c -// ca65 -o example.o example.s +// cc65 -t sim6502 -o example.s example.c +// ca65 -t sim6502 -o example.o example.s // ld65 -t sim6502 -o example.prg example.o sim6502.lib // sim65 example.prg @@ -173,7 +173,7 @@ _main: rts ; Build and run: -; ca65 -o example.o example.s +; ca65 -t sim6502 -o example.o example.s ; ld65 -t sim6502 -o example.prg example.o sim6502.lib ; sim65 example.prg From 4bc726ebe2d8148b132170a292291e811c5e4d2a Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Tue, 16 Apr 2024 16:41:00 -0400 Subject: [PATCH 4/5] clarify the meaning of the exit code unsigned limitation --- doc/sim65.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index ebd73c2cc..5cacf87cd 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -120,7 +120,7 @@ command line arguments to Date: Tue, 16 Apr 2024 16:56:13 -0400 Subject: [PATCH 5/5] give cl65 alternative --- doc/sim65.sgml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/sim65.sgml b/doc/sim65.sgml index 5cacf87cd..962f07254 100644 --- a/doc/sim65.sgml +++ b/doc/sim65.sgml @@ -141,6 +141,10 @@ int main() } // Build and run: +// cl65 -t sim6502 -o example.prg example.c +// sim65 example.prg + +// Build and run, separate steps: // cc65 -t sim6502 -o example.s example.c // ca65 -t sim6502 -o example.o example.s // ld65 -t sim6502 -o example.prg example.o sim6502.lib @@ -173,6 +177,10 @@ _main: rts ; Build and run: +; cl65 -t sim6502 -o example.prg example.s +; sim65 example.prg + +; Build and run, separate steps: ; ca65 -t sim6502 -o example.o example.s ; ld65 -t sim6502 -o example.prg example.o sim6502.lib ; sim65 example.prg