0 votes
by Nuno Lopes Ferreira (200 points)
I'm a newbie learning forth and realized when using the 'see' keyword that only rbx is used for the TOS, then the rest is in memory (through rbp). Are these assembly snippets how it is going to look when compiled? If so why aren't more registers(r8-r15) being used, shouldn't it be faster? This is the 64bit version on Windows.

Thanks

1 Answer

0 votes
by Stephen Pelc (3.4k points)

The stack with TOS=RBX and the rest indexed off RBP is called the "canonical stack" and is forced at basic block boundaries. If you look at words that use plenty of stack items, you will see that more registers are used. The following is order in which registers are allocated:
create resource-table   \ -- addr
\ holds available stack resources in preference order
\ deep stack resources are provided automagically
  rRBX ,     rRDX ,     rRCX ,        \ TOS *MUST* be first
  rRAX ,     rR8 ,      rR9 ,
  rR10 ,     rR11 ,     rR12 ,
  0 , 0 ,                             \ ends with a 0

 

...