fm/mod   m*   sm/rem

fm/mod ( d1 n1 -- n2 n3 )

Floored 32/16 -> 16-bit division

: fm/mod ( d1 n1 -- n2 n3 )
    dup >r
    2dup xor >r
    >r
    dabs r@ abs um/mod
    swap r> ?negate swap
    r> 0< if
        negate
        over if
            r@ rot - swap 1-
        then
    then
    r> drop
  ;

m* ( n1 n2 -- d )

Signed 16*16->32 multiply

: m*  ( n1 n2 -- d )
    2dup xor >r
    abs swap abs um*
    r> ?dnegate
  ;

sm/rem ( d1 n1 -- n2 n3 )

Symmetric 32/16 -> 16 bit division

: sm/rem ( d1 n1 -- n2 n3 )
    2dup xor >r over >r
    abs >r dabs r> um/mod
    swap r> ?negate
    swap r> ?negate
  ;