\ the basis for local variables
\ -----

\ the minimum required support set seems to be:
\ n>r ( push n values to the return stack)
\ nr@ ( get the nth item from the return stack)
\ nr! ( replace the nth item on the return stack)

\ code n>r already exists

code nr@ ( n -- n )
      bx bx add                         \ times 2
      bx bx add                         \ times 4
      bp bx add                         \ address of item
  0 [bx] bx mov                         \ get item
            end-code

code nr! ( n n -- n )            
      bx bx add                         \ times 2
      bx bx add                         \ times 4
      bp bx add                         \ address of item
         ax pop                         \ get item
  ax 0 [bx] mov                         \ write item
         bx pop
            end-code

: test ( a b c -- d )
   3 n>r
   0 nr@ .
   1 nr@ .
   2 nr@ .
   3 nr@ .
   4 nr@ .
   nr> drop ;
   

: try
   3 n>r
   1 nr@ 2 nr@ + 3 nr!
   nr> drop ;