Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forth and processor flags

Tags:

forth

Why doesn't Forth use processor flags for conditional execution?

Instead the result of a comparison is placed on the parameter stack. Is it because the inner interpreter loop may alter flags when going to the next instruction? Or is it simply to abstract conditional logic?

E.g. on x86 the flags register holds results of a comparison as most processors if not all will have a flags register.

like image 731
Daryl Avatar asked Jun 30 '26 11:06

Daryl


1 Answers

As Forth is a stack-based language, in order to define the operations inside the language, you must define the result to alter something that is inside the language. The flags register isn't in the language. Obviously in case of an optimizing compiler, whatever approach that gives the same final result is equally acceptable.

like image 52
George Kourtis Avatar answered Jul 06 '26 16:07

George Kourtis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!