mirror of
https://github.com/nineties/planckforth
synced 2024-12-25 21:58:22 +01:00
commit
6050e60671
3 changed files with 13 additions and 1 deletions
10
bootstrap.fs
10
bootstrap.fs
|
@ -2399,6 +2399,9 @@ BLOCK-SIZE remaining-size !
|
|||
then
|
||||
;
|
||||
|
||||
\ Bootstrapping version of free do nothing.
|
||||
: (free) ( addr -- ) ;
|
||||
|
||||
( === File I/O === )
|
||||
|
||||
3 constant SYS-READ
|
||||
|
@ -2440,11 +2443,16 @@ BLOCK-SIZE remaining-size !
|
|||
( === Heap Memory === )
|
||||
|
||||
need-defined (allocate)
|
||||
need-defined (free)
|
||||
|
||||
: allocate ( size -- addr e )
|
||||
(allocate) dup 0<> if success else ALLOCATE-ERROR then
|
||||
;
|
||||
|
||||
: free ( addr -- )
|
||||
(free)
|
||||
;
|
||||
|
||||
\ allocate heap memory
|
||||
: %allocate ( align size -- addr e )
|
||||
over + allocate ?dup unless
|
||||
|
@ -2604,7 +2612,7 @@ need-defined (read)
|
|||
2rot -2rot 2tuck 2over 2nip 2swap 2dup 2drop 3dup 3drop depth
|
||||
rp0 rp@ rp! r> >r r@ rdrop rpick rdepth
|
||||
|
||||
allocate allot memcpy strlen streq strneq strcpy strcpy,
|
||||
allocate free allot memcpy strlen streq strneq strcpy strcpy,
|
||||
cell cell+ cell- cells char+ char- chars align aligned +! -!
|
||||
|
||||
if else then unless begin until again while repeat
|
||||
|
|
|
@ -207,5 +207,6 @@ defcode("(allocate)", allocate) {
|
|||
push((cell) p);
|
||||
next();
|
||||
}
|
||||
defcode("(free)", free_) { free((void*) pop()); }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -281,7 +281,10 @@ def allocate():
|
|||
addr = len(memory) * CELL
|
||||
memory.extend([0]*n)
|
||||
push(addr)
|
||||
def free():
|
||||
pop() # Bootstrap version do nothing
|
||||
add_simple_operator('(allocate)', allocate)
|
||||
add_simple_operator('(free)', free)
|
||||
|
||||
start = read(HERE_CELL)
|
||||
comma(find('k'))
|
||||
|
|
Loading…
Reference in a new issue