diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/18f452.lkr FreeRTOSV7.1.0/Demo/PIC18_MPLAB/18f452.lkr
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/18f452.lkr	2009-08-18 11:38:20.000000000 -0400
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/18f452.lkr	2012-04-04 13:51:26.000000000 -0400
@@ -15,10 +15,29 @@
 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
 
-ACCESSBANK NAME=accessram  START=0x0            END=0x7F
-DATABANK   NAME=BIG_BLOCK  START=0x80          END=0x5FF
+ACCESSBANK NAME=cmpmng     START=0x0            END=0x19           PROTECTED
+ACCESSBANK NAME=accessram  START=0x1A           END=0x5F
+
+// Compiler-Managed Data Memory. Forcing these sections into their own
+// region serves as an early warning signal should the size of
+// .tmpdata increase.  If it does, the size of the `cmpmng' region will
+// have to be increased to accomodate it, but it will also be
+// necessary to modify configCOMPILER_MANAGED_MEMORY_SIZE.
+SECTION NAME=MATH_DATA RAM=cmpmng
+SECTION NAME=.tmpdata  RAM=cmpmng
+
+DATABANK   NAME=gpr0       START=0x80           END=0xFF
+DATABANK   NAME=heap       START=0x100          END=0x4FF          PROTECTED
+// These regions have been removed to make room for the heap
+//DATABANK   NAME=gpr1       START=0x100          END=0x1FF
+//DATABANK   NAME=gpr2       START=0x200          END=0x2FF
+//DATABANK   NAME=gpr3       START=0x300          END=0x3FF
+//DATABANK   NAME=gpr4       START=0x400          END=0x4FF
+DATABANK   NAME=gpr5       START=0x500          END=0x5FF
 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
 
+SECTION NAME=heap RAM=heap
+
 SECTION    NAME=CONFIG     ROM=config
 
-STACK SIZE=0x60 RAM=BIG_BLOCK
+STACK SIZE=0x100 RAM=gpr5
diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/FreeRTOSConfig.h FreeRTOSV7.1.0/Demo/PIC18_MPLAB/FreeRTOSConfig.h
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/FreeRTOSConfig.h	2011-12-13 15:38:28.000000000 -0500
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/FreeRTOSConfig.h	2012-04-04 13:51:26.000000000 -0400
@@ -74,12 +74,22 @@
 #define configTICK_RATE_HZ				( ( portTickType ) 1000 )
 #define configCPU_CLOCK_HZ				( ( unsigned long ) 20000000 )
 #define configMAX_PRIORITIES			( ( unsigned portBASE_TYPE ) 4 )
-#define configMINIMAL_STACK_SIZE		( 105 )
+/* Some memory areas get saved as part of the task context.  These memory
+area's get used by the compiler for temporary storage, especially when 
+performing mathematical operations, or when using 32bit data types.  This
+constant defines the size of memory area which must be saved. */
+#define configCOMPILER_MANAGED_MEMORY_SIZE	( ( unsigned char ) 0x1A )
+#define configMINIMAL_STACK_SIZE		( 86 + configCOMPILER_MANAGED_MEMORY_SIZE )
+/* NOTE: If you change TOTAL_HEAP_SIZE, adjust the size of the HEAP
+section in the linker script to match.  They must match exactly,
+since the heap is the only thing allowed to reside in a section
+that spans banks. */
 #define configTOTAL_HEAP_SIZE			( ( size_t ) 1024 )
 #define configMAX_TASK_NAME_LEN			( 4 )
 #define configUSE_TRACE_FACILITY		0
 #define configUSE_16_BIT_TICKS			1
 #define configIDLE_SHOULD_YIELD			1
+#define configPORT_USER_ISR_VECTOR		vUserInterruptVector
 
 /* Co-routine definitions. */
 #define configUSE_CO_ROUTINES 		0
diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/interrupts.c FreeRTOSV7.1.0/Demo/PIC18_MPLAB/interrupts.c
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/interrupts.c	1969-12-31 19:00:00.000000000 -0500
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/interrupts.c	2012-04-04 13:51:20.000000000 -0400
@@ -0,0 +1,35 @@
+#include "FreeRTOS.h"
+
+/*
+ * The serial port ISR's are defined in serial.c.
+ */
+void vSerialTxISR( void );
+void vSerialRxISR( void );
+
+/*
+ * User Vector for ISR.  Must alter any registers.
+ */
+void vUserInterruptVector( void )
+{
+	/* Was the interrupt a byte being received? */
+	if( PIR1bits.RCIF )
+	{
+		if( PIE1bits.RCIE )
+		{
+			_asm
+				goto vSerialRxISR
+			_endasm
+		}
+	}
+
+	/* Was the interrupt the Tx register becoming empty? */
+	if( PIR1bits.TXIF )
+	{
+		if( PIE1bits.TXIE )
+		{
+			_asm
+				goto vSerialTxISR
+			_endasm
+		}
+	}
+}
diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo1.mcp FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo1.mcp
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo1.mcp	2009-08-18 11:38:20.000000000 -0400
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo1.mcp	2012-04-04 13:52:00.000000000 -0400
@@ -7,7 +7,7 @@
 dir_bin=
 dir_tmp=
 dir_sin=
-dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
+dir_inc=C:\Devtools\Microchip\MCC18\h;.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;..\Common\include;..\..\Common\include
 dir_lib=C:\Devtools\Microchip\MCC18\lib
 dir_lkr=
 [CAT_FILTERS]
@@ -38,6 +38,7 @@
 file_018=no
 file_019=no
 file_020=no
+file_021=no
 [FILE_INFO]
 file_000=..\..\Source\tasks.c
 file_001=..\..\Source\queue.c
@@ -48,18 +49,19 @@
 file_006=ParTest\ParTest.c
 file_007=serial\serial.c
 file_008=..\Common\Minimal\integer.c
-file_009=..\..\Source\portable\MemMang\heap_1.c
-file_010=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
-file_011=..\..\Source\include\task.h
-file_012=..\..\Source\include\list.h
-file_013=..\..\Source\include\portable.h
-file_014=..\..\Source\include\projdefs.h
-file_015=..\..\Source\include\queue.h
-file_016=..\Common\include\integer.h
-file_017=..\Common\include\PollQ.h
-file_018=..\Common\include\serial.h
-file_019=FreeRTOSConfig.h
-file_020=18f452.lkr
+file_009=..\..\Source\portable\MemMang\heap_1_pic.c
+file_010=interrupts.c
+file_011=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
+file_012=..\..\Source\include\task.h
+file_013=..\..\Source\include\list.h
+file_014=..\..\Source\include\portable.h
+file_015=..\..\Source\include\projdefs.h
+file_016=..\..\Source\include\queue.h
+file_017=..\Common\include\integer.h
+file_018=..\Common\include\PollQ.h
+file_019=..\Common\include\serial.h
+file_020=FreeRTOSConfig.h
+file_021=18f452.lkr
 [SUITE_INFO]
 suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
 suite_state=
diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo2.mcp FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo2.mcp
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo2.mcp	2009-08-18 11:38:20.000000000 -0400
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo2.mcp	2012-04-04 13:51:26.000000000 -0400
@@ -6,7 +6,7 @@
 dir_bin=
 dir_tmp=
 dir_sin=
-dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
+dir_inc=C:\Devtools\Microchip\MCC18\h;.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;..\Common\include;..\..\Common\include
 dir_lib=C:\Devtools\Microchip\MCC18\lib
 dir_lkr=
 [CAT_FILTERS]
@@ -35,6 +35,7 @@
 file_016=no
 file_017=no
 file_018=no
+file_019=no
 [FILE_INFO]
 file_000=main2.c
 file_001=serial\serial.c
@@ -42,19 +43,20 @@
 file_003=..\..\Source\tasks.c
 file_004=..\..\Source\queue.c
 file_005=..\..\Source\list.c
-file_006=..\..\Source\portable\MemMang\heap_1.c
+file_006=..\..\Source\portable\MPLAB\PIC18F\heap_1_pic.c
 file_007=..\Common\Minimal\flash.c
 file_008=..\..\Source\portable\MPLAB\PIC18F\port.c
-file_009=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
-file_010=..\..\Source\include\task.h
-file_011=..\..\Source\include\list.h
-file_012=..\..\Source\include\portable.h
-file_013=..\..\Source\include\projdefs.h
-file_014=..\..\Source\include\queue.h
-file_015=..\Common\include\serial.h
-file_016=..\Common\include\flash.h
-file_017=FreeRTOSConfig.h
-file_018=18f452.lkr
+file_009=interrupts.c
+file_010=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
+file_011=..\..\Source\include\task.h
+file_012=..\..\Source\include\list.h
+file_013=..\..\Source\include\portable.h
+file_014=..\..\Source\include\projdefs.h
+file_015=..\..\Source\include\queue.h
+file_016=..\Common\include\serial.h
+file_017=..\Common\include\flash.h
+file_018=FreeRTOSConfig.h
+file_019=18f452.lkr
 [SUITE_INFO]
 suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
 suite_state=
diff -Nur FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo3.mcp FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo3.mcp
--- FreeRTOSV7.1.0-pristine/Demo/PIC18_MPLAB/rtosdemo3.mcp	2009-08-18 11:38:20.000000000 -0400
+++ FreeRTOSV7.1.0/Demo/PIC18_MPLAB/rtosdemo3.mcp	2012-04-04 13:51:26.000000000 -0400
@@ -6,7 +6,7 @@
 dir_bin=
 dir_tmp=
 dir_sin=
-dir_inc=.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;C:\Devtools\Microchip\MCC18\h;..\Common\include;..\..\Common\include
+dir_inc=C:\Devtools\Microchip\MCC18\h;.;.\include;..\include;..\..\include;..\..\..\include;..\..\Source\include;..\..\..\Source\include;..\Demo\PIC18_MPLAB;..\..\..\Demo\PIC18_MPLAB;..\..\..\..\Demo\PIC18_MPLAB;..\Common\include;..\..\Common\include
 dir_lib=C:\Devtools\Microchip\MCC18\lib
 dir_lkr=
 [CAT_FILTERS]
@@ -36,6 +36,7 @@
 file_017=no
 file_018=no
 file_019=no
+file_020=no
 [FILE_INFO]
 file_000=..\..\Source\tasks.c
 file_001=..\..\Source\queue.c
@@ -45,18 +46,19 @@
 file_005=main3.c
 file_006=..\Common\Minimal\comtest.c
 file_007=..\Common\Minimal\integer.c
-file_008=..\..\Source\portable\MemMang\heap_1.c
+file_008=..\..\Source\portable\MPLAB\PIC18F\heap_1_pic.c
 file_009=ParTest\ParTest.c
-file_010=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
-file_011=..\..\Source\include\task.h
-file_012=..\..\Source\include\list.h
-file_013=..\..\Source\include\portable.h
-file_014=..\..\Source\include\projdefs.h
-file_015=..\..\Source\include\queue.h
-file_016=..\Common\include\serial.h
-file_017=..\Common\include\comtest.h
-file_018=FreeRTOSConfig.h
-file_019=18f452.lkr
+file_010=interrupts.c
+file_011=..\..\Source\portable\MPLAB\PIC18F\portmacro.h
+file_012=..\..\Source\include\task.h
+file_013=..\..\Source\include\list.h
+file_014=..\..\Source\include\portable.h
+file_015=..\..\Source\include\projdefs.h
+file_016=..\..\Source\include\queue.h
+file_017=..\Common\include\serial.h
+file_018=..\Common\include\comtest.h
+file_019=FreeRTOSConfig.h
+file_020=18f452.lkr
 [SUITE_INFO]
 suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
 suite_state=
diff -Nur FreeRTOSV7.1.0-pristine/Source/portable/MPLAB/PIC18F/heap_1_pic.c FreeRTOSV7.1.0/Source/portable/MPLAB/PIC18F/heap_1_pic.c
--- FreeRTOSV7.1.0-pristine/Source/portable/MPLAB/PIC18F/heap_1_pic.c	1969-12-31 19:00:00.000000000 -0500
+++ FreeRTOSV7.1.0/Source/portable/MPLAB/PIC18F/heap_1_pic.c	2012-04-04 13:51:26.000000000 -0400
@@ -0,0 +1,147 @@
+/*
+    FreeRTOS V7.1.0 - Copyright (C) 2011 Real Time Engineers Ltd.
+	
+
+    ***************************************************************************
+     *                                                                       *
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *
+     *    Complete, revised, and edited pdf reference manuals are also       *
+     *    available.                                                         *
+     *                                                                       *
+     *    Purchasing FreeRTOS documentation will not only help you, by       *
+     *    ensuring you get running as quickly as possible and with an        *
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *
+     *    the FreeRTOS project to continue with its mission of providing     *
+     *    professional grade, cross platform, de facto standard solutions    *
+     *    for microcontrollers - completely free of charge!                  *
+     *                                                                       *
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *
+     *                                                                       *
+     *    Thank you for using FreeRTOS, and thank you for your support!      *
+     *                                                                       *
+    ***************************************************************************
+
+
+    This file is part of the FreeRTOS distribution.
+
+    FreeRTOS is free software; you can redistribute it and/or modify it under
+    the terms of the GNU General Public License (version 2) as published by the
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+    >>>NOTE<<< The modification to the GPL is included to allow you to
+    distribute a combined work that includes FreeRTOS without being obliged to
+    provide the source code for proprietary components outside of the FreeRTOS
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+    more details. You should have received a copy of the GNU General Public
+    License and the FreeRTOS license exception along with FreeRTOS; if not it
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained
+    by writing to Richard Barry, contact details for whom are available on the
+    FreeRTOS WEB site.
+
+    1 tab == 4 spaces!
+
+    http://www.FreeRTOS.org - Documentation, latest information, license and
+    contact details.
+
+    http://www.SafeRTOS.com - A version that is certified for use in safety
+    critical systems.
+
+    http://www.OpenRTOS.com - Commercial support, development, porting,
+    licensing and training services.
+*/
+
+
+/*
+ * The simplest possible implementation of pvPortMalloc().  Note that this
+ * implementation does NOT allow allocated memory to be freed again.
+ *
+ * See heap_2.c and heap_3.c for alternative implementations, and the memory
+ * management pages of http://www.FreeRTOS.org for more information.
+ */
+#include <stdlib.h>
+
+/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
+all the API functions to use the MPU wrappers.  That should only be done when
+task.h is included from an application file. */
+#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
+
+#include "FreeRTOS.h"
+#include "task.h"
+
+#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
+
+/* Allocate the memory for the heap. */
+#pragma udata heap
+unsigned char ucHeap[ configTOTAL_HEAP_SIZE ];
+#pragma udata
+
+unsigned char *rom pucHeap = ucHeap;
+
+static size_t xNextFreeByte = ( size_t ) 0;
+/*-----------------------------------------------------------*/
+
+void *pvPortMalloc( size_t xWantedSize )
+{
+void *pvReturn = NULL; 
+
+	/* Ensure that blocks are always aligned to the required number of bytes. */
+	#if portBYTE_ALIGNMENT != 1
+		if( xWantedSize & portBYTE_ALIGNMENT_MASK )
+		{
+			/* Byte alignment required. */
+			xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) );
+		}
+	#endif
+
+	vTaskSuspendAll();
+	{
+		/* Check there is enough room left for the allocation. */
+		if( ( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE ) &&
+			( ( xNextFreeByte + xWantedSize ) > xNextFreeByte )	)/* Check for overflow. */
+		{
+			/* Return the next free byte then increment the index past this
+			block. */
+			pvReturn = pucHeap + xNextFreeByte;
+			xNextFreeByte += xWantedSize;			
+		}	
+	}
+	xTaskResumeAll();
+	
+	#if( configUSE_MALLOC_FAILED_HOOK == 1 )
+	{
+		if( pvReturn == NULL )
+		{
+			extern void vApplicationMallocFailedHook( void );
+			vApplicationMallocFailedHook();
+		}
+	}
+	#endif	
+
+	return pvReturn;
+}
+/*-----------------------------------------------------------*/
+
+void vPortFree( void *pv )
+{
+	/* Memory cannot be freed using this scheme.  See heap_2.c and heap_3.c 
+	for alternative implementations, and the memory management pages of 
+	http://www.FreeRTOS.org for more information. */
+	( void ) pv;
+}
+/*-----------------------------------------------------------*/
+
+void vPortInitialiseBlocks( void )
+{
+	/* Only required when static memory is not cleared. */
+	xNextFreeByte = ( size_t ) 0;
+}
+/*-----------------------------------------------------------*/
+
+size_t xPortGetFreeHeapSize( void )
+{
+	return ( configTOTAL_HEAP_SIZE - xNextFreeByte );
+}
+
+
+
diff -Nur FreeRTOSV7.1.0-pristine/Source/portable/MPLAB/PIC18F/port.c FreeRTOSV7.1.0/Source/portable/MPLAB/PIC18F/port.c
--- FreeRTOSV7.1.0-pristine/Source/portable/MPLAB/PIC18F/port.c	2011-12-13 15:38:24.000000000 -0500
+++ FreeRTOSV7.1.0/Source/portable/MPLAB/PIC18F/port.c	2012-04-04 13:51:26.000000000 -0400
@@ -105,12 +105,6 @@
 enable state to be unchanged when the interrupted task is switched back in. */
 #define portINTERRUPTS_UNCHANGED			0x00
 
-/* Some memory areas get saved as part of the task context.  These memory
-area's get used by the compiler for temporary storage, especially when 
-performing mathematical operations, or when using 32bit data types.  This
-constant defines the size of memory area which must be saved. */
-#define portCOMPILER_MANAGED_MEMORY_SIZE	( ( unsigned char ) 0x13 )
-
 /* We require the address of the pxCurrentTCB variable, but don't want to know
 any details of its type. */
 typedef void tskTCB;
@@ -120,12 +114,10 @@
 #define portBIT_SET		( ( unsigned char ) 1 )
 #define portBIT_CLEAR	( ( unsigned char ) 0 )
 
-/*
- * The serial port ISR's are defined in serial.c, but are called from portable
- * as they use the same vector as the tick ISR.
- */
-void vSerialTxISR( void );
-void vSerialRxISR( void );
+/* Prototype for User ISR Vector */
+#ifdef configPORT_USER_ISR_VECTOR
+void configPORT_USER_ISR_VECTOR(void);
+#endif
 
 /*
  * Perform hardware setup to enable ticks.
@@ -164,10 +156,7 @@
  * 32bit data types are utilised (as they are by the scheduler).  The .tmpdata
  * and MATH_DATA sections have to be stored in there entirety as part of a task
  * context.  This macro stores from data address 0x00 to 
- * portCOMPILER_MANAGED_MEMORY_SIZE.  This is sufficient for the demo 
- * applications but you should check the map file for your project to ensure 
- * this is sufficient for your needs.  It is not clear whether this size is 
- * fixed for all compilations or has the potential to be program specific.
+ * configCOMPILER_MANAGED_MEMORY_SIZE.
  */
 #define	portSAVE_CONTEXT( ucForcedInterruptFlags )								\
 {																				\
@@ -200,31 +189,15 @@
 		MOVFF	PRODL, PREINC1													\
 		MOVFF	PCLATU, PREINC1													\
 		MOVFF	PCLATH, PREINC1													\
-		/* Store the .tempdata and MATH_DATA areas as described above. */		\
+		/* Store the .tmpdata and MATH_DATA areas as described above. */		\
 		CLRF	FSR0L, 0														\
 		CLRF	FSR0H, 0														\
+		MOVLW	configCOMPILER_MANAGED_MEMORY_SIZE								\
+	jTmpdataSaveLoop:															\
 		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	POSTINC0, PREINC1												\
-		MOVFF	INDF0, PREINC1													\
-		MOVFF	FSR0L, PREINC1													\
-		MOVFF	FSR0H, PREINC1													\
+		DECFSZ	WREG, 1, 0														\
+		BRA	jTmpdataSaveLoop													\
+																				\
 		/* Store the hardware stack pointer in a temp register before we		\
 		modify it. */															\
 		MOVFF	STKPTR, FSR0L													\
@@ -298,28 +271,16 @@
 																				\
 	_asm																		\
 		/* Restore the .tmpdata and MATH_DATA memory. */						\
-		MOVFF	POSTDEC1, FSR0H													\
-		MOVFF	POSTDEC1, FSR0L													\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
-		MOVFF	POSTDEC1, POSTDEC0												\
+		CLRF	FSR0H, 0														\
+        MOVLW	configCOMPILER_MANAGED_MEMORY_SIZE								\
+		MOVWF	FSR0L, 0														\
+	jTmpdataRestoreLoop:														\
+		DECF	FSR0L, 1, 0														\
+		BN	jTmpdataRestoreEnd													\
 		MOVFF	POSTDEC1, INDF0													\
+		BRA jTmpdataRestoreLoop													\
+	jTmpdataRestoreEnd:															\
+																				\
 		/* Restore the other registers forming the tasks context. */			\
 		MOVFF	POSTDEC1, PCLATH												\
 		MOVFF	POSTDEC1, PCLATU												\
@@ -456,19 +417,12 @@
 	pxTopOfStack++;
 
 	/* Next the .tmpdata and MATH_DATA sections. */
-	for( ucBlock = 0; ucBlock <= portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
+	for( ucBlock = 0; ucBlock < configCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
 	{
 		*pxTopOfStack = ( portSTACK_TYPE ) ucBlock;
 		*pxTopOfStack++;
 	}
 
-	/* Store the top of the global data section. */
-	*pxTopOfStack = ( portSTACK_TYPE ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */
-	pxTopOfStack++;
-
-	*pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* High. */
-	pxTopOfStack++;
-
 	/* The only function return address so far is the address of the 
 	task. */
 	ulAddress = ( unsigned long ) pxCode;
@@ -548,29 +502,19 @@
 	/* Was the interrupt the tick? */
 	if( PIR1bits.CCP1IF )
 	{		
-		_asm
-			goto prvTickISR
-		_endasm
-	}
-
-	/* Was the interrupt a byte being received? */
-	if( PIR1bits.RCIF )
-	{
-		_asm
-			goto vSerialRxISR
-		_endasm
-	}
-
-	/* Was the interrupt the Tx register becoming empty? */
-	if( PIR1bits.TXIF )
-	{
-		if( PIE1bits.TXIE )
+		if( PIE1bits.CCP1IE )
 		{
 			_asm
-				goto vSerialTxISR
+				goto prvTickISR
 			_endasm
 		}
 	}
+
+#ifdef configPORT_USER_ISR_VECTOR
+	_asm
+		goto configPORT_USER_ISR_VECTOR
+	_endasm
+#endif
 }
 #pragma code
 
