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

Re: High Level Definition for U*/

From: Anthony Senerchia <asenerchia_at_gmail.com>
Date: Thu, 08 Nov 2007 13:22:40 +0100

\ U*/ is an unsigned */ with the twist of rounding up. It adds
\ one less than the divisor to the dividend before dividing.
 
CODE U*/ ( u1 u2 u3 - u)
   0 [EBP] EDX MOV \ get u2
   4 [EBP] EAX MOV \ and u1
   EDX MUL \ u1 * u2
   EBX DEC \
   EBX EAX ADD \ round up
   0 # EDX ADC \
   EBX INC \
   EBX DIV \ do divide
   EAX EBX MOV \ return quotient in tos
   8 # EBP ADD \ clean up stack
   RET END-CODE

Sorry I can't be of more help...

A. Senerchia

Bee 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 - 04:23:36 PST

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