summaryrefslogtreecommitdiff
path: root/misc/pascal/libpas
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 15:24:18 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-06 15:24:18 +0000
commitbb5ede8152f14cc757ff4ee6f44ff3128c3ff144 (patch)
treedb2726eb2b79bde890812a8227dae075f8ca2a3b /misc/pascal/libpas
parenta26dad80f4d004a4a0f6effedc803b3902389b39 (diff)
downloadnuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.tar.gz
nuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.tar.bz2
nuttx-bb5ede8152f14cc757ff4ee6f44ff3128c3ff144.zip
Standardize to big-endian binary
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@637 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'misc/pascal/libpas')
-rw-r--r--misc/pascal/libpas/Make.defs2
-rw-r--r--misc/pascal/libpas/Makefile2
-rw-r--r--misc/pascal/libpas/pswap.c59
3 files changed, 61 insertions, 2 deletions
diff --git a/misc/pascal/libpas/Make.defs b/misc/pascal/libpas/Make.defs
index 9dca4a720..558f6b507 100644
--- a/misc/pascal/libpas/Make.defs
+++ b/misc/pascal/libpas/Make.defs
@@ -35,4 +35,4 @@
############################################################################
PAS_ASRCS =
-PAS_CSRCS = psignextend16.c
+PAS_CSRCS = psignextend16.c pswap.c
diff --git a/misc/pascal/libpas/Makefile b/misc/pascal/libpas/Makefile
index 047a47a13..b686daa89 100644
--- a/misc/pascal/libpas/Makefile
+++ b/misc/pascal/libpas/Makefile
@@ -47,7 +47,7 @@ LIBDIR = $(PASCAL)/lib
#
# Objects and targets
#
-LIBPASSRCS = pextension.c psignextend16.c
+LIBPASSRCS = pextension.c psignextend16.c pswap.c
LIBPASOBJS = $(LIBPASSRCS:.c=.o)
OBJS = $(LIBPASOBJS)
diff --git a/misc/pascal/libpas/pswap.c b/misc/pascal/libpas/pswap.c
new file mode 100644
index 000000000..0bf4a31f8
--- /dev/null
+++ b/misc/pascal/libpas/pswap.c
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * libpas/pswap.c
+ * Byte swapping to handling endian-ness conversions
+ *
+ * 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 <string.h>
+
+#include "keywords.h"
+#include "pdefs.h"
+#include "paslib.h"
+
+/***********************************************************************/
+
+uint16 poffSwap16(uint16 val)
+{
+ return val >> 8 | val << 8;
+}
+
+uint32 poffSwap32(uint32 val)
+{
+ return val >> 24 | ((val >> 8) & 0x0000ff00) | ((val << 8) & 0x00ff0000) | val << 24;
+}
+
+/***********************************************************************/