version 1.192, 2006/04/02 09:18:56
|
version 1.197, 2006/10/21 22:13:48
|
Line 809 n = n1*n2;
|
Line 809 n = n1*n2;
|
|
|
/ ( n1 n2 -- n ) core slash |
/ ( n1 n2 -- n ) core slash |
n = n1/n2; |
n = n1/n2; |
if(FLOORED_DIV && ((n1^n2) < 0) && (n1%n2 != 0)) n--; |
if (CHECK_DIVISION && (n2 == 0)) |
|
throw(-10); |
|
if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN) |
|
throw(-11); |
|
if (FLOORED_DIV && ((n1^n2) < 0) && (n1%n2 != 0)) |
|
n--; |
: |
: |
/mod nip ; |
/mod nip ; |
|
|
mod ( n1 n2 -- n ) core |
mod ( n1 n2 -- n ) core |
n = n1%n2; |
n = n1%n2; |
|
if (CHECK_DIVISION && (n2 == 0)) |
|
throw(-10); |
|
if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN) |
|
throw(-11); |
if(FLOORED_DIV && ((n1^n2) < 0) && n!=0) n += n2; |
if(FLOORED_DIV && ((n1^n2) < 0) && n!=0) n += n2; |
: |
: |
/mod drop ; |
/mod drop ; |
Line 822 if(FLOORED_DIV && ((n1^n2) < 0) && n!=0)
|
Line 831 if(FLOORED_DIV && ((n1^n2) < 0) && n!=0)
|
/mod ( n1 n2 -- n3 n4 ) core slash_mod |
/mod ( n1 n2 -- n3 n4 ) core slash_mod |
n4 = n1/n2; |
n4 = n1/n2; |
n3 = n1%n2; /* !! is this correct? look into C standard! */ |
n3 = n1%n2; /* !! is this correct? look into C standard! */ |
|
if (CHECK_DIVISION && (n2 == 0)) |
|
throw(-10); |
|
if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN) |
|
throw(-11); |
if (FLOORED_DIV && ((n1^n2) < 0) && n3!=0) { |
if (FLOORED_DIV && ((n1^n2) < 0) && n3!=0) { |
n4--; |
n4--; |
n3+=n2; |
n3+=n2; |
Line 1647 n=1;
|
Line 1660 n=1;
|
\g hostos |
\g hostos |
|
|
key-file ( wfileid -- c ) gforth paren_key_file |
key-file ( wfileid -- c ) gforth paren_key_file |
""Read one character @i{c} from @i{wfileid}. "" |
""Read one character @i{c} from @i{wfileid}. This word disables |
|
buffering for @i{wfileid}. If you want to read characters from a |
|
terminal in non-canonical (raw) mode, you have to put the terminal in |
|
non-canonical mode yourself (using the C interface); the exception is |
|
@code{stdin}: Gforth automatically puts it into non-canonical mode."" |
#ifdef HAS_FILE |
#ifdef HAS_FILE |
fflush(stdout); |
fflush(stdout); |
c = key((FILE*)wfileid); |
c = key((FILE*)wfileid); |
Line 1657 c = key(stdin);
|
Line 1674 c = key(stdin);
|
|
|
key?-file ( wfileid -- f ) gforth key_q_file |
key?-file ( wfileid -- f ) gforth key_q_file |
""@i{f} is true if at least one character can be read from @i{wfileid} |
""@i{f} is true if at least one character can be read from @i{wfileid} |
without blocking."" |
without blocking. If you also want to use @code{read-file} or |
|
@code{read-line} on the file, you have to call @code{key?-file} or |
|
@code{key-file} first (these two words disable buffering)."" |
#ifdef HAS_FILE |
#ifdef HAS_FILE |
fflush(stdout); |
fflush(stdout); |
f = key_query((FILE*)wfileid); |
f = key_query((FILE*)wfileid); |
Line 1668 f = key_query(stdin);
|
Line 1687 f = key_query(stdin);
|
\+os |
\+os |
|
|
stdin ( -- wfileid ) gforth |
stdin ( -- wfileid ) gforth |
|
""The standard input file of the Gforth process."" |
wfileid = (Cell)stdin; |
wfileid = (Cell)stdin; |
|
|
stdout ( -- wfileid ) gforth |
stdout ( -- wfileid ) gforth |
|
""The standard output file of the Gforth process."" |
wfileid = (Cell)stdout; |
wfileid = (Cell)stdout; |
|
|
stderr ( -- wfileid ) gforth |
stderr ( -- wfileid ) gforth |
|
""The standard error output file of the Gforth process."" |
wfileid = (Cell)stderr; |
wfileid = (Cell)stderr; |
|
|
form ( -- urows ucols ) gforth |
form ( -- urows ucols ) gforth |
Line 2689 w = ffi_prep_closure((ffi_closure *)a_cl
|
Line 2711 w = ffi_prep_closure((ffi_closure *)a_cl
|
|
|
ffi-2@ ( a_addr -- d ) gforth ffi_2fetch |
ffi-2@ ( a_addr -- d ) gforth ffi_2fetch |
#ifdef BUGGY_LONG_LONG |
#ifdef BUGGY_LONG_LONG |
DLO_IS(d, (Cell*)(*a_addr)); |
DLO_IS(d, *(Cell*)(*a_addr)); |
DHI_IS(d, 0); |
DHI_IS(d, 0); |
#else |
#else |
d = *(DCell*)(a_addr); |
d = *(DCell*)(a_addr); |
Line 2705 ffi-2! ( d a_addr -- ) gforth ffi_2store
|
Line 2727 ffi-2! ( d a_addr -- ) gforth ffi_2store
|
ffi-arg-int ( -- w ) gforth ffi_arg_int |
ffi-arg-int ( -- w ) gforth ffi_arg_int |
w = *(int *)(*gforth_clist++); |
w = *(int *)(*gforth_clist++); |
|
|
|
ffi-arg-long ( -- w ) gforth ffi_arg_long |
|
w = *(long *)(*gforth_clist++); |
|
|
ffi-arg-longlong ( -- d ) gforth ffi_arg_longlong |
ffi-arg-longlong ( -- d ) gforth ffi_arg_longlong |
#ifdef BUGGY_LONG_LONG |
#ifdef BUGGY_LONG_LONG |
DLO_IS(d, (Cell*)(*gforth_clist++)); |
DLO_IS(d, *(Cell*)(*gforth_clist++)); |
DHI_IS(d, 0); |
DHI_IS(d, -(*(Cell*)(*gforth_clist++)<0)); |
#else |
#else |
d = *(DCell*)(*gforth_clist++); |
d = *(DCell*)(*gforth_clist++); |
#endif |
#endif |
|
|
|
ffi-arg-dlong ( -- d ) gforth ffi_arg_dlong |
|
#ifdef BUGGY_LONG_LONG |
|
DLO_IS(d, *(Cell*)(*gforth_clist++)); |
|
DHI_IS(d, -(*(Cell*)(*gforth_clist++)<0)); |
|
#else |
|
d = *(Cell*)(*gforth_clist++); |
|
#endif |
|
|
ffi-arg-ptr ( -- c_addr ) gforth ffi_arg_ptr |
ffi-arg-ptr ( -- c_addr ) gforth ffi_arg_ptr |
c_addr = *(Char **)(*gforth_clist++); |
c_addr = *(Char **)(*gforth_clist++); |
|
|
Line 2737 ffi-ret-longlong ( d -- ) gforth ffi_ret
|
Line 2770 ffi-ret-longlong ( d -- ) gforth ffi_ret
|
#endif |
#endif |
return 0; |
return 0; |
|
|
|
ffi-ret-dlong ( d -- ) gforth ffi_ret_dlong |
|
#ifdef BUGGY_LONG_LONG |
|
*(Cell*)(gforth_ritem) = DLO(d); |
|
#else |
|
*(Cell*)(gforth_ritem) = d; |
|
#endif |
|
return 0; |
|
|
|
ffi-ret-long ( n -- ) gforth ffi_ret_long |
|
*(Cell*)(gforth_ritem) = n; |
|
return 0; |
|
|
ffi-ret-ptr ( c_addr -- ) gforth ffi_ret_ptr |
ffi-ret-ptr ( c_addr -- ) gforth ffi_ret_ptr |
*(Char **)(gforth_ritem) = c_addr; |
*(Char **)(gforth_ritem) = c_addr; |
return 0; |
return 0; |