--- gforth/code.fs 2010/04/17 21:31:36 1.21 +++ gforth/code.fs 2010/12/31 18:09:02 1.23 @@ -1,6 +1,6 @@ \ ASSEMBLER, CODE etc. -\ Copyright (C) 1995,1996,1997,1999,2003,2007 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1999,2003,2007,2010 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -41,7 +41,7 @@ vocabulary assembler ( -- ) \ tools-ext defstart init-asm ; [ifdef] doabicode: -: abi-code ( "name" -- colon-sys ) \ gforth abi_code +: abi-code ( "name" -- colon-sys ) \ gforth abi-code \G Start a native code definition that is called using the platform's \G ABI conventions corresponding to the C-prototype: \G @example @@ -69,10 +69,17 @@ vocabulary assembler ( -- ) \ tools-ext interpret/compile: ;code ( compilation. colon-sys1 -- colon-sys2 ) \ tools-ext semicolon-code \g The code after @code{;code} becomes the behaviour of the last \g defined word (which must be a @code{create}d word). The same -\g caveats apply as for @code{code}, but Gforth does not have a -\g @code{;abi-code} yet. As a workaround, you can use @code{does> foo -\g ;} instead, where @code{foo} is defined with @code{abi-code}. +\g caveats apply as for @code{code}, so we recommend using +\g @code{;abi-code} instead. +[ifdef] do;abicode: +: !;abi-code ( addr -- ) + latestxt do;abicode: any-code! ; + +: ;abi-code ( -- ) \ gforth semicolon-abi-code + ['] !;abi-code does>-like postpone [ init-asm ; immediate +[then] + : end-code ( colon-sys -- ) \ gforth end_code \G End a code definition. Note that you have to assemble the \G return from the ABI call (for @code{abi-code}) or the dispatch @@ -80,4 +87,3 @@ interpret/compile: ;code ( compilation. \G yourself. latestxt here over - flush-icache previous ?struc reveal ; -