gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] definition of '+place' in <other.fs>


From: Bernd Paysan
Subject: Re: [gforth] definition of '+place' in <other.fs>
Date: Sun, 10 Nov 2013 14:46:52 +0100
User-agent: KMail/4.10.5 (Linux/3.7.10-1.16-desktop; KDE/4.10.5; x86_64; ; )

Am Sonntag, 10. November 2013, 03:15:59 schrieb Marcos Cruz:
> I've realized '+place' is defined in two different files and ways.  'see
> +place' shows the actual definition is that of <cross.fs>; the second
> 
> definition is in <other.fs>:
> : +place ( adr len adr )
> 
>         2dup c@ + over c!
>         dup c@ char+ + swap move ;
> 
> I discovered it doesn't work fine.

Yes, that's broken.  It first updates the count and then uses the updated 
count...  apparently nobody uses +PLACE, except in cross (which is the reason 
why the definition there works ;-).

> At first sight the fixed definition of <other.fs> seems faster, with
> 
> less stack operations:
> : +place ( ca1 len1 ca2 )
> 
>   2dup c@ dup >r  + over c!  r> char+ +  swap move
>   ;

Yes, this works.  Fixed.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]