diff --git a/ueforth/common/opcodes.h b/ueforth/common/opcodes.h index 48e4946..f0e03fa 100644 --- a/ueforth/common/opcodes.h +++ b/ueforth/common/opcodes.h @@ -35,8 +35,10 @@ typedef uint64_t udcell_t; X("OVER", OP_OVER, DUP; tos = sp[-1]) \ X("DROP", OP_DROP, DROP) \ X("@", OP_AT, tos = *(cell_t *) tos) \ + X("L@", OP_LAT, tos = *(int32_t *) tos) \ X("C@", OP_CAT, tos = *(uint8_t *) tos) \ X("!", OP_STORE, *(cell_t *) tos = *sp; --sp; DROP) \ + X("L!", OP_LSTORE, *(int32_t *) tos = *sp; --sp; DROP) \ X("C!", OP_CSTORE, *(uint8_t *) tos = *sp; --sp; DROP) \ X("FILL", OP_FILL, memset((void *) sp[-1], tos, *sp); sp -= 2; DROP) \ X("MOVE", OP_MOVE, memmove((void *) sp[-1], (void *) *sp, tos); sp -= 2; DROP) \ diff --git a/ueforth/plan.txt b/ueforth/plan.txt index 1c9bff6..a815e03 100644 --- a/ueforth/plan.txt +++ b/ueforth/plan.txt @@ -47,7 +47,7 @@ CORE 0= 0< + UM/MOD */MOD AND OR XOR DUP SWAP OVER DROP -@ C@ ! C! FILL MOVE +@ L@ C@ ! L! C! FILL MOVE SP@ SP! RP@ RP! >R R> R@ EXECUTE BRANCH 0BRANCH DONEXT DOLIT ALITERAL CELL diff --git a/ueforth/posix/posix.fs b/ueforth/posix/posix.fs index 17d39bf..2860d44 100644 --- a/ueforth/posix/posix.fs +++ b/ueforth/posix/posix.fs @@ -21,6 +21,12 @@ z" write" 3 sysfunc write z" lseek" 3 sysfunc lseek z" exit" 1 sysfunc sysexit z" fork" 0 sysfunc fork +z" mmap" 6 sysfunc mmap +z" munmap" 2 sysfunc munmap + +( Errno ) +z" __errno_location" 0 sysfunc __errno_location +: errno ( -- n ) __errno_location l@ ; ( Default Pipes ) 0 constant stdin @@ -56,3 +62,13 @@ z" fork" 0 sysfunc fork : posix-bye 0 sysexit ; ' posix-bye is bye +( I/O Error Helpers ) +: 0ior ( n -- n ior ) dup 0= if errno else 0 then ; + +( Words with OS assist ) +z" malloc" 1 sysfunc malloc +z" free" 1 sysfunc sysfree +z" realloc" 2 sysfunc realloc +: allocate ( n -- a ior ) malloc 0ior ; +: free ( a -- ior ) sysfree 0 ; +: resize ( a n -- a ior ) realloc 0ior ;