programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: High Level Definition for U*/

From: Bob Nash <bob.nash1_at_gmail.com>
Date: Thu, 8 Nov 2007 10:52:34 -0800

Many thanks. That seems to work fine. There is one LSB difference
between the GForth calculation and the Swift Forth calculation. As
the calculation produces a 28-bit result to be loaded (via SPI) into a
Direct Digital Synthesis chip, the difference is inconsequential.

Just in case anybody out there needs to calculate a DDS tuning word
for the Analog Devices AD9833 chip (or others in this family), here is
the definition I use (courtesy of Charley Shattuck of Intellasys):

    268435456 constant 2^28
    24574507 constant freq \ 24.57 MHz clock input to MCLK
\ : u*/mod ( u1 u2 -- r q ) >r um* r> um/mod ; \ GForth only
\ : u*/ ( u1 u2 u3 -- q ) u*/mod nip ; \ GForth only
    : (hz) ( n1 - n2) 2^28 freq u*/ ;
    : hz ( freq -) (hz) hex . decimal ;

\ Usage: 25000 hz --> 42ABC (SF) or 42ABB (GForth)

P.S. I haven't had the time to test the CODE definition so kindly
transmitted by Anthony Senerechia, but I must admit it caused some
embarrassment: it didn't occur to me that both SwiftForth and GForth
use the same Intel processor (perhaps not the same register
assignments for Forth, but still ...). The CODE definition is
probably the better way to go.

On Nov 7, 2007 6:31 PM, Bee <200309_at_scshop.com> wrote:
>
>
> On Nov 7, 2007, at 12:36 PM, Bob Nash wrote:
>
> > I need a high level definition for U*/. The SF definition is a code
> > definition. I need something that will transport to GForth (Linux).
>
> Hello Bob
>
> I have not a U*/ in the eforth library, I have:
>
> : M* ( n n -- d )( 6.1.1810 )
> 2DUP XOR 0< >R ABS SWAP ABS UM* R> IF DNEGATE THEN ;
> : M/ ( d n -- q ) FM/MOD NIP ;
>
> : */MOD ( n n n -- r q )( 6.1.0110 ) >R M* R> FM/MOD ;
> : */ ( n n n -- q )( 6.1.0100 ) */MOD NIP ;
>
> I suspect if something like this may work:
>
> : u*/mod ( u u u -- r q ) >r um* r> um/mod ;
> : u*/ ( u u u -- q ) u*/mod nip ;
>
> But I may be wrong.
>
> --
> Bill Muench
> Santa Cruz, California
>
>
> ----------------------------------------------------------------------
> sftalk_at_forth.com The SwiftForth programming discussion email list
> To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
> For list command help, send subject "help" to sftalk-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/sftalk
> ----------------------------------------------------------------------
> This list is a forum for SwiftForth users. For product support and
> bug reports, please send email to support_at_forth.com
> ----------------------------------------------------------------------
>
>

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Nov 08 2007 - 10:53:23 PST

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:43 PST