[PicForth] Re: Dumb question - 'code' words and register banks

Samuel Tardieu sam at rfc1149.net
Sun Nov 14 20:20:01 CET 2004


>>>>> "David" == David McNab <david at rebirthing.co.nz> writes:

David> Hi, When writing 'code' words, what's the best/quickest way to
David> insert the appropriate bank-selection (rp0 b[s|c]f, rp1
David> b[s|c]f) instructions before accessing a variable?

You can use "adjust-cbank" between the variable name and the
operation. I don't want it to be automatically adjusted as in assembly
I don't want to generate code that has not been explicitely asked for.

Do not forget to restore the bank after returning, with "0
adjust-cbank drop".

Example:

  code foo
	porta adjust-bank clrf
	eedata adjust-bank clrf
	0 adjust-bank drop
	return
  end-code

It is equivalent to:

  : foo 0 porta ! 0 eedata ! ;

Maybe I should issue a warning when the right bank is not selected
and if the bank is not restored at return. What do you think about it?

  Sam
-- 
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/sam



More information about the PicForth mailing list