pawn
An embedded scripting language
Summary of recent changes
- 25 March, 2024 — version 4.1.7152
-
- Optimized assembler core for ARMv6-M architecture (ARM Cortex M0/M0+). Further (minor) optimizations in the other ARM assembler cores.
-
New function
amx_VerifyAddress()
, to test whether an address is valid in the sandbox of the abstract machine. -
Added "
#pragma opcodeset
" in the compiler, so that the instruction set that a target supports, can be set in the target's configuration file. - Adjust the assembler cores such that they can be built with either GNU GCC or GNU AS (both use a different syntax for assembly macros).
- A few more cases were added to the peephole optimizer in the compiler.
-
The compiler allows the "
var
" keyword as the equivalent of the "new
" keyword. That is, "var
" creates a new variable. - The Implementer Guide is expanded with a section (plus an example) on running scripts from ROM, and minimizing the footprint of the abstract machine.
- Fixes in support for 64-bit code, both in the Pawn compiler and in the abstract machine.
- Fixes in the garbage collector (this is an optional module for the abstract machine).
- BUG fix: the compiler applied an incorrect high bound for packed strings.
- BUG fix: the compiler did not handle progressive initiallers correctly in packed arrays.
- 13 June, 2017 — version 4.0.5691
-
- Addition of a tool to create "dot" files for the Graphviz programs, to create graphs of state machines.
- The location of configuration files for target hosts has changed, from the "bin" directory to the directory "targets". The default configuration file is now "default.cfg". For backward compatibility, if no "default.cfg" is found (and no other configuration file is specified), the compiler falls back to "pawn.cfg" file in the "bin" directory.
- For target host, host-specific include files have moved to a sub-directory with the name of the target host, below the "include" directory. This is similar to the locations of host-specific documentation and samples.
-
In Quincy (the pawn IDE), the sample browser has returned. In the menu, see
Tools / Sample browser...
-
The
STACK
opcode has different semantics: it now sets theALT
register to the value ofSTK
after adjusting it (instead of setting it to the value thatSTK
had before the adjustment). This change has no impact on compiled scripts or the abstract machine. In the past and current release, the pawn compiler does not rely on theALT
register after aSTACK
opcode. -
Portability fix: Linux no longer provides the
spawn()
function, so it has been emulated withposix_spawn()
andwaitpid()
. - BUG fix: in support of packed opcodes, since the support for 64-bit cells, negative parameters were no longer optimized to packed opcodes. (The generated code was correct, but sub-optimal.)
- BUG fix: code generation error for native functions that return an array. (pawn functions returning an array were not affected.)
- 26 October, 2016 — version 4.0.5588
-
- The IDE has been rewritten in wxWidgets (instead of MFC), so that it now runs on Linux as well.
- New warning to check for functions whose existence is tested (in conditionally compiled sections) before the functions are defined (which also requires an extra compilation pass).
- Identical literal strings are merged, as to reduce the "data" memory footprint.
- #warning directive (which works like #error, with the exception that it is a non-fatal message).
- #pragma warning directive, to push/pop/enable/disable warnings.
- #ifdef and #ifndef are supported (in addition to #if defined) for compatibility with C.
- The default extension for include files are now both .i and .inc.
- All documentation is updated to a format that is easier to read from a screen (as opposed to being printed).
- Improved support for new versions of GCC, clang and Borland/Embarcadero.
- BUG fix: dangling comma on initializers of two-dimensional arrays caused incorrect code generation. This has been corrected.
- BUG fix: when two files have a symbol with the same name, the debugger could pick the wrong source file. This has been corrected.
- BUG fix in test for UTF-8 files.
- 21 June, 2012 — version 4.0.4733
-
- BUG fix: the optimizer generated wrong code for subtraction of a variable from a constant. This has been corrected.
- BUG fix: overlay code caused "legacy" virtual instructions to be generated, instead of the instructions from the new set.
- The CMake build scripts were updated to reflect the changes in recent versions of CMake.
- In Quincy, the bottom panel may close automatically when it looses focus and re-open when it gains focus. This allows to keep a large edit window and still access the build/log windows with a single click. (Note: this functionality can be disabled in the application options.)
- In Quincy, code snippets may now optionally also expand on a space character (previously, only the TAB character was supported).
- A compilation problem with the ARM7 and Thumb2 cores, in combination with recent releases of the GNU "newlib" chain, has been corrected.
- 1 August, 2011 — version 4.0.4548
-
-
The instruction set of the pawn abstract machine has been revised and cleaned
up. This release is therefore not compatible with previous releases. AMX files
built with an old version of the pawn compiler (before 4.0) will not run with
the current abstract machine, and AMX files built with the current compiler
will not run with the old abstract machine.
The pawn language itself has also changed in the area of handling arrays with symbolic subscripts and handling packed versus unpacked arrays. The scripts need to be adjusted to the new syntax to compile in version 4.0.
See the separate "Pawn Porting Guide" for instructions for porting scripts and host applications from pawn 3.x to pawn 4.0.
-
The pawn abstract machine now supports three sets of instructions:
- The "core" set is the minimal set of instructions that an abstract machine must implement. If you need to minimize the footprint of the pawn abstract machine (e.g. on an embedded system on a small micro-controller), use this set. A Just-In-Time compiler will typically also implement the core set.
- The "supplemental" set adds macro instructions to the core set. A macro instruction replaces two or more of the core instructions by a single one. This reduces the size of the script and makes it run quicker as well (by reducing the overhead of decoding the instructions). For a Just-In-Time compiler, it is usually redundant to support this, because the macro instructions are typically translated to the same native code as the original sequence of core instructions.
- The "full" instruction set is a superset that adds "packed" instructions to the supplemental+core instruction set. Packed instructions decrease the size that the compiled script takes. It is mostly useful on embedded systems (with a small micro-controller) that run a script from RAM (but have enough ROM to contain a full abstract machine).
- The interface to public functions in the abstract machine has changed slightly: functions that allocate memory inside the abstract machine now return only a single pointer. Previous versions returned two pointers: one pointer to access the data, and one pointer to pass to the abstract machine (a "virtual" pointer). The manual has been updated for this; see also the "Pawn Porting Guide".
-
The interface in the abstract machine to native functions has changed: native
functions now get passed addresses that it can use directly. Converting
addresses through
amx_GetAddr()
is no longer needed; in fact, that function no longer exists. See the "Pawn Porting Guide" for details. - The pawn compiler can now generate 32-bit, 64-bit or 16-bit AMX files (for the abstract machine). A new command-line option indicates the cell size. There is no more need to create two versions of the pawn compiler if you wish to support both 32-bit and 64-bit scripts.
-
The "
enum
" keyword is removed from the pawn language. Instead, "const
" now declares either single constants or enumerated lists. In most cases, you can just replace "enum
" with "const
", but note that the very first constant in the enumerated list must be initialized (it does not default to zero).For example:
const Ping: { b = 1, c, Pong: d // tag override }
-
In the language, the syntax for packed and unpacked strings has changed.
A packed string now uses the syntax:
"this is a packed string"
And unpacked string is now enclosed between two pairs of single quotes:''this is an unpacked string''
The left-most quotes may also be back-quotes (for similarity with TeX):``this is also an unpacked string''
-
For literal arrays and array initialization, the syntax has also changed.
Square brackets now mean unpacked arrays and braces (curly brackets) means
packed arrays. In a multi-dimensional array, only the last dimension may
be packed.
In practice, this means that in most cases the braces must be replaced by brackets. For example, to declare and initialize an array with four cells, you now use:
new rect[4] = [ 1, 2, 3, 4 ]
For packed arrays, you use braces both in the declaration of the array size and in the initialization. For example:
new packed{10} = {'a', 'b', 'c' ... }
The above declares an array of ten characters (these fit in three cells on a 32-bit configuration). -
The "
char
" keyword is gone, see above for the new way to declare packed arrays. -
Previous versions of pawn used enumerations and tags to simulate a
light-weight variant of structures. This has been replaced by a more direct
way to declare "symbolic indices" in arrays. An array can now be declared
as:
new rect[.left, .top, .right, .bottom]
The array can then only be indexed with one of the declared symbolic fields, such as in:rect[.bottom] = rect[.top] + 15
Since the only valid index is a symbolic field, the brackets may be omitted, giving the shorter equivalent:rect.bottom = rect.top + 15
Symbolic indices may specify a tag for the field, and may also indicate a (pseudo-)array. Please see the "Language Guide" for details.
-
To make the new way to specify symbolic indices more practical, the "
#define
" preprocessor directive now also supports definitions that are delimited with square brackets. This means that definitions do not have to fit on a single line. An example of such a declaration:
#define PRODUCT[ .code, .description{20}, Float: .price ]
Later, this definition can be used to declare an array, for example:
new product[PRODUCT]
- There are many minor improvements in Quincy, which enhance its usability. For example, when hoovering over a warning or error message, a balloon pops up with a description text for the message, and the relevant line in the source code is marked at the same time.
- Quincy has also obtained a symbol browser. This browser gets its data from the XML reports that are generated by the compiler. The symbol browser also extracts details from the documentation comments, and shows these in the pop-up balloons when appropriate.
-
The instruction set of the pawn abstract machine has been revised and cleaned
up. This release is therefore not compatible with previous releases. AMX files
built with an old version of the pawn compiler (before 4.0) will not run with
the current abstract machine, and AMX files built with the current compiler
will not run with the old abstract machine.
- 8 June, 2009 — version 3.3.4127
-
- The entire pawn toolkit is now licensed under the Apache license, version 2. The Apache license is a very liberal license (permitting use in commercial projects), but it contains a patent clause. The previous license (zLib/libpng) did not have a patent clause.
- wxQuincy, a minimalist IDE distributed in the Linux autopackage and TAR files now comes with source code. The IDE has been enhanced with a multiple-document interface.
- The compiler is now a little better at guessing the TAB size in case of mixed indentation with TABs and spaces. This avoids the warning "loose indentation" to be reported erroneously.
- Keep the stack 8-byte aligned in the ARM7 assembler versions of the abstract machine (some ARM compilers require this).
- amxFile uses the newest version of minIni.
- Quincy (Microsoft Windows version) now detects FTDI virtual ports (for remote debugging); it supports up to 15 user help files and it supports host-specific help files. Quincy now also has the ability to insert accented characters (extended ASCII), and a new "repeat star in multi-line comments" option.
- BUG fix with strings with an escape character followed by a single line comment (preprocessor parser error).
- BUG fix in expressions with chained relational operators and constant operands.
- BUG fix in the optimizer: removed redundant calls to malloc().
- BUG fix related to passing arrays based on an enumeration to a function.
- BUG fix in auto-completion in Quincy, related to non-alphabetic characters ('_' and '@').
- 8 April, 2009 — version 3.3.4097
-
-
The pawn compiler can now take a configuration file with specific settings for
an environment. New command line option:
-T
. The manual contains the details. - The Linux distribution now comes with a minimalist IDE, called wxQuincy.
- Uncrustify replaces "artistic style" as the code beautifier for Quincy.
- BUG fix: minor bug correction in missing comma in initialler of 2-dimensional array.
- Modifications in Quincy: better detection of read-only paths (or drives), an option to save the file in a different location without aborting the compile, a message in the "build log" that signals that a source file was changed since last build (and thus needs rebuilding), a window to view strings received over the serial line.
- Improvements for GraphApp terminal (multi-platform).
-
The pawn compiler can now take a configuration file with specific settings for
an environment. New command line option:
- 15 January, 2009 — version 3.3.4058
-
-
Function
amx_GetString()
would terminate packed ANSI strings with two trailing zero bytes. In one of the examples as printed in the manual, this would lead to a buffer overrun. - The compiler optimizer applied a wrong limit to parameters when choosing between packed and unpacked opcodes. This led to a case where the compiler generated a packed opcode, while the parameter did not fit in that packed opcode.
-
In
pawndisasm
: a few opcodes were given the wrong mnemonic. - When the compiler halted on a fatal error occurred inside an include file, the "parent files" were left open.
- The compiler would no longer build with the PAWN_LIGHT or PAWN_NO_CODEPAGE options, because a few new sections lacked the respective conditional-compilation wrappers.
- A bug was fixed in amx_Clone(). This bug was reported by Luke Salisbury on the pawn forum.
- Re-entry of the compiler might use data from the previous run. This bug, reported by Soren Hannibal on the pawn forum, was fixed.
- Quincy now comes with an improved "search in files" function, by using a modified version of GNU grep (see the file "grep.txt" for the modifications).
- Quincy now also supports auto-completion using Ctrl-Space. If multiple words match, Quincy pops up a balloon. Pressing TAB expands the word up to the first character where multiple matches differ.
- Warnings when building with Visual Studio 2008 were removed.
- Various other bug fixes and improvements.
-
Function
- 27 October, 2008 — version 3.3.4026
-
- SECURITY FIX ("arbitrary code execution" vulnerability): the CALL.pri and JUMP.pri instructions were removed, because one could use them to force a jump out of the virtual sand box of the abstract machine and call arbitrary code that is carefully laid out in the data section of the script.
-
"
exit
" state functions are now also supported (in addition to "entry
" state functions). -
Trailing commas are now allowed in the initialization data of arrays. For
example, the comma behind the closing brace of the second sub-array in the
following declaration is allowed (but optional). The commas behind the digits
2 and 4 are allowed too (and also optional).
new arr[2][2] = { { 1, 2,}, { 3, 4,}, }
-
The macro substitution processor now recognizes the "#" character for
"stringizing" a parameter. For example, if you have the definition
#define log(%1) #%1
Then the expression log(test) will result in"test"
.
Note that concatenation of literal strings requires an ellipsis in pawn (which is different than C/C++). So to combine the parameter with literal strings, use a syntax like:#define log(%1) "logging: " ... #%1 ... "\n"
The stringize operator is only available in the replacement text of a macro. - Support for the "thousands" separator (a comma) in numbers.
- When a source file contains indenting with both spaces and tab characters, and no explicit tab size is given, the compiler now makes an educated guess for the tab space to use. This reduces warnings about "loose indentation".
- The handshake of the debugger in a remote-debugging configuration is a little faster. That is, the debugger finds the remote device/host faster. Remote debugging is typically used with embedded systems.
- Better support for ncurses, which is now also the default for Linux (if it is installed).
- For the amxProcess module, the dyncall library now replaces the libffi library, because dyncall comes with ports for Unix/Linux, Macintosh and Windows (libffi only supported Unix-like systems). The amxProcess module now also compiles without dyncall, but with reduced functionality. See http://www.dyncall.org/ for details on dyncall.
- The "binreloc" module is now optional when compiling pawnrun and pawndbg under Linux; binreloc is part of the "autopackage" developer tools.
- A portable INI file parser in the amxFile extension module (see the minIni project).
- Support for code snippets and balloon "info tips" in Quincy, as well as supporting info-tips in the debugger for the current value of variables.
- Quincy supports workspaces (light-weight projects). A set of open files and the currently selected compilation options can be saved in a workspace, for quickly switching between projects.
-
BUG fix: the ternary operator ("
a ? b : c
") had a bug when "b" and "c" were arrays of different lengths. This bug was reported by Bailopan on the pawn forum. - BUG fix: amxFile had an error in the file CRC calculation.
-
BUG fix: function
uuencode()
in amxString was broken. -
BUG fix: when basing a one-dimensional array on an enumeration and using the
ellipsis ("
...
") in the initialler to initialize the complete array to a value, the ellipsis would drop out immediately and fail to fill the remainder with the given value/sequence. -
BUG fix in amxString:
valstr()
failed on large numbers. -
BUG fix: a string like
"\\"
was not accepted by the pawn compiler (double backslash at the end of a string). This was fixed before... a regression! - BUG fixes in amxpool (minor bugs).
- BUG fix: indexing an undeclared symbol made the compiler abort with an "assertion failed" message. This has been corrected.
- Various BUG fixes and improvements in the pawn debugger (pawndbg) for working with Quincy.
- Various other bug fixes, and many improvements in Quincy.
-
See the history.txt in the downloadable archives for a longer history.