Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion well formed flag ?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Elizabeth D. Rather  
View profile  
 More options Oct 27 2012, 2:54 pm
Newsgroups: comp.lang.forth
From: "Elizabeth D. Rather" <erat...@forth.com>
Date: Sat, 27 Oct 2012 08:54:10 -1000
Local: Sat, Oct 27 2012 2:54 pm
Subject: Re: well formed flag ?
On 10/27/12 4:59 AM, Chris Hinsley wrote:

> Folks, I'm doing some tweaking to my hobby Forth compiler and just been
> doing some inlineing work.

> I'm not very happy about the size of the x86 code for comparision words
> (I know I could reduce the code size if I had a full optimizing code
> generator, but I don't yet…) this is my code for "<"

>      defword ">", 0, WORD_GT, WORD_INLINE_COMMA
>      POPDSP eax
>      cmp eax, ebx
>      setg bl
>      movzx ebx, bl
>      neg ebx
>      ret
>      defword_end

> I followed the 'well formed flag' comments in Ms Rathers book for this,
> but the IF and TRUE, FALSE words only talk about 0 for false or not zero
> for true. Is it definately the case that Forth needs -1 to come from the
> comparason words ?

> Are you allowed to write code that _needs_ the -1 from the ">" ? ie if
> it produce just a 1, would that be incorrect ?

Yes, the standard (everything since Forth83) provides that the
comparison words return well-formed flags, so they can be used with
things like AND, as masks, etc., even though IF, WHILE, and UNTIL don't
require well-formed flags.

In SwiftForth:
see >
354F   EBX 0 [EBP] CMP                  395D00
3552   0 # EBX MOV                      BB00000000
3557   355A JLE                         7E01
3559   EBX DEC                          4B
355A   4 # EBP ADD                      83C504
355D   RET                              C3 ok

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.