[PicForth] CBank manipulation patch

Alex Moon amoon at steradiantech.com
Wed Feb 9 22:25:28 CET 2005


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)

-------------- next part --------------
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"



More information about the PicForth mailing list