summaryrefslogtreecommitdiff
path: root/misc/pascal/insn32/libinsn
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-18 16:30:25 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-18 16:30:25 +0000
commit9695e5c9051d331278288a071c1353ae7214c4c2 (patch)
tree060301cfc350c1532655c699ab2419e1c4c2e486 /misc/pascal/insn32/libinsn
parenteb3074a4fe3b7c86d2a3ca139eb881964f2f23e1 (diff)
downloadpx4-nuttx-9695e5c9051d331278288a071c1353ae7214c4c2.tar.gz
px4-nuttx-9695e5c9051d331278288a071c1353ae7214c4c2.tar.bz2
px4-nuttx-9695e5c9051d331278288a071c1353ae7214c4c2.zip
Update to use stdint/stdbool.h
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2384 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/pascal/insn32/libinsn')
-rw-r--r--misc/pascal/insn32/libinsn/paddopcode.c195
-rw-r--r--misc/pascal/insn32/libinsn/paddtmpopcode.c196
-rw-r--r--misc/pascal/insn32/libinsn/pdasm.c865
-rw-r--r--misc/pascal/insn32/libinsn/pgen.c765
-rw-r--r--misc/pascal/insn32/libinsn/pgetopcode.c254
-rw-r--r--misc/pascal/insn32/libinsn/preloc.c296
-rw-r--r--misc/pascal/insn32/libinsn/presettmpopcodewrite.c196
7 files changed, 1393 insertions, 1374 deletions
diff --git a/misc/pascal/insn32/libinsn/paddopcode.c b/misc/pascal/insn32/libinsn/paddopcode.c
index 247c46e2c..2f873eb7f 100644
--- a/misc/pascal/insn32/libinsn/paddopcode.c
+++ b/misc/pascal/insn32/libinsn/paddopcode.c
@@ -1,96 +1,99 @@
-/**********************************************************************
- * paddopcode
- * P-Code access utilities
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include "keywords.h"
-#include "podefs.h"
-#include "pinsn32.h"
-
-#include "paslib.h"
-#include "pofflib.h"
-#include "pinsn.h"
-
-/**********************************************************************
- * Private Function Prototypes
- **********************************************************************/
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Functions
- **********************************************************************/
-
-/**********************************************************************
- * Global Functions
- **********************************************************************/
-
-/**********************************************************************/
-
-void insn_AddOpCode(poffHandle_t hProg, OPTYPE *ptr)
-{
- /* Handle big-endian byte stream */
-
- (void)poffAddProgByte(hProg, ptr->op);
-
- /* Write the 32-bit argument if present */
-
- if (ptr->op & o32)
- {
- ubyte *pb = (ubyte*)&ptr->arg;
- (void)poffAddProgByte(hProg, pb[opB1]);
- (void)poffAddProgByte(hProg, pb[opB2]);
- (void)poffAddProgByte(hProg, pb[opB3]);
- (void)poffAddProgByte(hProg, pb[opB4]);
- }
-}
-
-/**********************************************************************/
-
-void insn_ResetOpCodeWrite(poffHandle_t hProg)
-{
- poffResetAccess(hProg);
-}
-
-/***********************************************************************/
+/**********************************************************************
+ * paddopcode
+ * P-Code access utilities
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+
+#include "keywords.h"
+#include "podefs.h"
+#include "pinsn32.h"
+
+#include "paslib.h"
+#include "pofflib.h"
+#include "pinsn.h"
+
+/**********************************************************************
+ * Private Function Prototypes
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Functions
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Functions
+ **********************************************************************/
+
+/**********************************************************************/
+
+void insn_AddOpCode(poffHandle_t hProg, OPTYPE *ptr)
+{
+ /* Handle big-endian byte stream */
+
+ (void)poffAddProgByte(hProg, ptr->op);
+
+ /* Write the 32-bit argument if present */
+
+ if (ptr->op & o32)
+ {
+ uint8_t *pb = (uint8_t*)&ptr->arg;
+
+ (void)poffAddProgByte(hProg, pb[opB1]);
+ (void)poffAddProgByte(hProg, pb[opB2]);
+ (void)poffAddProgByte(hProg, pb[opB3]);
+ (void)poffAddProgByte(hProg, pb[opB4]);
+ }
+}
+
+/**********************************************************************/
+
+void insn_ResetOpCodeWrite(poffHandle_t hProg)
+{
+ poffResetAccess(hProg);
+}
+
+/***********************************************************************/
diff --git a/misc/pascal/insn32/libinsn/paddtmpopcode.c b/misc/pascal/insn32/libinsn/paddtmpopcode.c
index 3b66521e0..e4e10b458 100644
--- a/misc/pascal/insn32/libinsn/paddtmpopcode.c
+++ b/misc/pascal/insn32/libinsn/paddtmpopcode.c
@@ -1,97 +1,99 @@
-/**********************************************************************
- * paddtmpopcode
- * P-Code access utilities
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include "keywords.h"
-#include "podefs.h"
-#include "pinsn32.h"
-
-#include "paslib.h"
-#include "pofflib.h"
-#include "pinsn.h"
-
-/**********************************************************************
- * Private Function Prototypes
- **********************************************************************/
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Functions
- **********************************************************************/
-
-/**********************************************************************
- * Global Functions
- **********************************************************************/
-
-/**********************************************************************/
-
-void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr)
-{
- /* Write the opcode which is always present */
-
- (void)poffAddTmpProgByte(hProg, ptr->op);
-
- /* Write the 32-bit argument if present */
-
- if (ptr->op & o32)
- {
- ubyte *pb = (ubyte*)&ptr->arg;
-
- (void)poffAddTmpProgByte(hProg, pb[opB1]);
- (void)poffAddTmpProgByte(hProg, pb[opB2]);
- (void)poffAddTmpProgByte(hProg, pb[opB3]);
- (void)poffAddTmpProgByte(hProg, pb[opB4]);
- }
-}
-
-/**********************************************************************/
-
-void insn_ResetTmpOpCodeWrite(poffProgHandle_t hProg)
-{
- poffResetProgHandle(hProg);
-}
-
-/***********************************************************************/
+/**********************************************************************
+ * paddtmpopcode
+ * P-Code access utilities
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+
+#include "keywords.h"
+#include "podefs.h"
+#include "pinsn32.h"
+
+#include "paslib.h"
+#include "pofflib.h"
+#include "pinsn.h"
+
+/**********************************************************************
+ * Private Function Prototypes
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Functions
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Functions
+ **********************************************************************/
+
+/**********************************************************************/
+
+void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr)
+{
+ /* Write the opcode which is always present */
+
+ (void)poffAddTmpProgByte(hProg, ptr->op);
+
+ /* Write the 32-bit argument if present */
+
+ if (ptr->op & o32)
+ {
+ uint8_t *pb = (uint8_t*)&ptr->arg;
+
+ (void)poffAddTmpProgByte(hProg, pb[opB1]);
+ (void)poffAddTmpProgByte(hProg, pb[opB2]);
+ (void)poffAddTmpProgByte(hProg, pb[opB3]);
+ (void)poffAddTmpProgByte(hProg, pb[opB4]);
+ }
+}
+
+/**********************************************************************/
+
+void insn_ResetTmpOpCodeWrite(poffProgHandle_t hProg)
+{
+ poffResetProgHandle(hProg);
+}
+
+/***********************************************************************/
diff --git a/misc/pascal/insn32/libinsn/pdasm.c b/misc/pascal/insn32/libinsn/pdasm.c
index 0db6db932..75d79d7b6 100644
--- a/misc/pascal/insn32/libinsn/pdasm.c
+++ b/misc/pascal/insn32/libinsn/pdasm.c
@@ -1,429 +1,436 @@
-/**********************************************************************
- * pdasm.c
- * P-Code Disassembler
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-#include <stdio.h>
-
-#include "keywords.h"
-#include "podefs.h"
-#include "pinsn32.h"
-#include "pfdefs.h"
-#include "pxdefs.h"
-#include "paslib.h"
-
-#include "pinsn.h"
-
-/***********************************************************************/
-
-/* These are all the format codes that apply to opcodes with an argument */
-
-enum {
- SIMPLE = 0, /* No argument */
- HEX, /* Hexadecimal argument */
- DECIMAL, /* Signed Decimal argument (w/shift) */
- UDECIMAL, /* Unsigned Decimal argument (w/shift) */
- LABEL_DEC, /* Label number */
- xOP, lbOP, fpOP, /* Sub opcode */
- FILENO, LINENO /* File number, line number */
-};
-
-/* The following table defines everything that is needed to disassemble
- * a P-Code. NOTE: The order of definition in this table must exactly
- * match the declaration sequence in pinsn.h. */
-
-static const char invOp[] = "Invalid Opcode";
-struct optab_s
-{
- const char *opName; /* Opcode mnemonics */
- ubyte format; /* arg16 format */
-};
-
-/******************** OPCODES WITH NO ARGUMENTS *************************/
-
-static const struct optab_s g_sNoArgOpTable[64] =
-{
- /* Program control (No stack arguments) */
-
- /* 0x00 */ { "NOP ", SIMPLE },
-
- /* Arithmetic & logical & and integer conversions (One stack argument) */
-
- /* 0x01 */ { "NEG ", SIMPLE },
- /* 0x02 */ { "ABS ", SIMPLE },
- /* 0x03 */ { "INC ", SIMPLE },
- /* 0x04 */ { "DEC ", SIMPLE },
- /* 0x05 */ { "NOT ", SIMPLE },
-
- /* Arithmetic & logical (Two stack arguments) */
-
- /* 0x06 */ { "ADD ", SIMPLE },
- /* 0x07 */ { "SUB ", SIMPLE },
- /* 0x08 */ { "MUL ", SIMPLE },
- /* 0x09 */ { "DIV ", SIMPLE },
- /* 0x0a */ { "MOD ", SIMPLE },
- /* 0x0b */ { "SLL ", SIMPLE },
- /* 0x0c */ { "SRL ", SIMPLE },
- /* 0x0d */ { "SRA ", SIMPLE },
- /* 0x0e */ { "OR ", SIMPLE },
- /* 0x0f */ { "AND ", SIMPLE },
-
- /* Comparisons (One stack argument) */
-
- /* 0x10 */ { "EQUZ ", SIMPLE },
- /* 0x11 */ { "NEQZ ", SIMPLE },
- /* 0x12 */ { "LTZ ", SIMPLE },
- /* 0x13 */ { "GTEZ ", SIMPLE },
- /* 0x14 */ { "GTZ ", SIMPLE },
- /* 0x15 */ { "LTEZ ", SIMPLE },
- /* 0x16 */ { invOp, SIMPLE },
- /* 0x17 */ { invOp, SIMPLE },
-
- /* Comparisons (Two stack arguments) */
-
- /* 0x18 */ { "EQU ", SIMPLE },
- /* 0x19 */ { "NEQ ", SIMPLE },
- /* 0x1a */ { "LT ", SIMPLE },
- /* 0x1b */ { "GTE ", SIMPLE },
- /* 0x1c */ { "GT ", SIMPLE },
- /* 0x1d */ { "LTE ", SIMPLE },
- /* 0x1e */ { invOp, SIMPLE },
- /* 0x1f */ { "BIT ", SIMPLE },
-
- /* Load (One) or Store (Two stack argument) */
-
- /* 0x20 */ { "LDI ", SIMPLE },
- /* 0x21 */ { "LDIH", SIMPLE },
- /* 0x22 */ { "LDIB", SIMPLE },
- /* 0x23 */ { "LDIM", SIMPLE },
- /* 0x24 */ { "STI ", SIMPLE },
- /* 0x25 */ { "STIH", SIMPLE },
- /* 0x26 */ { "STIB", SIMPLE },
- /* 0x27 */ { "STIM", SIMPLE },
-
- /* Data stack operations */
-
- /* 0x28 */ { "DUP ", SIMPLE },
- /* 0x29 */ { "DUPH ", SIMPLE },
- /* 0x2a */ { "PUSHS", SIMPLE },
- /* 0x2b */ { "POPS", SIMPLE },
- /* 0x2c */ { invOp, SIMPLE },
- /* 0x2d */ { invOp, SIMPLE },
- /* 0x2e */ { invOp, SIMPLE },
- /* 0x2f */ { "RET ", SIMPLE },
-
- /* 0x30 */ { invOp, SIMPLE },
- /* 0x31 */ { invOp, SIMPLE },
- /* 0x32 */ { invOp, SIMPLE },
- /* 0x33 */ { invOp, SIMPLE },
- /* 0x34 */ { invOp, SIMPLE },
- /* 0x35 */ { invOp, SIMPLE },
- /* 0x36 */ { invOp, SIMPLE },
- /* 0x37 */ { invOp, SIMPLE },
-
- /* System Functions (No stack arguments) */
-
- /* 0x38 */ { invOp, SIMPLE },
- /* 0x39 */ { invOp, SIMPLE },
- /* 0x3a */ { invOp, SIMPLE },
- /* 0x3b */ { invOp, SIMPLE },
- /* 0x3c */ { invOp, SIMPLE },
- /* 0x3d */ { invOp, SIMPLE },
- /* 0x3e */ { invOp, SIMPLE },
- /* 0x3f */ { "EXIT ", SIMPLE }
-};
-
-/****************** OPCODES WITH 25-BIT ARGUMENT ************************/
-
-static const struct optab_s g_sArg32OpTable[64] =
-{
- /* Load: arg = unsigned base offset */
-
- /* 0x80 */ { "LD ", UDECIMAL }, /* No stack arguments */
- /* 0x81 */ { "LDH ", UDECIMAL }, /* No stack arguments */
- /* 0x82 */ { "LDB ", UDECIMAL }, /* No stack arguments */
- /* 0x83 */ { "LDM ", UDECIMAL }, /* One 32-bit stack argument */
-
- /* Store: arg = unsigned base offset (One stack arguments) */
-
- /* 0x84 */ { "ST ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x85 */ { "STH ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x86 */ { "STB ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x87 */ { "STM ", UDECIMAL }, /* One+n 32-bit stack argument */
-
- /* Load Indexed: arg = unsigned base offset */
-
- /* 0x88 */ { "LDX ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x89 */ { "LDXH ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x8a */ { "LDXB ", UDECIMAL }, /* One 32-bit stack argument */
- /* 0x8b */ { "LDXM ", UDECIMAL }, /* Two 32-bit stack argument */
-
- /* Store Indexed: arg = unsigned base offset */
-
- /* 0x8c */ { "STX ", UDECIMAL }, /* Two 32-bit stack argument */
- /* 0x8d */ { "STXH ", UDECIMAL }, /* Two 32-bit stack argument */
- /* 0x8e */ { "STXB ", UDECIMAL }, /* Two 32-bit stack argument */
- /* 0x8f */ { "STXM ", UDECIMAL }, /* Two+n 32-bit stack argument */
-
- /* Program control: arg = unsigned label (One stack argument) */
-
- /* 0x90 */ { "JEQUZ", HEX },
- /* 0x91 */ { "JNEQZ", HEX },
- /* 0x92 */ { "JLTZ ", HEX },
- /* 0x93 */ { "JGTEZ", HEX },
- /* 0x94 */ { "JGTZ ", HEX },
- /* 0x95 */ { "JLTEZ", HEX },
-
- /* Program control: arg = unsigned label (no stack arguments) */
-
- /* 0x96 */ { "JMP ", HEX },
- /* 0x97 */ { "PUSH ", DECIMAL },
-
- /* Program control: arg = unsigned label (One stack argument) */
-
- /* 0x98 */ { "JEQU ", HEX },
- /* 0x99 */ { "JNEQ ", HEX },
- /* 0x9a */ { "JLT ", HEX },
- /* 0x9b */ { "JGTE ", HEX },
- /* 0x9c */ { "JGT ", HEX },
- /* 0x9d */ { "JLTE ", HEX },
- /* 0x9e */ { invOp, SIMPLE },
- /* 0x9f */ { "INDS ", DECIMAL },
-
- /* Load: Uses LSP; arg = signed frame offset */
-
- /* 0xa0 */ { "LDS ", DECIMAL }, /* No stack arguments */
- /* 0xa1 */ { "LDSH ", DECIMAL }, /* No stack arguments */
- /* 0xa2 */ { "LDSB ", DECIMAL }, /* No stack arguments */
- /* 0xa3 */ { "LDSM ", DECIMAL }, /* One 32-bit stack argument */
-
- /* Store: Uses LSP; arg = signed frame offset */
-
- /* 0xa4 */ { "STS ", DECIMAL }, /* One 32-bit stack argument */
- /* 0xa5 */ { "STSH ", DECIMAL }, /* One 32-bit stack argument */
- /* 0xa6 */ { "STSB ", DECIMAL }, /* One 32-bit stack argument */
- /* 0xa7 */ { "STSM ", DECIMAL }, /* One+n 32-bit stack argument */
-
- /* Load Indexed: Uses LSP; arg = signed frame offset */
-
- /* 0xa8 */ { "LDSX ", DECIMAL }, /* One 32-bit stack argument */
- /* 0xa9 */ { "LDSXH", DECIMAL }, /* One 32-bit stack argument */
- /* 0xaa */ { "LDSXB", DECIMAL }, /* One 32-bit stack argument */
- /* 0xab */ { "LDSXM", DECIMAL }, /* Two 32-bit stack argument */
-
- /* Store Indexed: Uses LSP; arg = signed frame offset */
-
- /* 0xac */ { "STSX ", DECIMAL }, /* Two 32-bit stack argument */
- /* 0xad */ { "STSXH", DECIMAL }, /* Two 32-bit stack argument */
- /* 0xae */ { "STSXB", DECIMAL }, /* Two 32-bit stack argument */
- /* 0xaf */ { "STSXM", DECIMAL }, /* Two+n 32-bit stack argument */
-
- /* Load address relative to stack base: arg = unsigned offset */
-
- /* 0xb0 */ { "LA ", UDECIMAL },
-
- /* Load address: Uses SLP, arg = signed frame offset */
-
- /* 0xb1 */ { "LAS ", DECIMAL },
-
- /* Load absolute stack address: arg = RODATA offset (No stack arguments) */
-
- /* 0xb2 */ { "LAC ", HEX, },
- /* 0xb3 */ { invOp, SIMPLE },
-
- /* Load address relative to stack base: arg = unsigned offset, TOS=index */
-
- /* 0xb4 */ { "LAX ", UDECIMAL },
-
- /* Load address indexed: Uses SLP, arg = signed frame offset */
-
- /* 0xb5 */ { "LASX ", DECIMAL },
-
- /* Set LSP: arg = new level that evaluates to LSP value */
-
- /* 0xb6 */ { "SLSP ", UDECIMAL },
- /* 0xb7 */ { "SDC ", UDECIMAL },
- /* 0xb8 */ { invOp, SIMPLE },
-
- /* Program Control: Uses LSP; arg = unsigned label (No stack arguments) */
-
- /* 0xb9 */ { "PCAL ", HEX },
-
- /* System calls: arg = file number | sub-function code */
-
- /* 0xba */ { "SYSIO", xOP },
-
- /* System functions: arg = 32-bit library call identifier */
-
- /* 0xbb */ { "LIB ", lbOP },
-
- /* Floating point operations: arg = FP op-code */
-
- /* 0xbc */ { "FLOAT", fpOP },
-
- /* Program control: arg = unsigned label (no stack arguments) */
-
- /* 0xbd */ { NULL, LABEL_DEC },
-
- /* Psuedo-operations: arg = file number OR line number */
-
- /* 0xbe */ { "INCLUDE ", FILENO },
- /* 0xbf */ { "LINE ", LINENO },
-};
-
-static const char invXOp[] = "Invalid SYSIO";
-static const char *xName[MAX_XOP] = { /* SYSIO opcode mnemonics */
-/* 0x00 */ invXOp, "EOF", "EOLN", "RESET",
-/* 0x04 */ "REWRITE", invXOp, invXOp, invXOp,
-/* 0x08 */ invXOp, invXOp, invXOp, invXOp,
-/* 0x0c */ invXOp, invXOp, invXOp, invXOp,
-/* 0x10 */ "READLN", "READPG", "READBIN", "READINT",
-/* 0x14 */ "READCHR", "READSTR", "READRL", invXOp,
-/* 0x18 */ invXOp, invXOp, invXOp, invXOp,
-/* 0x1c */ invXOp, invXOp, invXOp, invXOp,
-/* 0x20 */ "WRITELN", "WRITEPG", "WRITEBIN", "WRITEINT",
-/* 0x24 */ "WRITECHR", "WRITESTR", "WRITERL" };
-
-static const char invLbOp[] = "Invalid runtime code";
-static const char *lbName[MAX_LBOP] = { /* LIB opcode mnemonics */
-/* 0x00 */ "GETENV", "STR2STR", "CSTR2STR", "STR2RSTR",
-/* 0x04 */ "CSTR2RSTR", "VAL", "MKSTK", "MKSTKSTR",
-/* 0x08 */ "MKSTKC", "STRCAT", "STRCATC", "STRCMP" };
-
-#define MAX_FOP 16
-static const char invFpOp[] = "Invalid FP Operation";
-static const char *fpName[MAX_FOP] = {
-/* 0x00 */ invFpOp, "FLOAT", "TRUNC", "ROUND",
-/* 0x04 */ "NEG", "ADD", "SUB", "MUL",
-/* 0x08 */ "DIV", "MOD", "EQU", "NEQ",
-/* 0x0c */ "LT", "GTE", "GT", "LTE" };
-
-/***********************************************************************/
-
-void insn_DisassemblePCode(FILE* lfile, OPTYPE *pop)
-{
- const struct optab_s *opTable;
- int idx;
-
- /* Select table based upon whether an opcode is included or not */
-
- if (pop->op & o32)
- {
- opTable = g_sArg32OpTable;
- idx = pop->op & ~o32;
- }
- else
- {
- opTable = g_sNoArgOpTable;
- idx = pop->op;
- }
-
- /* Indent, comment or label as appropriate */
-
- switch (opTable[idx].format)
- {
- case LABEL_DEC :
- fprintf(lfile, "L%08lx:\n", pop->arg);
- return;
- case FILENO :
- case LINENO :
- fprintf(lfile, "; ");
- break;
- default :
- fprintf(lfile, " ");
- } /* end switch */
-
- /* Print the opcode mnemonic */
-
- fprintf(lfile, "%s ", opTable[idx].opName);
-
- /* Print the argument (if present) */
-
- if (pop->op & o32)
- {
- switch (opTable[idx].format)
- {
- case HEX :
- fprintf(lfile, "0x%08lx", pop->arg);
- break;
-
- case FILENO :
- case LINENO :
- case DECIMAL :
- fprintf(lfile, "%ld", (sint32)pop->arg);
- break;
-
- case UDECIMAL :
- fprintf(lfile, "%1lu", pop->arg);
- break;
-
- case fpOP :
- if ((pop->arg & 0x3f) < MAX_FOP)
- fprintf(lfile, "%s", fpName[(pop->arg & 0x3f)]);
- else
- fprintf(lfile, "%s", invFpOp);
- break;
-
- case xOP :
- {
- unsigned fileno = pop->arg >> 16;
- unsigned xop = pop->arg & 0xffff;
- fprintf(lfile, "%d, ", fileno);
- if (xop < MAX_XOP)
- fprintf(lfile, "%s", xName[xop]);
- else
- fprintf(lfile, "%s", invXOp);
- }
- break;
-
- case lbOP :
- if (pop->arg < MAX_LBOP)
- fprintf(lfile, "%s", lbName[pop->arg]);
- else
- fprintf(lfile, "%s", invLbOp);
- break;
-
- case LABEL_DEC :
- default :
- break;
- }
- }
-
- /* Don't forget the newline! */
-
- fputc('\n', lfile);
-
-} /* end dissassemblePcode */
-
-/***********************************************************************/
+/**********************************************************************
+ * pdasm.c
+ * P-Code Disassembler
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+#include <stdio.h>
+
+#include "keywords.h"
+#include "podefs.h"
+#include "pinsn32.h"
+#include "pfdefs.h"
+#include "pxdefs.h"
+#include "paslib.h"
+
+#include "pinsn.h"
+
+/**********************************************************************
+ * Private Types
+ **********************************************************************/
+
+/* These are all the format codes that apply to opcodes with an argument */
+
+enum {
+ SIMPLE = 0, /* No argument */
+ HEX, /* Hexadecimal argument */
+ DECIMAL, /* Signed Decimal argument (w/shift) */
+ UDECIMAL, /* Unsigned Decimal argument (w/shift) */
+ LABEL_DEC, /* Label number */
+ xOP, lbOP, fpOP, /* Sub opcode */
+ FILENO, LINENO /* File number, line number */
+};
+
+/* The following table defines everything that is needed to disassemble
+ * a P-Code. NOTE: The order of definition in this table must exactly
+ * match the declaration sequence in pinsn.h. */
+
+static const char invOp[] = "Invalid Opcode";
+struct optab_s
+{
+ const char *opName; /* Opcode mnemonics */
+ uint8_t format; /* arg16 format */
+};
+
+/******************** OPCODES WITH NO ARGUMENTS *************************/
+
+static const struct optab_s g_sNoArgOpTable[64] =
+{
+ /* Program control (No stack arguments) */
+
+ /* 0x00 */ { "NOP ", SIMPLE },
+
+ /* Arithmetic & logical & and integer conversions (One stack argument) */
+
+ /* 0x01 */ { "NEG ", SIMPLE },
+ /* 0x02 */ { "ABS ", SIMPLE },
+ /* 0x03 */ { "INC ", SIMPLE },
+ /* 0x04 */ { "DEC ", SIMPLE },
+ /* 0x05 */ { "NOT ", SIMPLE },
+
+ /* Arithmetic & logical (Two stack arguments) */
+
+ /* 0x06 */ { "ADD ", SIMPLE },
+ /* 0x07 */ { "SUB ", SIMPLE },
+ /* 0x08 */ { "MUL ", SIMPLE },
+ /* 0x09 */ { "DIV ", SIMPLE },
+ /* 0x0a */ { "MOD ", SIMPLE },
+ /* 0x0b */ { "SLL ", SIMPLE },
+ /* 0x0c */ { "SRL ", SIMPLE },
+ /* 0x0d */ { "SRA ", SIMPLE },
+ /* 0x0e */ { "OR ", SIMPLE },
+ /* 0x0f */ { "AND ", SIMPLE },
+
+ /* Comparisons (One stack argument) */
+
+ /* 0x10 */ { "EQUZ ", SIMPLE },
+ /* 0x11 */ { "NEQZ ", SIMPLE },
+ /* 0x12 */ { "LTZ ", SIMPLE },
+ /* 0x13 */ { "GTEZ ", SIMPLE },
+ /* 0x14 */ { "GTZ ", SIMPLE },
+ /* 0x15 */ { "LTEZ ", SIMPLE },
+ /* 0x16 */ { invOp, SIMPLE },
+ /* 0x17 */ { invOp, SIMPLE },
+
+ /* Comparisons (Two stack arguments) */
+
+ /* 0x18 */ { "EQU ", SIMPLE },
+ /* 0x19 */ { "NEQ ", SIMPLE },
+ /* 0x1a */ { "LT ", SIMPLE },
+ /* 0x1b */ { "GTE ", SIMPLE },
+ /* 0x1c */ { "GT ", SIMPLE },
+ /* 0x1d */ { "LTE ", SIMPLE },
+ /* 0x1e */ { invOp, SIMPLE },
+ /* 0x1f */ { "BIT ", SIMPLE },
+
+ /* Load (One) or Store (Two stack argument) */
+
+ /* 0x20 */ { "LDI ", SIMPLE },
+ /* 0x21 */ { "LDIH", SIMPLE },
+ /* 0x22 */ { "LDIB", SIMPLE },
+ /* 0x23 */ { "LDIM", SIMPLE },
+ /* 0x24 */ { "STI ", SIMPLE },
+ /* 0x25 */ { "STIH", SIMPLE },
+ /* 0x26 */ { "STIB", SIMPLE },
+ /* 0x27 */ { "STIM", SIMPLE },
+
+ /* Data stack operations */
+
+ /* 0x28 */ { "DUP ", SIMPLE },
+ /* 0x29 */ { "DUPH ", SIMPLE },
+ /* 0x2a */ { "PUSHS", SIMPLE },
+ /* 0x2b */ { "POPS", SIMPLE },
+ /* 0x2c */ { invOp, SIMPLE },
+ /* 0x2d */ { invOp, SIMPLE },
+ /* 0x2e */ { invOp, SIMPLE },
+ /* 0x2f */ { "RET ", SIMPLE },
+
+ /* 0x30 */ { invOp, SIMPLE },
+ /* 0x31 */ { invOp, SIMPLE },
+ /* 0x32 */ { invOp, SIMPLE },
+ /* 0x33 */ { invOp, SIMPLE },
+ /* 0x34 */ { invOp, SIMPLE },
+ /* 0x35 */ { invOp, SIMPLE },
+ /* 0x36 */ { invOp, SIMPLE },
+ /* 0x37 */ { invOp, SIMPLE },
+
+ /* System Functions (No stack arguments) */
+
+ /* 0x38 */ { invOp, SIMPLE },
+ /* 0x39 */ { invOp, SIMPLE },
+ /* 0x3a */ { invOp, SIMPLE },
+ /* 0x3b */ { invOp, SIMPLE },
+ /* 0x3c */ { invOp, SIMPLE },
+ /* 0x3d */ { invOp, SIMPLE },
+ /* 0x3e */ { invOp, SIMPLE },
+ /* 0x3f */ { "EXIT ", SIMPLE }
+};
+
+/****************** OPCODES WITH 25-BIT ARGUMENT ************************/
+
+static const struct optab_s g_sArg32OpTable[64] =
+{
+ /* Load: arg = unsigned base offset */
+
+ /* 0x80 */ { "LD ", UDECIMAL }, /* No stack arguments */
+ /* 0x81 */ { "LDH ", UDECIMAL }, /* No stack arguments */
+ /* 0x82 */ { "LDB ", UDECIMAL }, /* No stack arguments */
+ /* 0x83 */ { "LDM ", UDECIMAL }, /* One 32-bit stack argument */
+
+ /* Store: arg = unsigned base offset (One stack arguments) */
+
+ /* 0x84 */ { "ST ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x85 */ { "STH ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x86 */ { "STB ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x87 */ { "STM ", UDECIMAL }, /* One+n 32-bit stack argument */
+
+ /* Load Indexed: arg = unsigned base offset */
+
+ /* 0x88 */ { "LDX ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x89 */ { "LDXH ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x8a */ { "LDXB ", UDECIMAL }, /* One 32-bit stack argument */
+ /* 0x8b */ { "LDXM ", UDECIMAL }, /* Two 32-bit stack argument */
+
+ /* Store Indexed: arg = unsigned base offset */
+
+ /* 0x8c */ { "STX ", UDECIMAL }, /* Two 32-bit stack argument */
+ /* 0x8d */ { "STXH ", UDECIMAL }, /* Two 32-bit stack argument */
+ /* 0x8e */ { "STXB ", UDECIMAL }, /* Two 32-bit stack argument */
+ /* 0x8f */ { "STXM ", UDECIMAL }, /* Two+n 32-bit stack argument */
+
+ /* Program control: arg = unsigned label (One stack argument) */
+
+ /* 0x90 */ { "JEQUZ", HEX },
+ /* 0x91 */ { "JNEQZ", HEX },
+ /* 0x92 */ { "JLTZ ", HEX },
+ /* 0x93 */ { "JGTEZ", HEX },
+ /* 0x94 */ { "JGTZ ", HEX },
+ /* 0x95 */ { "JLTEZ", HEX },
+
+ /* Program control: arg = unsigned label (no stack arguments) */
+
+ /* 0x96 */ { "JMP ", HEX },
+ /* 0x97 */ { "PUSH ", DECIMAL },
+
+ /* Program control: arg = unsigned label (One stack argument) */
+
+ /* 0x98 */ { "JEQU ", HEX },
+ /* 0x99 */ { "JNEQ ", HEX },
+ /* 0x9a */ { "JLT ", HEX },
+ /* 0x9b */ { "JGTE ", HEX },
+ /* 0x9c */ { "JGT ", HEX },
+ /* 0x9d */ { "JLTE ", HEX },
+ /* 0x9e */ { invOp, SIMPLE },
+ /* 0x9f */ { "INDS ", DECIMAL },
+
+ /* Load: Uses LSP; arg = signed frame offset */
+
+ /* 0xa0 */ { "LDS ", DECIMAL }, /* No stack arguments */
+ /* 0xa1 */ { "LDSH ", DECIMAL }, /* No stack arguments */
+ /* 0xa2 */ { "LDSB ", DECIMAL }, /* No stack arguments */
+ /* 0xa3 */ { "LDSM ", DECIMAL }, /* One 32-bit stack argument */
+
+ /* Store: Uses LSP; arg = signed frame offset */
+
+ /* 0xa4 */ { "STS ", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xa5 */ { "STSH ", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xa6 */ { "STSB ", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xa7 */ { "STSM ", DECIMAL }, /* One+n 32-bit stack argument */
+
+ /* Load Indexed: Uses LSP; arg = signed frame offset */
+
+ /* 0xa8 */ { "LDSX ", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xa9 */ { "LDSXH", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xaa */ { "LDSXB", DECIMAL }, /* One 32-bit stack argument */
+ /* 0xab */ { "LDSXM", DECIMAL }, /* Two 32-bit stack argument */
+
+ /* Store Indexed: Uses LSP; arg = signed frame offset */
+
+ /* 0xac */ { "STSX ", DECIMAL }, /* Two 32-bit stack argument */
+ /* 0xad */ { "STSXH", DECIMAL }, /* Two 32-bit stack argument */
+ /* 0xae */ { "STSXB", DECIMAL }, /* Two 32-bit stack argument */
+ /* 0xaf */ { "STSXM", DECIMAL }, /* Two+n 32-bit stack argument */
+
+ /* Load address relative to stack base: arg = unsigned offset */
+
+ /* 0xb0 */ { "LA ", UDECIMAL },
+
+ /* Load address: Uses SLP, arg = signed frame offset */
+
+ /* 0xb1 */ { "LAS ", DECIMAL },
+
+ /* Load absolute stack address: arg = RODATA offset (No stack arguments) */
+
+ /* 0xb2 */ { "LAC ", HEX, },
+ /* 0xb3 */ { invOp, SIMPLE },
+
+ /* Load address relative to stack base: arg = unsigned offset, TOS=index */
+
+ /* 0xb4 */ { "LAX ", UDECIMAL },
+
+ /* Load address indexed: Uses SLP, arg = signed frame offset */
+
+ /* 0xb5 */ { "LASX ", DECIMAL },
+
+ /* Set LSP: arg = new level that evaluates to LSP value */
+
+ /* 0xb6 */ { "SLSP ", UDECIMAL },
+ /* 0xb7 */ { "SDC ", UDECIMAL },
+ /* 0xb8 */ { invOp, SIMPLE },
+
+ /* Program Control: Uses LSP; arg = unsigned label (No stack arguments) */
+
+ /* 0xb9 */ { "PCAL ", HEX },
+
+ /* System calls: arg = file number | sub-function code */
+
+ /* 0xba */ { "SYSIO", xOP },
+
+ /* System functions: arg = 32-bit library call identifier */
+
+ /* 0xbb */ { "LIB ", lbOP },
+
+ /* Floating point operations: arg = FP op-code */
+
+ /* 0xbc */ { "FLOAT", fpOP },
+
+ /* Program control: arg = unsigned label (no stack arguments) */
+
+ /* 0xbd */ { NULL, LABEL_DEC },
+
+ /* Psuedo-operations: arg = file number OR line number */
+
+ /* 0xbe */ { "INCLUDE ", FILENO },
+ /* 0xbf */ { "LINE ", LINENO },
+};
+
+static const char invXOp[] = "Invalid SYSIO";
+static const char *xName[MAX_XOP] = { /* SYSIO opcode mnemonics */
+/* 0x00 */ invXOp, "EOF", "EOLN", "RESET",
+/* 0x04 */ "REWRITE", invXOp, invXOp, invXOp,
+/* 0x08 */ invXOp, invXOp, invXOp, invXOp,
+/* 0x0c */ invXOp, invXOp, invXOp, invXOp,
+/* 0x10 */ "READLN", "READPG", "READBIN", "READINT",
+/* 0x14 */ "READCHR", "READSTR", "READRL", invXOp,
+/* 0x18 */ invXOp, invXOp, invXOp, invXOp,
+/* 0x1c */ invXOp, invXOp, invXOp, invXOp,
+/* 0x20 */ "WRITELN", "WRITEPG", "WRITEBIN", "WRITEINT",
+/* 0x24 */ "WRITECHR", "WRITESTR", "WRITERL" };
+
+static const char invLbOp[] = "Invalid runtime code";
+static const char *lbName[MAX_LBOP] = { /* LIB opcode mnemonics */
+/* 0x00 */ "GETENV", "STR2STR", "CSTR2STR", "STR2RSTR",
+/* 0x04 */ "CSTR2RSTR", "VAL", "MKSTK", "MKSTKSTR",
+/* 0x08 */ "MKSTKC", "STRCAT", "STRCATC", "STRCMP" };
+
+#define MAX_FOP 16
+static const char invFpOp[] = "Invalid FP Operation";
+static const char *fpName[MAX_FOP] = {
+/* 0x00 */ invFpOp, "FLOAT", "TRUNC", "ROUND",
+/* 0x04 */ "NEG", "ADD", "SUB", "MUL",
+/* 0x08 */ "DIV", "MOD", "EQU", "NEQ",
+/* 0x0c */ "LT", "GTE", "GT", "LTE" };
+
+/***********************************************************************/
+
+void insn_DisassemblePCode(FILE* lfile, OPTYPE *pop)
+{
+ const struct optab_s *opTable;
+ int idx;
+
+ /* Select table based upon whether an opcode is included or not */
+
+ if (pop->op & o32)
+ {
+ opTable = g_sArg32OpTable;
+ idx = pop->op & ~o32;
+ }
+ else
+ {
+ opTable = g_sNoArgOpTable;
+ idx = pop->op;
+ }
+
+ /* Indent, comment or label as appropriate */
+
+ switch (opTable[idx].format)
+ {
+ case LABEL_DEC :
+ fprintf(lfile, "L%08lx:\n", pop->arg);
+ return;
+ case FILENO :
+ case LINENO :
+ fprintf(lfile, "; ");
+ break;
+ default :
+ fprintf(lfile, " ");
+ } /* end switch */
+
+ /* Print the opcode mnemonic */
+
+ fprintf(lfile, "%s ", opTable[idx].opName);
+
+ /* Print the argument (if present) */
+
+ if (pop->op & o32)
+ {
+ switch (opTable[idx].format)
+ {
+ case HEX :
+ fprintf(lfile, "0x%08lx", pop->arg);
+ break;
+
+ case FILENO :
+ case LINENO :
+ case DECIMAL :
+ fprintf(lfile, "%ld", (int32_t)pop->arg);
+ break;
+
+ case UDECIMAL :
+ fprintf(lfile, "%1lu", pop->arg);
+ break;
+
+ case fpOP :
+ if ((pop->arg & 0x3f) < MAX_FOP)
+ fprintf(lfile, "%s", fpName[(pop->arg & 0x3f)]);
+ else
+ fprintf(lfile, "%s", invFpOp);
+ break;
+
+ case xOP :
+ {
+ unsigned fileno = pop->arg >> 16;
+ unsigned xop = pop->arg & 0xffff;
+ fprintf(lfile, "%d, ", fileno);
+ if (xop < MAX_XOP)
+ fprintf(lfile, "%s", xName[xop]);
+ else
+ fprintf(lfile, "%s", invXOp);
+ }
+ break;
+
+ case lbOP :
+ if (pop->arg < MAX_LBOP)
+ fprintf(lfile, "%s", lbName[pop->arg]);
+ else
+ fprintf(lfile, "%s", invLbOp);
+ break;
+
+ case LABEL_DEC :
+ default :
+ break;
+ }
+ }
+
+ /* Don't forget the newline! */
+
+ fputc('\n', lfile);
+
+} /* end dissassemblePcode */
+
+/***********************************************************************/
diff --git a/misc/pascal/insn32/libinsn/pgen.c b/misc/pascal/insn32/libinsn/pgen.c
index d6584147d..a3219d388 100644
--- a/misc/pascal/insn32/libinsn/pgen.c
+++ b/misc/pascal/insn32/libinsn/pgen.c
@@ -1,382 +1,383 @@
-/**********************************************************************
- * pgen.c
- * P-Code generation logic
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-#include "config.h" /* Configuration */
-#include "keywords.h" /* Standard types */
-#include "pdefs.h" /* Common types */
-#include "pofflib.h" /* POFF library definitions */
-#include "podefs.h" /* Logical opcode definitions */
-#include "pedefs.h" /* Error codes */
-#include "pinsn32.h" /* 32-bit target INSN opcode definitions */
-#include "perr.h" /* Error handling logic */
-
-#include "pinsn.h" /* (to verify prototypes in this file) */
-
-/**********************************************************************
- * Definitions
- **********************************************************************/
-
-#define INVALID_INCLUDE (-1)
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-extern poffHandle_t poffHandle; /* Handle to POFF object */
-extern FILE *lstFile; /* LIST file pointer */
-extern sint16 level; /* Static nesting level */
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-static const ubyte opmap[NUM_OPCODES] =
-{
- oNOP, /* opNOP */
- oNEG, /* opNEG */
- oABS, /* opABS */
- oINC, /* opINC */
- oDEC, /* opDEC */
- oNOT, /* opNOT */
- oADD, /* opADD */
- oSUB, /* opSUB */
- oMUL, /* opMUL */
- oDIV, /* opDIV */
- oMOD, /* opMOD */
- oSLL, /* opSLL */
- oSRL, /* opSRL */
- oSRA, /* opSRA */
- oOR, /* opOR */
- oAND, /* opAND */
- oEQUZ, /* opEQUZ */
- oNEQZ, /* opNEQZ */
- oLTZ, /* opLTZ */
- oGTEZ, /* opGTEZ */
- oGTZ, /* opGTZ */
- oLTEZ, /* opLTEZ */
- oEQU, /* opEQU */
- oNEQ, /* opNEQ */
- oLT, /* opLT */
- oGTE, /* opGTE */
- oGT, /* opGT */
- oLTE, /* opLTE */
- oBIT, /* opBIT */
- oLDI, /* opLDI */
- oLDIB, /* opLDIB */
- oLDIM, /* opLDIM */
- oSTI, /* opSTI */
- oSTIB, /* opSTIB */
- oSTIM, /* opSTIM */
- oDUP, /* opDUP */
- oPUSHS, /* opPUSHS */
- oPOPS, /* opPOPS */
- oRET, /* opRET */
- oEND, /* opEND */
- oFLOAT, /* opFLOAT */
- oJEQUZ, /* opJEQUZ */
- oJNEQZ, /* opJNEQZ */
- oJMP, /* opJMP */
- oJEQU, /* opJEQU */
- oJNEQ, /* opJNEQ */
- oJLT, /* opJLT */
- oJGTE, /* opJGTE */
- oJGT, /* opJGT */
- oJLTE, /* opJLTE */
- oLD, /* opLD */
- oLDH, /* opLDH */
- oLDB, /* opLDB */
- oLDM, /* opLDM */
- oST, /* opST */
- oSTB, /* opSTB */
- oSTM, /* opSTM */
- oLDX, /* opLDX */
- oLDXB, /* opLDXB */
- oLDXM, /* opLDXM */
- oSTX, /* opSTX */
- oSTXB, /* opSTXB */
- oSTXM, /* opSTXM */
- oLA, /* opLA */
- oLAC, /* opLAC */
- oPUSH, /* opPUSH */
- oINDS, /* opINDS */
- oLAX, /* opLAX */
- oLIB, /* opLIB */
- oLABEL, /* opLABEL */
- oPCAL, /* opPCAL */
- oLDS, /* opLDS */
- oLDSH, /* opLDSH */
- oLDSB, /* opLDSB */
- oLDSM, /* opLDSM */
- oSTS, /* opSTS */
- oSTSB, /* opSTSB */
- oSTSM, /* opSTSM */
- oLDSX, /* opLDSX */
- oLDSXB, /* opLDSXB */
- oLDSXM, /* opLDSXM */
- oSTSX, /* opSTSX */
- oSTSXB, /* opSTSXB */
- oSTSXM, /* opSTSXM */
- oLAS, /* opLAS */
- oLASX, /* opLASX */
- oSYSIO, /* opSYSIO */
- oLINE, /* opLINE */
-};
-
-static uint16 g_nCurrentIncludeNumber = INVALID_INCLUDE;
-
-/***********************************************************************
- * Private Function Prototypes
- ***********************************************************************/
-
-/***********************************************************************
- * Private Functions
- ***********************************************************************/
-
-static void
-insn32_GenerateSimple(ubyte opcode);
-static void
-insn32_GenerateDataOperation(ubyte opcode, uint32 data);
-static void
-insn32_Generate(enum pcode_e opcode, uint32 arg);
-
-/***********************************************************************
- * Private Functions
- ***********************************************************************/
-
-/***********************************************************************/
-/* Disassemble an Op-code */
-
-#if CONFIG_DEBUG
-static inline void
-insn32_DisassemblePCode(ubyte opcode, uint32 arg)
-{
- OPTYPE op;
-
- op.op = opcode;
- op.arg = arg;
-
- insn_DisassemblePCode(lstFile, &op);
-}
-#else
-# define insn32_DisassemblePCode(op,a)
-#endif
-
-/***********************************************************************/
-static inline void
-insn32_DisassembleOpcode(ubyte opcode, uint32 data)
-{
-#if CONFIG_DEBUG
- OPTYPE op;
- op.op = opcode;
- op.arg = data;
- insn32_DisassemblePCode(opcode, 0);
-#endif
-}
-
-/***********************************************************************/
-/* Generate an Op-Code */
-
-static void
-insn32_GenerateSimple(ubyte opcode)
-{
- TRACE(lstFile,"[insn32_GenerateSimple:0x%02x]", opcode);
-
- /* Write the 8-bit opcode */
-
- poffAddProgByte(poffHandle, opcode);
-
- /* Now, add the disassembled PCode to the list file. */
-
- insn32_DisassembleOpcode(opcode, 0);
-}
-
-/***********************************************************************/
-
-static void
-insn32_GenerateDataOperation(ubyte opcode, uint32 data)
-{
- union
- {
- ubyte b[4];
- uint32 w;
- } udata;
-
- TRACE(lstFile,"[insn32_GenerateDataOperation:0x%02x:0x%07x]", opcode, data);
-
- /* Write the 8-bit opcode */
-
- poffAddProgByte(poffHandle, opcode);
-
- /* Write the 32-bit opcode */
-
- udata.w = data;
- (void)poffAddProgByte(poffHandle, udata.b[opB1]);
- (void)poffAddProgByte(poffHandle, udata.b[opB2]);
- (void)poffAddProgByte(poffHandle, udata.b[opB3]);
- (void)poffAddProgByte(poffHandle, udata.b[opB4]);
-
- /* Now, add the disassembled PCode to the list file. */
-
- insn32_DisassembleOpcode(opcode, data);
-}
-
-/***********************************************************************/
-
-static void
-insn32_Generate(enum pcode_e opcode, uint32 arg)
-{
- ubyte insn_opcode = opmap[opcode];
-
- TRACE(lstFile,"[insn32_Generate:0x%02x->0x%02x]", opcode, insn_opcode);
-
- if (insn_opcode & o32)
- {
- insn32_GenerateDataOperation(insn_opcode, arg);
- }
- else
- {
- insn32_GenerateSimple(insn_opcode);
-
- /* We ignore the argument... what if one was provided? */
-
- if (arg != 0)
- {
- warn(eARGIGNORED);
- }
- }
-}
-
-/***********************************************************************
- * Public Functions
- ***********************************************************************/
-
-void
-insn_GenerateSimple(enum pcode_e opcode)
-{
- insn32_Generate(opcode, 0);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateDataOperation(enum pcode_e opcode, sint32 data)
-{
- insn32_Generate(opcode, (uint32)data);
-}
-
-/***********************************************************************/
-/* Data size for the next multiple register operation (in bytes) is
- * retained in the DC register.
- */
-
-void insn_GenerateDataSize(uint32 dwDataSize)
-{
- insn32_GenerateDataOperation(oSDC, dwDataSize);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateFpOperation(ubyte fpOpcode)
-{
- insn32_GenerateDataOperation(oFLOAT, fpOpcode);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateIoOperation(uint16 ioOpcode, uint16 fileNumber)
-{
- uint32 arg = (uint32)fileNumber << 16 | (uint32)ioOpcode;
- insn32_GenerateDataOperation(oSYSIO, arg);
-}
-
-/***********************************************************************/
-
-void
-insn_BuiltInFunctionCall(uint16 libOpcode)
-{
- insn32_GenerateDataOperation(oLIB, (uint32)libOpcode);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateLevelReference(enum pcode_e opcode, uint16 level, sint32 offset)
-{
- /* Note that level is ignored. We used the level set by the
- * preceding call to insn_SetStackLevel().
- */
-
- insn32_Generate(opcode, (uint32)offset);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateProcedureCall(uint16 level, sint32 offset)
-{
- insn32_GenerateDataOperation(oPCAL, (uint32)offset);
-}
-
-/***********************************************************************/
-
-void
-insn_GenerateLineNumber(uint16 includeNumber, uint32 lineNumber)
-{
- if (includeNumber != g_nCurrentIncludeNumber)
- {
- g_nCurrentIncludeNumber = includeNumber;
- insn32_GenerateDataOperation(oINCLUDE, includeNumber);
- }
- insn32_GenerateDataOperation(oLINE, lineNumber);
-}
-
-/***********************************************************************/
-
-void
-insn_SetStackLevel(uint32 level)
-{
- insn32_GenerateDataOperation(oSLSP, level);
-}
+/**********************************************************************
+ * pgen.c
+ * P-Code generation logic
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include "config.h" /* Configuration */
+#include "keywords.h" /* Standard types */
+#include "pdefs.h" /* Common types */
+#include "pofflib.h" /* POFF library definitions */
+#include "podefs.h" /* Logical opcode definitions */
+#include "pedefs.h" /* Error codes */
+#include "pinsn32.h" /* 32-bit target INSN opcode definitions */
+#include "perr.h" /* Error handling logic */
+
+#include "pinsn.h" /* (to verify prototypes in this file) */
+
+/**********************************************************************
+ * Definitions
+ **********************************************************************/
+
+#define INVALID_INCLUDE (-1)
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+extern poffHandle_t poffHandle; /* Handle to POFF object */
+extern FILE *lstFile; /* LIST file pointer */
+extern int16_t level; /* Static nesting level */
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+static const uint8_t opmap[NUM_OPCODES] =
+{
+ oNOP, /* opNOP */
+ oNEG, /* opNEG */
+ oABS, /* opABS */
+ oINC, /* opINC */
+ oDEC, /* opDEC */
+ oNOT, /* opNOT */
+ oADD, /* opADD */
+ oSUB, /* opSUB */
+ oMUL, /* opMUL */
+ oDIV, /* opDIV */
+ oMOD, /* opMOD */
+ oSLL, /* opSLL */
+ oSRL, /* opSRL */
+ oSRA, /* opSRA */
+ oOR, /* opOR */
+ oAND, /* opAND */
+ oEQUZ, /* opEQUZ */
+ oNEQZ, /* opNEQZ */
+ oLTZ, /* opLTZ */
+ oGTEZ, /* opGTEZ */
+ oGTZ, /* opGTZ */
+ oLTEZ, /* opLTEZ */
+ oEQU, /* opEQU */
+ oNEQ, /* opNEQ */
+ oLT, /* opLT */
+ oGTE, /* opGTE */
+ oGT, /* opGT */
+ oLTE, /* opLTE */
+ oBIT, /* opBIT */
+ oLDI, /* opLDI */
+ oLDIB, /* opLDIB */
+ oLDIM, /* opLDIM */
+ oSTI, /* opSTI */
+ oSTIB, /* opSTIB */
+ oSTIM, /* opSTIM */
+ oDUP, /* opDUP */
+ oPUSHS, /* opPUSHS */
+ oPOPS, /* opPOPS */
+ oRET, /* opRET */
+ oEND, /* opEND */
+ oFLOAT, /* opFLOAT */
+ oJEQUZ, /* opJEQUZ */
+ oJNEQZ, /* opJNEQZ */
+ oJMP, /* opJMP */
+ oJEQU, /* opJEQU */
+ oJNEQ, /* opJNEQ */
+ oJLT, /* opJLT */
+ oJGTE, /* opJGTE */
+ oJGT, /* opJGT */
+ oJLTE, /* opJLTE */
+ oLD, /* opLD */
+ oLDH, /* opLDH */
+ oLDB, /* opLDB */
+ oLDM, /* opLDM */
+ oST, /* opST */
+ oSTB, /* opSTB */
+ oSTM, /* opSTM */
+ oLDX, /* opLDX */
+ oLDXB, /* opLDXB */
+ oLDXM, /* opLDXM */
+ oSTX, /* opSTX */
+ oSTXB, /* opSTXB */
+ oSTXM, /* opSTXM */
+ oLA, /* opLA */
+ oLAC, /* opLAC */
+ oPUSH, /* opPUSH */
+ oINDS, /* opINDS */
+ oLAX, /* opLAX */
+ oLIB, /* opLIB */
+ oLABEL, /* opLABEL */
+ oPCAL, /* opPCAL */
+ oLDS, /* opLDS */
+ oLDSH, /* opLDSH */
+ oLDSB, /* opLDSB */
+ oLDSM, /* opLDSM */
+ oSTS, /* opSTS */
+ oSTSB, /* opSTSB */
+ oSTSM, /* opSTSM */
+ oLDSX, /* opLDSX */
+ oLDSXB, /* opLDSXB */
+ oLDSXM, /* opLDSXM */
+ oSTSX, /* opSTSX */
+ oSTSXB, /* opSTSXB */
+ oSTSXM, /* opSTSXM */
+ oLAS, /* opLAS */
+ oLASX, /* opLASX */
+ oSYSIO, /* opSYSIO */
+ oLINE, /* opLINE */
+};
+
+static uint16_t g_nCurrentIncludeNumber = INVALID_INCLUDE;
+
+/***********************************************************************
+ * Private Function Prototypes
+ ***********************************************************************/
+
+/***********************************************************************
+ * Private Functions
+ ***********************************************************************/
+
+static void
+insn32_GenerateSimple(uint8_t opcode);
+static void
+insn32_GenerateDataOperation(uint8_t opcode, uint32_t data);
+static void
+insn32_Generate(enum pcode_e opcode, uint32_t arg);
+
+/***********************************************************************
+ * Private Functions
+ ***********************************************************************/
+
+/***********************************************************************/
+/* Disassemble an Op-code */
+
+#if CONFIG_DEBUG
+static inline void
+insn32_DisassemblePCode(uint8_t opcode, uint32_t arg)
+{
+ OPTYPE op;
+
+ op.op = opcode;
+ op.arg = arg;
+
+ insn_DisassemblePCode(lstFile, &op);
+}
+#else
+# define insn32_DisassemblePCode(op,a)
+#endif
+
+/***********************************************************************/
+static inline void
+insn32_DisassembleOpcode(uint8_t opcode, uint32_t data)
+{
+#if CONFIG_DEBUG
+ OPTYPE op;
+ op.op = opcode;
+ op.arg = data;
+ insn32_DisassemblePCode(opcode, 0);
+#endif
+}
+
+/***********************************************************************/
+/* Generate an Op-Code */
+
+static void
+insn32_GenerateSimple(uint8_t opcode)
+{
+ TRACE(lstFile,"[insn32_GenerateSimple:0x%02x]", opcode);
+
+ /* Write the 8-bit opcode */
+
+ poffAddProgByte(poffHandle, opcode);
+
+ /* Now, add the disassembled PCode to the list file. */
+
+ insn32_DisassembleOpcode(opcode, 0);
+}
+
+/***********************************************************************/
+
+static void
+insn32_GenerateDataOperation(uint8_t opcode, uint32_t data)
+{
+ union
+ {
+ uint8_t b[4];
+ uint32_t w;
+ } udata;
+
+ TRACE(lstFile,"[insn32_GenerateDataOperation:0x%02x:0x%07x]", opcode, data);
+
+ /* Write the 8-bit opcode */
+
+ poffAddProgByte(poffHandle, opcode);
+
+ /* Write the 32-bit opcode */
+
+ udata.w = data;
+ (void)poffAddProgByte(poffHandle, udata.b[opB1]);
+ (void)poffAddProgByte(poffHandle, udata.b[opB2]);
+ (void)poffAddProgByte(poffHandle, udata.b[opB3]);
+ (void)poffAddProgByte(poffHandle, udata.b[opB4]);
+
+ /* Now, add the disassembled PCode to the list file. */
+
+ insn32_DisassembleOpcode(opcode, data);
+}
+
+/***********************************************************************/
+
+static void
+insn32_Generate(enum pcode_e opcode, uint32_t arg)
+{
+ uint8_t insn_opcode = opmap[opcode];
+
+ TRACE(lstFile,"[insn32_Generate:0x%02x->0x%02x]", opcode, insn_opcode);
+
+ if (insn_opcode & o32)
+ {
+ insn32_GenerateDataOperation(insn_opcode, arg);
+ }
+ else
+ {
+ insn32_GenerateSimple(insn_opcode);
+
+ /* We ignore the argument... what if one was provided? */
+
+ if (arg != 0)
+ {
+ warn(eARGIGNORED);
+ }
+ }
+}
+
+/***********************************************************************
+ * Public Functions
+ ***********************************************************************/
+
+void
+insn_GenerateSimple(enum pcode_e opcode)
+{
+ insn32_Generate(opcode, 0);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateDataOperation(enum pcode_e opcode, int32_t data)
+{
+ insn32_Generate(opcode, (uint32_t)data);
+}
+
+/***********************************************************************/
+/* Data size for the next multiple register operation (in bytes) is
+ * retained in the DC register.
+ */
+
+void insn_GenerateDataSize(uint32_t dwDataSize)
+{
+ insn32_GenerateDataOperation(oSDC, dwDataSize);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateFpOperation(uint8_t fpOpcode)
+{
+ insn32_GenerateDataOperation(oFLOAT, fpOpcode);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateIoOperation(uint16_t ioOpcode, uint16_t fileNumber)
+{
+ uint32_t arg = (uint32_t)fileNumber << 16 | (uint32_t)ioOpcode;
+ insn32_GenerateDataOperation(oSYSIO, arg);
+}
+
+/***********************************************************************/
+
+void
+insn_BuiltInFunctionCall(uint16_t libOpcode)
+{
+ insn32_GenerateDataOperation(oLIB, (uint32_t)libOpcode);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateLevelReference(enum pcode_e opcode, uint16_t level, int32_t offset)
+{
+ /* Note that level is ignored. We used the level set by the
+ * preceding call to insn_SetStackLevel().
+ */
+
+ insn32_Generate(opcode, (uint32_t)offset);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateProcedureCall(uint16_t level, int32_t offset)
+{
+ insn32_GenerateDataOperation(oPCAL, (uint32_t)offset);
+}
+
+/***********************************************************************/
+
+void
+insn_GenerateLineNumber(uint16_t includeNumber, uint32_t lineNumber)
+{
+ if (includeNumber != g_nCurrentIncludeNumber)
+ {
+ g_nCurrentIncludeNumber = includeNumber;
+ insn32_GenerateDataOperation(oINCLUDE, includeNumber);
+ }
+ insn32_GenerateDataOperation(oLINE, lineNumber);
+}
+
+/***********************************************************************/
+
+void
+insn_SetStackLevel(uint32_t level)
+{
+ insn32_GenerateDataOperation(oSLSP, level);
+}
diff --git a/misc/pascal/insn32/libinsn/pgetopcode.c b/misc/pascal/insn32/libinsn/pgetopcode.c
index 7ccabb5a1..bbcc011e9 100644
--- a/misc/pascal/insn32/libinsn/pgetopcode.c
+++ b/misc/pascal/insn32/libinsn/pgetopcode.c
@@ -1,126 +1,128 @@
-/**********************************************************************
- * pgetopcode.c
- * P-Code access utilities
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include "keywords.h"
-#include "podefs.h"
-#include "pinsn32.h"
-
-#include "paslib.h"
-#include "pofflib.h"
-#include "pinsn.h"
-
-/**********************************************************************
- * Private Function Prototypes
- **********************************************************************/
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-static sint16 g_bEndIn = 0; /* 1 = oEND pcode or EOF received */
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Functions
- **********************************************************************/
-
-/**********************************************************************
- * Global Functions
- **********************************************************************/
-
-/**********************************************************************/
-
-uint32 insn_GetOpCode(poffHandle_t handle, OPTYPE *ptr)
-{
- uint32 opsize = 1;
- int c;
-
- TRACE(stderr, "[insn_GetOpCode]");
-
- /* If we are not already at the EOF, read the next character from
- * the input stream.
- */
-
- if (!g_bEndIn)
- c = poffGetProgByte(handle);
- else
- c = EOF;
-
- /* Check for end of file. We may have previously parsed oEND which
- * is a 'logical' end of file for a pascal program (but not a unit)
- * or we may be at the physical end of the file wihout encountering
- * oEND (typical for a UNIT file).
- */
-
- if ((g_bEndIn) || (c == EOF))
- {
- ptr->op = oEND;
- }
- else
- {
- ptr->op = c;
- g_bEndIn = (c == oEND);
-
- if (c & o32)
- {
- ubyte *pb = (ubyte*)&ptr->arg;
- pb[opB1] = poffGetProgByte(handle);
- pb[opB2] = poffGetProgByte(handle);
- pb[opB3] = poffGetProgByte(handle);
- pb[opB4] = poffGetProgByte(handle);
- opsize += 4;
- }
- }
-
- return opsize;
-}
-
-/**********************************************************************/
-
-void insn_ResetOpCodeRead(poffHandle_t handle)
-{
- poffResetAccess(handle);
- g_bEndIn = 0;
-}
-
-/***********************************************************************/
+/**********************************************************************
+ * pgetopcode.c
+ * P-Code access utilities
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+
+#include "keywords.h"
+#include "podefs.h"
+#include "pinsn32.h"
+
+#include "paslib.h"
+#include "pofflib.h"
+#include "pinsn.h"
+
+/**********************************************************************
+ * Private Function Prototypes
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+static int16_t g_bEndIn = 0; /* 1 = oEND pcode or EOF received */
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Functions
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Functions
+ **********************************************************************/
+
+/**********************************************************************/
+
+uint32_t insn_GetOpCode(poffHandle_t handle, OPTYPE *ptr)
+{
+ uint32_t opsize = 1;
+ int c;
+
+ TRACE(stderr, "[insn_GetOpCode]");
+
+ /* If we are not already at the EOF, read the next character from
+ * the input stream.
+ */
+
+ if (!g_bEndIn)
+ c = poffGetProgByte(handle);
+ else
+ c = EOF;
+
+ /* Check for end of file. We may have previously parsed oEND which
+ * is a 'logical' end of file for a pascal program (but not a unit)
+ * or we may be at the physical end of the file wihout encountering
+ * oEND (typical for a UNIT file).
+ */
+
+ if ((g_bEndIn) || (c == EOF))
+ {
+ ptr->op = oEND;
+ }
+ else
+ {
+ ptr->op = c;
+ g_bEndIn = (c == oEND);
+
+ if (c & o32)
+ {
+ uint8_t *pb = (uint8_t*)&ptr->arg;
+ pb[opB1] = poffGetProgByte(handle);
+ pb[opB2] = poffGetProgByte(handle);
+ pb[opB3] = poffGetProgByte(handle);
+ pb[opB4] = poffGetProgByte(handle);
+ opsize += 4;
+ }
+ }
+
+ return opsize;
+}
+
+/**********************************************************************/
+
+void insn_ResetOpCodeRead(poffHandle_t handle)
+{
+ poffResetAccess(handle);
+ g_bEndIn = 0;
+}
+
+/***********************************************************************/
diff --git a/misc/pascal/insn32/libinsn/preloc.c b/misc/pascal/insn32/libinsn/preloc.c
index 6d0b017a4..b752abba5 100644
--- a/misc/pascal/insn32/libinsn/preloc.c
+++ b/misc/pascal/insn32/libinsn/preloc.c
@@ -1,147 +1,149 @@
-/**********************************************************************
- * preloc.c
- * Perform P-Code relocations
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include "keywords.h"
-#include "pdefs.h"
-#include "pedefs.h"
-#include "podefs.h"
-#include "pinsn32.h"
-
-#include "pofflib.h"
-#include "perr.h"
-#include "pinsn.h"
-
-/**********************************************************************
- * Definitions
- **********************************************************************/
-
-/**********************************************************************
- * Private Type Definitions
- **********************************************************************/
-
-/**********************************************************************
- * Private Function Prototypes
- **********************************************************************/
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Functions
- **********************************************************************/
-
-int insn_Relocate(OPTYPE *op, uint32 pcOffset, uint32 roOffset)
-{
- switch (op->op)
- {
- /* Catch each instruction that references the read-only data
- * section.
- */
-
- case oLAC:
- /* Add the offset to the read-only data section */
-
- op->arg += roOffset;
- break;
-
- /* Catch each instruction that references the text section
- * data via an offset.
- */
-
- case oPCAL: /* Procedure / Function calls */
- case oJMP: /* Unconditional jump */
- case oJEQUZ: /* Jump on unary comparisons with zero */
- case oJNEQZ:
- case oJLTZ:
- case oJGTEZ:
- case oJGTZ:
- case oJLTEZ:
- case oJEQU: /* Jump on binary comparisons */
- case oJNEQ:
- case oJLT:
- case oJGTE:
- case oJGT:
- case oJLTE:
- /* Add the offset to the text section */
-
- op->arg += pcOffset;
- break;
-
- /* Return an end of file indication if oEND encountered */
-
- case oEND:
- return 1;
-
- /* Otherwise, it is not an interesting opcode */
- default:
- break;
- }
-
- /* Return 0 on all opcodes other than oEND */
-
- return 0;
-}
-
-/***********************************************************************/
-
-void insn_FixupProcedureCall(ubyte *progData, uint32 symValue)
-{
-
- /* Sanity checking */
-
- if (progData[0] != oPCAL)
- fatal(ePOFFCONFUSION);
-
- if (symValue > 0xffff)
- fatal(eBADSHORTINT);
-
- /* Perform the relocation */
-
- progData[2] = symValue >> 8;
- progData[3] = symValue & 0xff;
-}
-
-
-/***********************************************************************/
+/**********************************************************************
+ * preloc.c
+ * Perform P-Code relocations
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+
+#include "keywords.h"
+#include "pdefs.h"
+#include "pedefs.h"
+#include "podefs.h"
+#include "pinsn32.h"
+
+#include "pofflib.h"
+#include "perr.h"
+#include "pinsn.h"
+
+/**********************************************************************
+ * Definitions
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Type Definitions
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Function Prototypes
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Functions
+ **********************************************************************/
+
+int insn_Relocate(OPTYPE *op, uint32_t pcOffset, uint32_t roOffset)
+{
+ switch (op->op)
+ {
+ /* Catch each instruction that references the read-only data
+ * section.
+ */
+
+ case oLAC:
+ /* Add the offset to the read-only data section */
+
+ op->arg += roOffset;
+ break;
+
+ /* Catch each instruction that references the text section
+ * data via an offset.
+ */
+
+ case oPCAL: /* Procedure / Function calls */
+ case oJMP: /* Unconditional jump */
+ case oJEQUZ: /* Jump on unary comparisons with zero */
+ case oJNEQZ:
+ case oJLTZ:
+ case oJGTEZ:
+ case oJGTZ:
+ case oJLTEZ:
+ case oJEQU: /* Jump on binary comparisons */
+ case oJNEQ:
+ case oJLT:
+ case oJGTE:
+ case oJGT:
+ case oJLTE:
+ /* Add the offset to the text section */
+
+ op->arg += pcOffset;
+ break;
+
+ /* Return an end of file indication if oEND encountered */
+
+ case oEND:
+ return 1;
+
+ /* Otherwise, it is not an interesting opcode */
+ default:
+ break;
+ }
+
+ /* Return 0 on all opcodes other than oEND */
+
+ return 0;
+}
+
+/***********************************************************************/
+
+void insn_FixupProcedureCall(uint8_t *progData, uint32_t symValue)
+{
+
+ /* Sanity checking */
+
+ if (progData[0] != oPCAL)
+ fatal(ePOFFCONFUSION);
+
+ if (symValue > 0xffff)
+ fatal(eBADSHORTINT);
+
+ /* Perform the relocation */
+
+ progData[2] = symValue >> 8;
+ progData[3] = symValue & 0xff;
+}
+
+
+/***********************************************************************/
diff --git a/misc/pascal/insn32/libinsn/presettmpopcodewrite.c b/misc/pascal/insn32/libinsn/presettmpopcodewrite.c
index 3b66521e0..e4e10b458 100644
--- a/misc/pascal/insn32/libinsn/presettmpopcodewrite.c
+++ b/misc/pascal/insn32/libinsn/presettmpopcodewrite.c
@@ -1,97 +1,99 @@
-/**********************************************************************
- * paddtmpopcode
- * P-Code access utilities
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- **********************************************************************/
-
-/**********************************************************************
- * Included Files
- **********************************************************************/
-
-#include "keywords.h"
-#include "podefs.h"
-#include "pinsn32.h"
-
-#include "paslib.h"
-#include "pofflib.h"
-#include "pinsn.h"
-
-/**********************************************************************
- * Private Function Prototypes
- **********************************************************************/
-
-/**********************************************************************
- * Global Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Variables
- **********************************************************************/
-
-/**********************************************************************
- * Private Functions
- **********************************************************************/
-
-/**********************************************************************
- * Global Functions
- **********************************************************************/
-
-/**********************************************************************/
-
-void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr)
-{
- /* Write the opcode which is always present */
-
- (void)poffAddTmpProgByte(hProg, ptr->op);
-
- /* Write the 32-bit argument if present */
-
- if (ptr->op & o32)
- {
- ubyte *pb = (ubyte*)&ptr->arg;
-
- (void)poffAddTmpProgByte(hProg, pb[opB1]);
- (void)poffAddTmpProgByte(hProg, pb[opB2]);
- (void)poffAddTmpProgByte(hProg, pb[opB3]);
- (void)poffAddTmpProgByte(hProg, pb[opB4]);
- }
-}
-
-/**********************************************************************/
-
-void insn_ResetTmpOpCodeWrite(poffProgHandle_t hProg)
-{
- poffResetProgHandle(hProg);
-}
-
-/***********************************************************************/
+/**********************************************************************
+ * paddtmpopcode
+ * P-Code access utilities
+ *
+ * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ **********************************************************************/
+
+/**********************************************************************
+ * Included Files
+ **********************************************************************/
+
+#include <stdint.h>
+
+#include "keywords.h"
+#include "podefs.h"
+#include "pinsn32.h"
+
+#include "paslib.h"
+#include "pofflib.h"
+#include "pinsn.h"
+
+/**********************************************************************
+ * Private Function Prototypes
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Variables
+ **********************************************************************/
+
+/**********************************************************************
+ * Private Functions
+ **********************************************************************/
+
+/**********************************************************************
+ * Global Functions
+ **********************************************************************/
+
+/**********************************************************************/
+
+void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr)
+{
+ /* Write the opcode which is always present */
+
+ (void)poffAddTmpProgByte(hProg, ptr->op);
+
+ /* Write the 32-bit argument if present */
+
+ if (ptr->op & o32)
+ {
+ uint8_t *pb = (uint8_t*)&ptr->arg;
+
+ (void)poffAddTmpProgByte(hProg, pb[opB1]);
+ (void)poffAddTmpProgByte(hProg, pb[opB2]);
+ (void)poffAddTmpProgByte(hProg, pb[opB3]);
+ (void)poffAddTmpProgByte(hProg, pb[opB4]);
+ }
+}
+
+/**********************************************************************/
+
+void insn_ResetTmpOpCodeWrite(poffProgHandle_t hProg)
+{
+ poffResetProgHandle(hProg);
+}
+
+/***********************************************************************/