CBank manipulation patch

Alex Moon <[email protected]> Wed, 09 Feb 2005 16:25:28 -0500
Newsgroups gmane.comp.lang.forth.picforth
Organization Steradian Technologies, LLC
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------020008000700020806020600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I've run into a few problems with a large (> 0x800 words) program not 
having the cbank bits always set correctly.  The attached patch fixed 
the problems for me.  I'm not sure if it's the best way to go about it, 
but it seemed to solve the problems in my case.

-- 
Alex R. Moon
Vice President
Steradian Technologies, LLC (http://www.steradiantech.com)


--------------020008000700020806020600
Content-Type: text/plain;
 name="cbank.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cbank.diff"

diff -ru orig/picforth.fs ./picforth.fs
--- orig/picforth.fs	2004-12-29 07:31:50.000000000 -0500
+++ ./picforth.fs	2005-02-09 15:50:29.875000000 -0500
@@ -1074,12 +1074,14 @@
 : set-cbank ( addr -- )
     \ If target is in bank 0, clear PCLATH
     cbank dup 0= if drop pclath clrf 0 current-cbank ! exit then
+    dup
     \ If current known bank is invalid, everything is wrong
     current-cbank @ -1 = if dup invert current-cbank ! then
     \ If current address is in bank 0 or 1, clear one bit
     tcshere cbank 2 < if current-cbank @ $d and current-cbank ! then
     \ Change only the right bits
     dup 0 set-cbank-bit 1 set-cbank-bit
+    current-cbank !
 ;
 
 : manipulate-cbank ( addr -- )
@@ -1985,7 +1987,7 @@
 \ reference.
 : backref ( -- BACKWARDMARK baddr ) BACKWARDMARK tcshere no-opt no-cbank ;
 
-: begin ( -- 0 BACKWARDMARK baddr ) 0 backref ;
+: begin ( -- 0 BACKWARDMARK baddr ) 0 backref tcshere manipulate-cbank ;
 
 : again ( 0 BACKWARDMARK baddr -- )
     swap BACKWARDMARK <> abort" Nested statements problem"


--------------020008000700020806020600
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PicForth mailing list
[email protected]
http://lists.rfc1149.net/mailman/listinfo/picforth

--------------020008000700020806020600--