]> git.sur5r.net Git - cc65/commitdiff
Merge pull request #433 from clbr/trampoline-fixes
authorOliver Schmidt <ol.sc@web.de>
Sat, 20 May 2017 10:29:10 +0000 (12:29 +0200)
committerGitHub <noreply@github.com>
Sat, 20 May 2017 10:29:10 +0000 (12:29 +0200)
Trampoline fixes

doc/cc65.sgml
doc/vic20.sgml
libsrc/c128/joy/c128-stdjoy.s
src/cc65.vcxproj
src/common.vcxproj

index 2e480e4c3f27e71141540a6320497f48addf58e5..3689c0b35e37edfe11500b78add6ca88335b67d3 100644 (file)
@@ -4,7 +4,7 @@
 <title>cc65 Users Guide
 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
 <url url="mailto:gregdk@users.sf.net" name="Greg King">
-<date>2017-03-21
+<date>2017-05-20
 
 <abstract>
 cc65 is a C compiler for 6502 targets. It supports several 6502 based home
@@ -1229,27 +1229,36 @@ parameter with the <tt/#pragma/.
   </verb></tscreen>
 
 
-<sect1><tt>#pragma wrapped-call (&lt;push&rt;, &lt;name&gt;, &lt;identifier&gt;)</tt><label id="pragma-wrapped-call"><p>
+<sect1><tt>#pragma wrapped-call (push, &lt;name&gt;, &lt;identifier&gt;)</tt><label id="pragma-wrapped-call"><p>
 
   This pragma sets a wrapper for functions, often used for trampolines.
-  The name is a function returning void and taking no parameters.
-  The identifier is an 8-bit number that's set to tmp4.
 
-  The address of the function is passed in ptr4.
+  The name is a function returning <tt/void/, and taking no parameters.
+  It must preserve the CPU's <tt/A/ and <tt/X/ registers if it wraps any
+  <tt/__fastcall__/ functions that have parameters.  It must preserve
+  the <tt/Y/ register if it wraps any variadic functions (they have "<tt/.../"
+  in their prototypes).
 
-  This is useful for example with banked memory, to automatically
-  switch banks to where this function resides, and then restore
-  the bank when it returns.
+  The identifier is an 8-bit number that's set into <tt/tmp4/.
 
-  The <tt/#pragma/ requires the push and pop parameters as explained above.
+  The address of a wrapped function is passed in <tt/ptr4/.  The wrapper can
+  call that function by using "<tt/jsr callptr4/".
+
+  This feature is useful, for example, with banked memory, to switch banks
+  automatically to where a wrapped function resides, and then to restore the
+  previous bank when it returns.
+
+  The <tt/#pragma/ requires the push or pop argument as explained above.
 
   Example:
   <tscreen><verb>
-       void mytrampoline(void);
+/* Note that this code can be in a header. */
+void mytrampoline(void); /* Doesn't corrupt __AX__ */
 
-        #pragma wrapped-call (push, mytrampoline, 0)
-        void somefunc(void);
-        #pragma wrapped-call (pop)
+#pragma wrapped-call (push, mytrampoline, 5)
+void somefunc1(void);
+void somefunc2(int, char *);
+#pragma wrapped-call (pop)
   </verb></tscreen>
 
 
index b1a08ac83bb56b8e7237290d2f31dc660b6afe42..26a4aa55829d8ee8f7bfbfbb66248e711a4c6c01 100644 (file)
@@ -2,11 +2,11 @@
 
 <article>
 
-<title>Commodore VIC20 (aka VC20) specific information for cc65
+<title>Commodore VIC20 (aka VC20 aka VIC1001) specific information for cc65
 <author>
 <url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
 <url url="mailto:polluks@sdf.lonestar.org" name="Stefan A. Haubenthal">
-<date>2014-04-12
+<date>2017-05-18
 
 <abstract>
 An overview over the VIC20 runtime system as it is implemented for the cc65 C
@@ -182,13 +182,14 @@ No VIC1011 drivers are currently available for the VIC20.
 <sect>Limitations<p>
 
 
+<sect1>Escape code<p>
 
-<sect>Other hints<p>
+The CTRL key cannot be used to type most control characters,
+entering an Esc is not possible.
 
 
-<sect1>Escape code<p>
 
-For an Esc, press CTRL and the <tt/[/ key.
+<sect>Other hints<p>
 
 
 <sect1>Passing arguments to the program<p>
@@ -219,8 +220,7 @@ The program return code (low byte) is passed back to BASIC by use of the
 
 <sect1>Using extended memory<p>
 
-The extended memory at $A000 may be added to the heap by using the following
-code:
+BLK5 memory may be added to the heap by using the following code:
 
 <tscreen><verb>
     /* Check for the existence of RAM */
index 119d3784f5b25aef7778e67fb7e3c8fe4facc057..a2caead1a17228f9f4a6071b6e64e35fb25846de 100644 (file)
@@ -104,7 +104,7 @@ joy1:   lda     #$7F
         sei
         sta     CIA1_PRA
         lda     CIA1_PRB
-        cli
+back:   cli
         and     #$1F
         eor     #$1F
         rts
@@ -118,9 +118,4 @@ joy2:   ldx     #0
         sta     CIA1_DDRA
         lda     CIA1_PRA
         sty     CIA1_DDRA
-        cli
-        and     #$1F
-        eor     #$1F
-        rts
-
-
+        jmp     back
index 1c1f993fe0960ae795d357acc3dba96d993513bf..70f43dc73212f85ed515906e9118c626393753ba 100644 (file)
     <ClInclude Include="cc65\typecmp.h" />
     <ClInclude Include="cc65\typeconv.h" />
     <ClInclude Include="cc65\util.h" />
+    <ClInclude Include="cc65\wrappedcall.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="cc65\anonname.c" />
     <ClCompile Include="cc65\typecmp.c" />
     <ClCompile Include="cc65\typeconv.c" />
     <ClCompile Include="cc65\util.c" />
+    <ClCompile Include="cc65\wrappedcall.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index 053d2398181a70e9be7ddb1145fbaa73647ca256..39fea35e5f48fd6907a4e07c2bbac6d9130edd6a 100644 (file)
@@ -38,6 +38,7 @@
     <ClInclude Include="common\hashtab.h" />
     <ClInclude Include="common\hlldbgsym.h" />
     <ClInclude Include="common\inline.h" />
+    <ClInclude Include="common\intptrstack.h" />
     <ClInclude Include="common\intstack.h" />
     <ClInclude Include="common\inttypes.h" />
     <ClInclude Include="common\libdefs.h" />
@@ -87,6 +88,7 @@
     <ClCompile Include="common\gentype.c" />
     <ClCompile Include="common\hashfunc.c" />
     <ClCompile Include="common\hashtab.c" />
+    <ClCompile Include="common\intptrstack.c" />
     <ClCompile Include="common\intstack.c" />
     <ClCompile Include="common\matchpat.c" />
     <ClCompile Include="common\mmodel.c" />