home .. forth .. colorforth mail list archive ..

RE: [colorforth] FS/Forth for DOS: crude performance test


>
>> Just curious why all this XCHGing is required.
>
>It's because the x86 only has one stack pointer, but Forth requires two stacks.
> So to manipulate the data stack with PUSH and POP instructions, the data stack
>pointer must appear in the SP register.  But when invoking colon definitions,
>the return stack pointer must be in SP.
>

Ahh, it makes sense now. I was using BP as my PSP (data/parameter stack 
pointer), and the primitives explicitly move the pointer:

Top of stack cached in AX.

: AND   AND AX,[BP]  INC BP  INC BP ;

: DUP   DEC BP  DEC BP  MOV [BP],AX  ;

: DROP   MOV AX,[BP]  INC BP  INC BP ;

etc. 

Not the most efficient way, I guess, but it seemed straightforward and easy
to understand, which was the goal. Optimization will come later... I'm still
calling the primitives rather than inlining to keep the compiler simple.

It sounds interesting to use PUSH/POP on both stacks, I'll have to look into 
that.

Thanks for the explanation.

-Lonnie  

 


---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com