This is the open source Pawn interpreter ported to mbed. See here: http://www.compuphase.com/pawn/pawn.htm and here: http://code.google.com/p/pawnscript/

Dependents:   Pawn4Test

Some instructions:

  • Put the attached include folder next to your source, so when you compile you get all the proper definitions
  • Use the attached main.p as a starting point if you wish
  • Compile your main.p into main.amx - Put your main.amx on the mbed 'drive'
  • Reset and be amazed.

Important Compile Notes:

  • You should use the -S# option to define a smaller default stack size. Start with -S64 and go up from there if needed.
  • To use on the Cortex-M0 version of the mbed (LPC11U24), you MUST include the TARGET=3 command-line option as well, so the pin names are properly defined. In the future this may be handled on the native code side.

Known Issues:

  • At the moment it appears the kbhit() function is not working right - at least on my mac. Will continue testing on Windows. Working fine.

Todo:

  • Add more wrappers for the mbed peripherals
  • Add Pawn overlay support, to allow much larger scripts to run (even on the LPC11U24)
Committer:
tylerwilson
Date:
Wed May 22 12:20:59 2013 +0000
Revision:
1:cc719e522b5d
Parent:
0:3ab1d2d14eb3
Child:
2:01588bd27169
Small cleanup in main.cpp test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tylerwilson 0:3ab1d2d14eb3 1 /*
tylerwilson 0:3ab1d2d14eb3 2 * Platform
tylerwilson 0:3ab1d2d14eb3 3 * __MSDOS__ set when compiling for DOS (not Windows)
tylerwilson 0:3ab1d2d14eb3 4 * _Windows set when compiling for any version of Microsoft Windows
tylerwilson 0:3ab1d2d14eb3 5 * __WIN32__ set when compiling for Windows95 or WindowsNT (32 bit mode)
tylerwilson 0:3ab1d2d14eb3 6 * __32BIT__ set when compiling in 32-bit "flat" mode (DOS, Windows, ARM)
tylerwilson 0:3ab1d2d14eb3 7 * __64BIT__ set when compiling in 64-bit mode
tylerwilson 0:3ab1d2d14eb3 8 * __ECOS__ set if Pawn was included with the eCos with configtool
tylerwilson 0:3ab1d2d14eb3 9 * __LINUX__ set when compiling for Linux
tylerwilson 0:3ab1d2d14eb3 10 *
tylerwilson 0:3ab1d2d14eb3 11 * Copyright 1998-2011, ITB CompuPhase, The Netherlands.
tylerwilson 0:3ab1d2d14eb3 12 * No usage restrictions, no warranties.
tylerwilson 0:3ab1d2d14eb3 13 */
tylerwilson 0:3ab1d2d14eb3 14
tylerwilson 0:3ab1d2d14eb3 15 #ifndef _OSDEFS_H
tylerwilson 0:3ab1d2d14eb3 16 #define _OSDEFS_H
tylerwilson 0:3ab1d2d14eb3 17
tylerwilson 0:3ab1d2d14eb3 18 /* Every compiler uses different "default" macros to indicate the mode
tylerwilson 0:3ab1d2d14eb3 19 * it is in. Throughout the source, we use the Borland C++ macros, so
tylerwilson 0:3ab1d2d14eb3 20 * the macros of Watcom C/C++ and Microsoft Visual C/C++ are mapped to
tylerwilson 0:3ab1d2d14eb3 21 * those of Borland C++.
tylerwilson 0:3ab1d2d14eb3 22 */
tylerwilson 0:3ab1d2d14eb3 23 #if defined(__WATCOMC__)
tylerwilson 0:3ab1d2d14eb3 24 #if defined(__WINDOWS__) || defined(__NT__)
tylerwilson 0:3ab1d2d14eb3 25 #define _Windows 1
tylerwilson 0:3ab1d2d14eb3 26 #endif
tylerwilson 0:3ab1d2d14eb3 27 #if defined(__386__) || defined(__NT__)
tylerwilson 0:3ab1d2d14eb3 28 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 29 #endif
tylerwilson 0:3ab1d2d14eb3 30 #if defined(_Windows) && defined(__32BIT__)
tylerwilson 0:3ab1d2d14eb3 31 #define __WIN32__ 1
tylerwilson 0:3ab1d2d14eb3 32 #endif
tylerwilson 0:3ab1d2d14eb3 33 #elif defined(_MSC_VER)
tylerwilson 0:3ab1d2d14eb3 34 #if defined(_WINDOWS) || defined(_WIN32)
tylerwilson 0:3ab1d2d14eb3 35 #define _Windows 1
tylerwilson 0:3ab1d2d14eb3 36 #endif
tylerwilson 0:3ab1d2d14eb3 37 #if defined(_WIN32)
tylerwilson 0:3ab1d2d14eb3 38 #define __WIN32__ 1
tylerwilson 0:3ab1d2d14eb3 39 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 40 #endif
tylerwilson 0:3ab1d2d14eb3 41 #elif defined __arm__
tylerwilson 0:3ab1d2d14eb3 42 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 43 #elif defined __AVR__
tylerwilson 0:3ab1d2d14eb3 44 #define __16BIT__ 1
tylerwilson 0:3ab1d2d14eb3 45 #endif
tylerwilson 0:3ab1d2d14eb3 46 #if !defined __16BIT__ && !defined __32BIT__ && !defined __64BIT__
tylerwilson 0:3ab1d2d14eb3 47 #define __32BIT__ 1
tylerwilson 0:3ab1d2d14eb3 48 #endif
tylerwilson 0:3ab1d2d14eb3 49
tylerwilson 0:3ab1d2d14eb3 50 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC11U24)
tylerwilson 0:3ab1d2d14eb3 51 #define AMX_ANSIONLY 1
tylerwilson 0:3ab1d2d14eb3 52 #define AMX_NODYNALOAD 1
tylerwilson 0:3ab1d2d14eb3 53 #define AMX_TERMINAL 1
tylerwilson 1:cc719e522b5d 54 // #define AMX_ASM 1
tylerwilson 0:3ab1d2d14eb3 55
tylerwilson 0:3ab1d2d14eb3 56 // #define TCHAR char
tylerwilson 0:3ab1d2d14eb3 57 // #define __T(x) (x)
tylerwilson 0:3ab1d2d14eb3 58 #define stime(x) (x)
tylerwilson 0:3ab1d2d14eb3 59 #endif
tylerwilson 0:3ab1d2d14eb3 60
tylerwilson 0:3ab1d2d14eb3 61 #if (defined __linux || defined __linux__) && !defined __LINUX__
tylerwilson 0:3ab1d2d14eb3 62 #define __LINUX__
tylerwilson 0:3ab1d2d14eb3 63 #endif
tylerwilson 0:3ab1d2d14eb3 64 /* To be able to eventually set __ECOS__, we have to find a symbol
tylerwilson 0:3ab1d2d14eb3 65 * defined in a common place (so including the header file won't break
tylerwilson 0:3ab1d2d14eb3 66 * anything for other platforms). <sys/types.h> includes
tylerwilson 0:3ab1d2d14eb3 67 * <pkgconf/system.h> and in this later file we can find CYGPKG_PAWN
tylerwilson 0:3ab1d2d14eb3 68 * if the Pawn package was included with configtool and so we know
tylerwilson 0:3ab1d2d14eb3 69 * that we are compiling for eCos.
tylerwilson 0:3ab1d2d14eb3 70 */
tylerwilson 0:3ab1d2d14eb3 71 #if defined CCSINFO
tylerwilson 0:3ab1d2d14eb3 72 #include <sys/types.h>
tylerwilson 0:3ab1d2d14eb3 73 #endif
tylerwilson 0:3ab1d2d14eb3 74 #if defined CYGPKG_PAWN
tylerwilson 0:3ab1d2d14eb3 75 #define __ECOS__ 1
tylerwilson 0:3ab1d2d14eb3 76 #define HAVE_ALLOCA_H 0
tylerwilson 0:3ab1d2d14eb3 77 #endif
tylerwilson 0:3ab1d2d14eb3 78
tylerwilson 0:3ab1d2d14eb3 79
tylerwilson 0:3ab1d2d14eb3 80 #if defined __FreeBSD__
tylerwilson 0:3ab1d2d14eb3 81 #include <sys/endian.h>
tylerwilson 0:3ab1d2d14eb3 82 #elif defined __LINUX__
tylerwilson 0:3ab1d2d14eb3 83 #include <endian.h>
tylerwilson 0:3ab1d2d14eb3 84 #elif defined __ECOS__
tylerwilson 0:3ab1d2d14eb3 85 #include <cyg/hal/hal_endian.h>
tylerwilson 0:3ab1d2d14eb3 86 #define BIG_ENDIAN 4321
tylerwilson 0:3ab1d2d14eb3 87 #define LITTLE_ENDIAN 1234
tylerwilson 0:3ab1d2d14eb3 88 #if (CYG_BYTEORDER == CYG_LSBFIRST)
tylerwilson 0:3ab1d2d14eb3 89 #define BYTE_ORDER LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 90 #else
tylerwilson 0:3ab1d2d14eb3 91 #define BYTE_ORDER BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 92 #endif
tylerwilson 0:3ab1d2d14eb3 93 /*
tylerwilson 0:3ab1d2d14eb3 94 * eCos option management.
tylerwilson 0:3ab1d2d14eb3 95 */
tylerwilson 0:3ab1d2d14eb3 96 #include <pkgconf/pawn.h>
tylerwilson 0:3ab1d2d14eb3 97 #if CYGPKG_PAWN_AMX_ANSIONLY==1
tylerwilson 0:3ab1d2d14eb3 98 #define AMX_ANSIONLY
tylerwilson 0:3ab1d2d14eb3 99 #endif
tylerwilson 0:3ab1d2d14eb3 100 #define PAWN_CELL_SIZE CYGPKG_PAWN_AMX_CELLSIZE
tylerwilson 0:3ab1d2d14eb3 101 #if CYGPKG_PAWN_CORE_RANDOM==0
tylerwilson 0:3ab1d2d14eb3 102 #define AMX_NORANDOM
tylerwilson 0:3ab1d2d14eb3 103 #endif
tylerwilson 0:3ab1d2d14eb3 104 #if CYGPKG_PAWN_CORE_PROPERTY==0
tylerwilson 0:3ab1d2d14eb3 105 #define AMX_NOPROPLIST
tylerwilson 0:3ab1d2d14eb3 106 #endif
tylerwilson 0:3ab1d2d14eb3 107 #if CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
tylerwilson 0:3ab1d2d14eb3 108 #define FIXEDPOINT
tylerwilson 0:3ab1d2d14eb3 109 #endif
tylerwilson 0:3ab1d2d14eb3 110 #if CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
tylerwilson 0:3ab1d2d14eb3 111 #define FLOATPOINT
tylerwilson 0:3ab1d2d14eb3 112 #endif
tylerwilson 0:3ab1d2d14eb3 113 #endif
tylerwilson 0:3ab1d2d14eb3 114
tylerwilson 0:3ab1d2d14eb3 115 /* Linux now has these */
tylerwilson 0:3ab1d2d14eb3 116 #if !defined BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 117 #define BIG_ENDIAN 4321
tylerwilson 0:3ab1d2d14eb3 118 #endif
tylerwilson 0:3ab1d2d14eb3 119 #if !defined LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 120 #define LITTLE_ENDIAN 1234
tylerwilson 0:3ab1d2d14eb3 121 #endif
tylerwilson 0:3ab1d2d14eb3 122
tylerwilson 0:3ab1d2d14eb3 123 /* educated guess, BYTE_ORDER is undefined, i386 is common => little endian */
tylerwilson 0:3ab1d2d14eb3 124 #if !defined BYTE_ORDER
tylerwilson 0:3ab1d2d14eb3 125 #if defined UCLINUX
tylerwilson 0:3ab1d2d14eb3 126 #define BYTE_ORDER BIG_ENDIAN
tylerwilson 0:3ab1d2d14eb3 127 #else
tylerwilson 0:3ab1d2d14eb3 128 #define BYTE_ORDER LITTLE_ENDIAN
tylerwilson 0:3ab1d2d14eb3 129 #endif
tylerwilson 0:3ab1d2d14eb3 130 #endif
tylerwilson 0:3ab1d2d14eb3 131
tylerwilson 0:3ab1d2d14eb3 132 #if defined __MSDOS__ || defined __WIN32__ || defined _Windows
tylerwilson 0:3ab1d2d14eb3 133 #define DIRSEP_CHAR '\\'
tylerwilson 0:3ab1d2d14eb3 134 #elif defined macintosh || defined __APPLE__
tylerwilson 0:3ab1d2d14eb3 135 #define DIRSEP_CHAR ':'
tylerwilson 0:3ab1d2d14eb3 136 #else
tylerwilson 0:3ab1d2d14eb3 137 #define DIRSEP_CHAR '/' /* directory separator character */
tylerwilson 0:3ab1d2d14eb3 138 #endif
tylerwilson 0:3ab1d2d14eb3 139
tylerwilson 0:3ab1d2d14eb3 140 /* _MAX_PATH is sometimes called differently and it may be in limits.h or
tylerwilson 0:3ab1d2d14eb3 141 * stdlib.h instead of stdio.h.
tylerwilson 0:3ab1d2d14eb3 142 */
tylerwilson 0:3ab1d2d14eb3 143 #if !defined _MAX_PATH
tylerwilson 0:3ab1d2d14eb3 144 /* not defined, perhaps stdio.h was not included */
tylerwilson 0:3ab1d2d14eb3 145 #if !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 146 #include <stdio.h>
tylerwilson 0:3ab1d2d14eb3 147 #endif
tylerwilson 0:3ab1d2d14eb3 148 #if !defined _MAX_PATH && !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 149 /* no _MAX_PATH and no MAX_PATH, perhaps it is in limits.h */
tylerwilson 0:3ab1d2d14eb3 150 #include <limits.h>
tylerwilson 0:3ab1d2d14eb3 151 #endif
tylerwilson 0:3ab1d2d14eb3 152 #if !defined _MAX_PATH && !defined PATH_MAX
tylerwilson 0:3ab1d2d14eb3 153 /* no _MAX_PATH and no MAX_PATH, perhaps it is in stdlib.h */
tylerwilson 0:3ab1d2d14eb3 154 #include <stdlib.h>
tylerwilson 0:3ab1d2d14eb3 155 #endif
tylerwilson 0:3ab1d2d14eb3 156 /* if _MAX_PATH is undefined, try common alternative names */
tylerwilson 0:3ab1d2d14eb3 157 #if !defined _MAX_PATH
tylerwilson 0:3ab1d2d14eb3 158 #if defined MAX_PATH
tylerwilson 0:3ab1d2d14eb3 159 #define _MAX_PATH MAX_PATH
tylerwilson 0:3ab1d2d14eb3 160 #elif defined _POSIX_PATH_MAX
tylerwilson 0:3ab1d2d14eb3 161 #define _MAX_PATH _POSIX_PATH_MAX
tylerwilson 0:3ab1d2d14eb3 162 #else
tylerwilson 0:3ab1d2d14eb3 163 /* everything failed, actually we have a problem here... */
tylerwilson 0:3ab1d2d14eb3 164 #define _MAX_PATH 1024
tylerwilson 0:3ab1d2d14eb3 165 #endif
tylerwilson 0:3ab1d2d14eb3 166 #endif
tylerwilson 0:3ab1d2d14eb3 167 #endif
tylerwilson 0:3ab1d2d14eb3 168
tylerwilson 0:3ab1d2d14eb3 169 #endif /* _OSDEFS_H */