diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-18 16:30:25 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-18 16:30:25 +0000 |
commit | 9695e5c9051d331278288a071c1353ae7214c4c2 (patch) | |
tree | 060301cfc350c1532655c699ab2419e1c4c2e486 /misc/pascal/insn32/include | |
parent | eb3074a4fe3b7c86d2a3ca139eb881964f2f23e1 (diff) | |
download | nuttx-9695e5c9051d331278288a071c1353ae7214c4c2.tar.gz nuttx-9695e5c9051d331278288a071c1353ae7214c4c2.tar.bz2 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/include')
-rw-r--r-- | misc/pascal/insn32/include/builtins.h | 16 | ||||
-rw-r--r-- | misc/pascal/insn32/include/pexec.h | 316 | ||||
-rw-r--r-- | misc/pascal/insn32/include/rinsn32.h | 442 |
3 files changed, 396 insertions, 378 deletions
diff --git a/misc/pascal/insn32/include/builtins.h b/misc/pascal/insn32/include/builtins.h index c60e44eea..04aacfde9 100644 --- a/misc/pascal/insn32/include/builtins.h +++ b/misc/pascal/insn32/include/builtins.h @@ -2,7 +2,7 @@ * builtins.h * Definitions of built-in function calls. * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * 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 @@ -38,7 +38,13 @@ #define __BUILTINS_H /*********************************************************************** - * Definitions + * Included Files + ***********************************************************************/ + +#include <stdint.h> + +/*********************************************************************** + * Pre-processor Definitions ***********************************************************************/ #define MAX_BUILTIN_ARGS 3 @@ -436,9 +442,9 @@ struct regm_builtin_s { const char *szName; - uint32 wRetSize; - uint32 nParms; - uint32 wArgSize[MAX_BUILTIN_ARGS]; + uint32_t wRetSize; + uint32_t nParms; + uint32_t wArgSize[MAX_BUILTIN_ARGS]; }; #endif /* __BUILTINS_H */ diff --git a/misc/pascal/insn32/include/pexec.h b/misc/pascal/insn32/include/pexec.h index c8b530afc..67227ff3a 100644 --- a/misc/pascal/insn32/include/pexec.h +++ b/misc/pascal/insn32/include/pexec.h @@ -1,158 +1,160 @@ -/****************************************************************************
- * pexec.h
- *
- * 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.
- *
- ****************************************************************************/
-
-#ifndef __PEXEC_H
-#define __PEXEC_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-/****************************************************************************
- * Definitions
- ****************************************************************************/
-
-#define BPERI 2
-#define ITOBSTACK(i) ((i) << 1)
-#define BTOISTACK(i) ((i) >> 1)
-#define ROUNDBTOI(i) (((i) + 1) >> 1)
-
-/****************************************************************************
- * Type Definitions
- ****************************************************************************/
-
-typedef uint32 ustack_t; /* Stack values are 16-bits in length */
-typedef sint32 sstack_t;
-typedef uint32 addr_t; /* Addresses are 16-bits in length */
-typedef uint16 level_t; /* Limits to MAXUINT16 levels */
-
-union stack_u
-{
- ustack_t *i;
- ubyte *b;
-};
-typedef union stack_u stackType;
-
-/* This structure describes the parameters needed to initialize the p-code
- * interpreter.
- */
-
-struct pexec_attr_s
-{
- /* Instruction space (I-Space) */
-
- FAR ubyte *ispace; /* Allocated I-Space containing p-code data */
- addr_t entry; /* Entry point */
- addr_t maxpc; /* Last valid p-code address */
-
- /* Read-only data block */
-
- FAR ubyte *rodata; /* Address of read-only data block */
- addr_t rosize; /* Size of read-only data block */
-
- /* Allocate for variable storage */
-
- addr_t varsize; /* Variable storage size */
- addr_t strsize; /* String storage size */
-};
-
-/* This structure defines the current state of the p-code interpreter */
-
-struct pexec_s
-{
- /* This is the emulated P-Machine stack (D-Space) */
-
- stackType dstack;
-
- /* This is the emulated P-Machine instruction space (I-Space) */
-
- FAR ubyte *ispace;
-
- /* Address of last valid P-Code */
-
- addr_t maxpc;
-
- /* These are the emulated P-Machine registers:
- *
- * spb: Base of the stack
- * sp: The Pascal stack pointer
- * lsp: Level stack pointer
- * csp: The current top of the stack used to manage string
- * storage
- * fp: Base Register of the current stack frame. Holds the address
- * of the base of the stack frame of the current block.
- * fop: Pointer to section containing read-only data
- * pc: Holds the current p-code location
- */
-
- addr_t spb; /* Pascal stack base */
- addr_t sp; /* Pascal stack pointer */
- addr_t lsp; /* Level stack pointer */
- addr_t csp; /* Character stack pointer */
- addr_t fp; /* Base of the current frame */
- addr_t rop; /* Read-only data pointer */
- addr_t pc; /* Program counter */
-
- /* Info needed to perform a simulated reset */
-
- addr_t strsize; /* String stack size */
- addr_t rosize; /* Read-only stack size */
- addr_t entry; /* Entry point */
- addr_t stacksize; /* (debug only) */
-};
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
-#endif
-
-EXTERN FAR struct pexec_s *pload(const char *filename, addr_t varsize, addr_t strsize);
-EXTERN FAR struct pexec_s *pexec_init(struct pexec_attr_s *attr);
-EXTERN int pexec(FAR struct pexec_s *st);
-EXTERN void pexec_reset(struct pexec_s *st);
-EXTERN void pexec_release(struct pexec_s *st);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
+/**************************************************************************** + * pexec.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __PEXEC_H +#define __PEXEC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +#define BPERI 2 +#define ITOBSTACK(i) ((i) << 1) +#define BTOISTACK(i) ((i) >> 1) +#define ROUNDBTOI(i) (((i) + 1) >> 1) + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +typedef uint32_t ustack_t; /* Stack values are 16-bits in length */ +typedef int32_t sstack_t; +typedef uint32_t addr_t; /* Addresses are 16-bits in length */ +typedef uint16_t level_t; /* Limits to MAXUINT16 levels */ + +union stack_u +{ + ustack_t *i; + uint8_t *b; +}; +typedef union stack_u stackType; + +/* This structure describes the parameters needed to initialize the p-code + * interpreter. + */ + +struct pexec_attr_s +{ + /* Instruction space (I-Space) */ + + FAR uint8_t *ispace; /* Allocated I-Space containing p-code data */ + addr_t entry; /* Entry point */ + addr_t maxpc; /* Last valid p-code address */ + + /* Read-only data block */ + + FAR uint8_t *rodata; /* Address of read-only data block */ + addr_t rosize; /* Size of read-only data block */ + + /* Allocate for variable storage */ + + addr_t varsize; /* Variable storage size */ + addr_t strsize; /* String storage size */ +}; + +/* This structure defines the current state of the p-code interpreter */ + +struct pexec_s +{ + /* This is the emulated P-Machine stack (D-Space) */ + + stackType dstack; + + /* This is the emulated P-Machine instruction space (I-Space) */ + + FAR uint8_t *ispace; + + /* Address of last valid P-Code */ + + addr_t maxpc; + + /* These are the emulated P-Machine registers: + * + * spb: Base of the stack + * sp: The Pascal stack pointer + * lsp: Level stack pointer + * csp: The current top of the stack used to manage string + * storage + * fp: Base Register of the current stack frame. Holds the address + * of the base of the stack frame of the current block. + * fop: Pointer to section containing read-only data + * pc: Holds the current p-code location + */ + + addr_t spb; /* Pascal stack base */ + addr_t sp; /* Pascal stack pointer */ + addr_t lsp; /* Level stack pointer */ + addr_t csp; /* Character stack pointer */ + addr_t fp; /* Base of the current frame */ + addr_t rop; /* Read-only data pointer */ + addr_t pc; /* Program counter */ + + /* Info needed to perform a simulated reset */ + + addr_t strsize; /* String stack size */ + addr_t rosize; /* Read-only stack size */ + addr_t entry; /* Entry point */ + addr_t stacksize; /* (debug only) */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +EXTERN FAR struct pexec_s *pload(const char *filename, addr_t varsize, addr_t strsize); +EXTERN FAR struct pexec_s *pexec_init(struct pexec_attr_s *attr); +EXTERN int pexec(FAR struct pexec_s *st); +EXTERN void pexec_reset(struct pexec_s *st); +EXTERN void pexec_release(struct pexec_s *st); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + #endif /* __PEXEC_H */
\ No newline at end of file diff --git a/misc/pascal/insn32/include/rinsn32.h b/misc/pascal/insn32/include/rinsn32.h index f2a89e5fa..8894023ff 100644 --- a/misc/pascal/insn32/include/rinsn32.h +++ b/misc/pascal/insn32/include/rinsn32.h @@ -1,216 +1,226 @@ -/***********************************************************************
- * rinsn32.h
- * 32-bit register module instruction definitions
- *
- * 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.
- *
- ***********************************************************************/
-
-#ifndef __RINSN32_H
-#define __RINSN32_H
-
-/* 32-bit op-code bit definitions
- *
- * Machine model:
- *
- * SPB 32-bit Pascal stack base address
- * SP 32-bit Pascal stack pointer
- * LSP 32-bit level stack pointer
- * CSB 32-bit character stack base address
- * PC 32-bit program counter
- * ZRO 32-bit register containing zero (like MIPS)
- * Rn 32-bit general purpose registers
- *
- * Parameters passed in registers up to a limit. Parameters
- * beyond the limit are passed on the stack. Return values
- * are provided in these same registers.
- *
- * Instruction forms
- *
- * FORM 1: <op> <roperand1>, <operand2>
- * FORM 2: <op> <rdest>, <operand2>
- * FORM 3: <op> <rdest>, <roperand1>, <operand2>
- * <rsrc>, <roperand1>, <operand2>
- * FORM 4: <op> <pc-offset>
- *
- * Where
- * <op> operation code
- * [cc] optional conditional execution
- * [S] optional set condition code
- * <rdest> register holding the result
- * <rsrc> register holding data to be stored.
- * <roperand1> register holding the first operand
- * <operand2> One of <roperand2> or <immediate>
- * <roperand2> register holding the second operand
- * <immediate> Immediate constant data (short).
- * <pc-offset> Word offset from current PC
- *
- * NOTE: This instruction set is inspired by the ARM instruction
- * set, but is intended to be a general register model. It does
- * not exploit certain ARM-isms such as "flexible" operands, conditional
- * execution, post-incrementing, pre-incrementing, pc-relative addressing,
- * optional register writeback, or ldm/stm with register sets, etc.
- */
-
-#define FORM1(o) (((o) & 0xe0) == 0x00)
-#define FORM1R(o) (((o) & 0xf0) == 0x00)
-#define FORM1I(o) (((o) & 0xf0) == 0x10)
-#define FORM1O(o) ((o) & 0x0f)
-
-#define FORM2(o) (((o) & 0xe0) == 0x20)
-#define FORM2R(o) (((o) & 0xf0) == 0x20)
-#define FORM2I(o) (((o) & 0xf0) == 0x30)
-#define FORM2O(o) ((o) & 0x0f)
-
-#define FORM3(o) (((o) & 0x80) == 0x80)
-#define FORM3R(o) (((o) & 0xc0) == 0x80)
-#define FORM3I(o) (((o) & 0xc0) == 0xc0)
-#define FORM3O(o) ((o) & 0x3f)
-
-#define FORM4(o) (((o) & 0xc0) == 0x40)
-#define FORM3O(o) ((o) & 0x3f)
-
-struct rinsn_u
-{
- ubyte opcode;
- union {
- struct {
- uint32 rop1;
- uint32 rop2;
- } r1;
- struct {
- uint32 rop1;
- uint32 im2;
- } i1;
- struct {
- uint32 rdest;
- uint32 rop;
- } r2;
- struct {
- uint32 rdest;
- uint32 im;
- } i2;
- struct {
- uint32 rdest;
- uint32 rop1;
- uint32 rop2;
- } r3;
- struct {
- uint32 rdest;
- uint32 rop1;
- uint32 im2;
- } i3;
- struct {
- uint32 offset;
- } i4;
- } f;
-};
-typedef struct rinsn_u RINSN32;
-
-/* FORM 1: Comparisons */
-
-#define rCMP (0x00) /* Form 1: set <cc> after <roperand1> - <roperand2> */
-#define rCMPI (0x10) /* Form 1: set <cc> after <roperand1> - <immediate> */
-#define rCMN (0x01) /* Form 1: set <cc> after <roperand1> + <roperand2> */
-#define rCMNI (0x11) /* Form 1: set <cc> after <roperand1> + <immediate> */
-
-/* FORM 2: Data movement */
-
-#define rMOV (0x20) /* Form 1: <rdest> = <roperand2> */
-#define rMOVI (0x30) /* Form 1: <rdist> = <immediate> */
-#define rMVN (0x21) /* Form 1: <rdest> = ~<roperand2> */
-#define rMVNI (0x31) /* Form 1: <rdist> = ~<immediate> */
-
-/* FORM 4: Program control */
-
-#define rB (0x40) /* PC += <pcoffset> << 2 */
-#define rBEQ (0x41) /* if <cc>->EQ, PC += <pcoffset> << 2 */
-#define rBNE (0x42) /* if <cc>->NEQ, PC += <pcoffset> << 2 */
-#define rBLT (0x43) /* if <cc>->LT, PC += <pcoffset> << 2 */
-#define rBGTE (0x44) /* if <cc>->GTE, PC += <pcoffset> << 2 */
-#define rBGT (0x45) /* if <cc>->GT, PC += <pcoffset> << 2 */
-#define rBLTE (0x46) /* if <cc>->KTE, PC += <pcoffset> << 2 */
-#define rBL (0x47) /* LR=next PC, PC += <pcoffset> << 2 */
-
-/* FORM 3: Arithmetic and logical operations */
-
-#define rADD (0x80) /* Form 3: <rdest> = <roperand1> + <roperand2> */
-#define rADDI (0xc0) /* Form 3: <rdest> = <roperand1> + <immediate> */
-#define rSUB (0x81) /* Form 3: <rdest> = <roperand1> - <roperand2> */
-#define rSUBI (0xc1) /* Form 3: <rdest> = <roperand1> - <immediate> */
-#define rRSB (0x82) /* Form 3: <rdest> = -<roperand1> + <roperand2> */
-#define rRSBI (0xc2) /* Form 3: <rdest> = -<roperand2> + <immediate> */
-#define rMUL (0x83) /* Form 3: <rdest> = <roperand1> * <roperand2> */
-#define rMULI (0xc3) /* Form 3: <rdest> = <roperand1> * <immediate> */
-#define rDIV (0x84) /* Form 3: <rdest> = <roperand1> / <roperand2> */
-#define rDIVI (0xc4) /* Form 3: <rdest> = <roperand1> / <immediate> */
-#define rMOD (0x85) /* Form 3: <rdest> = <roperand1> % <roperand2> */
-#define rMODI (0xc5) /* Form 3: <rdest> = <roperand1> % <immediate> */
-#define rSLL (0x86) /* Form 3: <rdest> = <roperand1> << <roperand2> */
-#define rSLLI (0xc6) /* Form 3: <rdest> = <roperand1> << <immediate> */
-#define rSRL (0x87) /* Form 3: <rdest> = <roperand1> >> <roperand2> */
-#define rSRLI (0xc7) /* Form 3: <rdest> = <roperand1> >> <immediate> */
-#define rSRA (0x88) /* Form 3: <rdest> = <roperand1> >> <roperand2> */
-#define rSRAI (0xc8) /* Form 3: <rdest> = <roperand1> >> <immediate> */
-#define rOR (0x89) /* Form 3: <rdest> = <roperand1> | <roperand2> */
-#define rORI (0xc9) /* Form 3: <rdest> = <roperand1> | <immediate> */
-#define rAND (0x8a) /* Form 3: <rdest> = <roperand1> & <roperand2> */
-#define rANDI (0xca) /* Form 3: <rdest> = <roperand1> & <immediate> */
-#define rXOR (0x8b) /* Form 3: <rdest> = <roperand1> xor <roperand2> */
-#define rXORI (0xcb) /* Form 3: <rdest> = <roperand1> xor <immediate> */
-#define rANDN (0x8c) /* Form 3: <rdest> = <roperand1> & ~<roperand2> */
-#define rANDNI (0xcc) /* Form 3: <rdest> = <roperand1> & ~<immediate> */
-
-/* FORM 3: Loads and stores */
-
-#define rLD (0x90) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */
-#define rLDI (0xd0) /* Form 3: <rdest> = (<roperand1> + (<immediate> << 2)) */
-#define rLDH (0x91) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */
-#define rLDIH (0xd1) /* Form 3: <rdest> = (<roperand1> + (<immediate> << 1)) */
-#define rLDB (0x92) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */
-#define rLDIB (0xd2) /* Form 3: <rdest> = (<roperand1> + <immediate>) */
-
-#define rLDM (0xd3) /* Form 3: Load <immediate> registers. Source
- * address is roperand1, first dest register is
- * <rdest>, register count is <immediate> */
-
-#define rST (0x94) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */
-#define rSTI (0xd4) /* Form 3: (<roperand1> + (<immediate> << 2)) = <rsrc> */
-#define rSTH (0x95) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */
-#define rSTIH (0xd5) /* Form 3: (<roperand1> + (<immediate> << 1)) = <rsrc> */
-#define rSTB (0x96) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */
-#define rSTIB (0xd6) /* Form 3: (<roperand1> + <immediate>) = <rsrc> */
-
-#define rSTM (0xd7) /* Form 3: Store <immediate> registers. Destination
- * address is roperand1, first source register is
- * <rsrc>, register count is <immediate> */
-
-#endif /* __RINSN32_H */
+/*********************************************************************** + * rinsn32.h + * 32-bit register module instruction definitions + * + * 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. + * + ***********************************************************************/ + +#ifndef __RINSN32_H +#define __RINSN32_H + +/*********************************************************************** + * Included Files + ***********************************************************************/ + +#include <stdint.h> + +/*********************************************************************** + * Pre-processor Definitions + ***********************************************************************/ + +/* 32-bit op-code bit definitions + * + * Machine model: + * + * SPB 32-bit Pascal stack base address + * SP 32-bit Pascal stack pointer + * LSP 32-bit level stack pointer + * CSB 32-bit character stack base address + * PC 32-bit program counter + * ZRO 32-bit register containing zero (like MIPS) + * Rn 32-bit general purpose registers + * + * Parameters passed in registers up to a limit. Parameters + * beyond the limit are passed on the stack. Return values + * are provided in these same registers. + * + * Instruction forms + * + * FORM 1: <op> <roperand1>, <operand2> + * FORM 2: <op> <rdest>, <operand2> + * FORM 3: <op> <rdest>, <roperand1>, <operand2> + * <rsrc>, <roperand1>, <operand2> + * FORM 4: <op> <pc-offset> + * + * Where + * <op> operation code + * [cc] optional conditional execution + * [S] optional set condition code + * <rdest> register holding the result + * <rsrc> register holding data to be stored. + * <roperand1> register holding the first operand + * <operand2> One of <roperand2> or <immediate> + * <roperand2> register holding the second operand + * <immediate> Immediate constant data (short). + * <pc-offset> Word offset from current PC + * + * NOTE: This instruction set is inspired by the ARM instruction + * set, but is intended to be a general register model. It does + * not exploit certain ARM-isms such as "flexible" operands, conditional + * execution, post-incrementing, pre-incrementing, pc-relative addressing, + * optional register writeback, or ldm/stm with register sets, etc. + */ + +#define FORM1(o) (((o) & 0xe0) == 0x00) +#define FORM1R(o) (((o) & 0xf0) == 0x00) +#define FORM1I(o) (((o) & 0xf0) == 0x10) +#define FORM1O(o) ((o) & 0x0f) + +#define FORM2(o) (((o) & 0xe0) == 0x20) +#define FORM2R(o) (((o) & 0xf0) == 0x20) +#define FORM2I(o) (((o) & 0xf0) == 0x30) +#define FORM2O(o) ((o) & 0x0f) + +#define FORM3(o) (((o) & 0x80) == 0x80) +#define FORM3R(o) (((o) & 0xc0) == 0x80) +#define FORM3I(o) (((o) & 0xc0) == 0xc0) +#define FORM3O(o) ((o) & 0x3f) + +#define FORM4(o) (((o) & 0xc0) == 0x40) +#define FORM3O(o) ((o) & 0x3f) + +struct rinsn_u +{ + uint8_t opcode; + union { + struct { + uint32_t rop1; + uint32_t rop2; + } r1; + struct { + uint32_t rop1; + uint32_t im2; + } i1; + struct { + uint32_t rdest; + uint32_t rop; + } r2; + struct { + uint32_t rdest; + uint32_t im; + } i2; + struct { + uint32_t rdest; + uint32_t rop1; + uint32_t rop2; + } r3; + struct { + uint32_t rdest; + uint32_t rop1; + uint32_t im2; + } i3; + struct { + uint32_t offset; + } i4; + } f; +}; +typedef struct rinsn_u RINSN32; + +/* FORM 1: Comparisons */ + +#define rCMP (0x00) /* Form 1: set <cc> after <roperand1> - <roperand2> */ +#define rCMPI (0x10) /* Form 1: set <cc> after <roperand1> - <immediate> */ +#define rCMN (0x01) /* Form 1: set <cc> after <roperand1> + <roperand2> */ +#define rCMNI (0x11) /* Form 1: set <cc> after <roperand1> + <immediate> */ + +/* FORM 2: Data movement */ + +#define rMOV (0x20) /* Form 1: <rdest> = <roperand2> */ +#define rMOVI (0x30) /* Form 1: <rdist> = <immediate> */ +#define rMVN (0x21) /* Form 1: <rdest> = ~<roperand2> */ +#define rMVNI (0x31) /* Form 1: <rdist> = ~<immediate> */ + +/* FORM 4: Program control */ + +#define rB (0x40) /* PC += <pcoffset> << 2 */ +#define rBEQ (0x41) /* if <cc>->EQ, PC += <pcoffset> << 2 */ +#define rBNE (0x42) /* if <cc>->NEQ, PC += <pcoffset> << 2 */ +#define rBLT (0x43) /* if <cc>->LT, PC += <pcoffset> << 2 */ +#define rBGTE (0x44) /* if <cc>->GTE, PC += <pcoffset> << 2 */ +#define rBGT (0x45) /* if <cc>->GT, PC += <pcoffset> << 2 */ +#define rBLTE (0x46) /* if <cc>->KTE, PC += <pcoffset> << 2 */ +#define rBL (0x47) /* LR=next PC, PC += <pcoffset> << 2 */ + +/* FORM 3: Arithmetic and logical operations */ + +#define rADD (0x80) /* Form 3: <rdest> = <roperand1> + <roperand2> */ +#define rADDI (0xc0) /* Form 3: <rdest> = <roperand1> + <immediate> */ +#define rSUB (0x81) /* Form 3: <rdest> = <roperand1> - <roperand2> */ +#define rSUBI (0xc1) /* Form 3: <rdest> = <roperand1> - <immediate> */ +#define rRSB (0x82) /* Form 3: <rdest> = -<roperand1> + <roperand2> */ +#define rRSBI (0xc2) /* Form 3: <rdest> = -<roperand2> + <immediate> */ +#define rMUL (0x83) /* Form 3: <rdest> = <roperand1> * <roperand2> */ +#define rMULI (0xc3) /* Form 3: <rdest> = <roperand1> * <immediate> */ +#define rDIV (0x84) /* Form 3: <rdest> = <roperand1> / <roperand2> */ +#define rDIVI (0xc4) /* Form 3: <rdest> = <roperand1> / <immediate> */ +#define rMOD (0x85) /* Form 3: <rdest> = <roperand1> % <roperand2> */ +#define rMODI (0xc5) /* Form 3: <rdest> = <roperand1> % <immediate> */ +#define rSLL (0x86) /* Form 3: <rdest> = <roperand1> << <roperand2> */ +#define rSLLI (0xc6) /* Form 3: <rdest> = <roperand1> << <immediate> */ +#define rSRL (0x87) /* Form 3: <rdest> = <roperand1> >> <roperand2> */ +#define rSRLI (0xc7) /* Form 3: <rdest> = <roperand1> >> <immediate> */ +#define rSRA (0x88) /* Form 3: <rdest> = <roperand1> >> <roperand2> */ +#define rSRAI (0xc8) /* Form 3: <rdest> = <roperand1> >> <immediate> */ +#define rOR (0x89) /* Form 3: <rdest> = <roperand1> | <roperand2> */ +#define rORI (0xc9) /* Form 3: <rdest> = <roperand1> | <immediate> */ +#define rAND (0x8a) /* Form 3: <rdest> = <roperand1> & <roperand2> */ +#define rANDI (0xca) /* Form 3: <rdest> = <roperand1> & <immediate> */ +#define rXOR (0x8b) /* Form 3: <rdest> = <roperand1> xor <roperand2> */ +#define rXORI (0xcb) /* Form 3: <rdest> = <roperand1> xor <immediate> */ +#define rANDN (0x8c) /* Form 3: <rdest> = <roperand1> & ~<roperand2> */ +#define rANDNI (0xcc) /* Form 3: <rdest> = <roperand1> & ~<immediate> */ + +/* FORM 3: Loads and stores */ + +#define rLD (0x90) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */ +#define rLDI (0xd0) /* Form 3: <rdest> = (<roperand1> + (<immediate> << 2)) */ +#define rLDH (0x91) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */ +#define rLDIH (0xd1) /* Form 3: <rdest> = (<roperand1> + (<immediate> << 1)) */ +#define rLDB (0x92) /* Form 3: <rdest> = (<roperand1> + <roperand2>) */ +#define rLDIB (0xd2) /* Form 3: <rdest> = (<roperand1> + <immediate>) */ + +#define rLDM (0xd3) /* Form 3: Load <immediate> registers. Source + * address is roperand1, first dest register is + * <rdest>, register count is <immediate> */ + +#define rST (0x94) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */ +#define rSTI (0xd4) /* Form 3: (<roperand1> + (<immediate> << 2)) = <rsrc> */ +#define rSTH (0x95) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */ +#define rSTIH (0xd5) /* Form 3: (<roperand1> + (<immediate> << 1)) = <rsrc> */ +#define rSTB (0x96) /* Form 3: (<roperand1> + <roperand2>) = <rsrc> */ +#define rSTIB (0xd6) /* Form 3: (<roperand1> + <immediate>) = <rsrc> */ + +#define rSTM (0xd7) /* Form 3: Store <immediate> registers. Destination + * address is roperand1, first source register is + * <rsrc>, register count is <immediate> */ + +#endif /* __RINSN32_H */ |