diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-18 15:43:29 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-12-18 15:43:29 +0000 |
commit | eb3074a4fe3b7c86d2a3ca139eb881964f2f23e1 (patch) | |
tree | 5ce1e76df21acb8d0b5b209fe7f2461a78c36a8e /misc/pascal/insn16/libinsn/preloc.c | |
parent | af6cfa901fa8cc78607976e8ed8aedc195500aff (diff) | |
download | nuttx-eb3074a4fe3b7c86d2a3ca139eb881964f2f23e1.tar.gz nuttx-eb3074a4fe3b7c86d2a3ca139eb881964f2f23e1.tar.bz2 nuttx-eb3074a4fe3b7c86d2a3ca139eb881964f2f23e1.zip |
Update to use stdint/stdbool.h
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2383 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/pascal/insn16/libinsn/preloc.c')
-rw-r--r-- | misc/pascal/insn16/libinsn/preloc.c | 296 |
1 files changed, 149 insertions, 147 deletions
diff --git a/misc/pascal/insn16/libinsn/preloc.c b/misc/pascal/insn16/libinsn/preloc.c index 9db115c28..0ecb53cb4 100644 --- a/misc/pascal/insn16/libinsn/preloc.c +++ b/misc/pascal/insn16/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 "pinsn16.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->arg2 += 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->arg2 += 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 "pinsn16.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->arg2 += 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->arg2 += 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; +} + + +/***********************************************************************/ |