home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / FORTH / QF251.EXE / MEMORY.BLK < prev    next >
Text File  |  1988-05-15  |  10KB  |  1 lines

  1. This file allows allocation and deallocation of memory          using calls to BIOS.                                                                                                            Usage:                                                                                                                             n  ALLOCATE: <name>                                                                                                          where n is the requested memory size in paragraphs                ( ie. n=number of bytes /16 )                                 subsequent usage of <name> leaves the segment address of the      allocated memory.                                                                                                                                                                                                                                                                                                                                                                             \ ALLOCATE MEMORY                                       5 /15/88VISA MEMORY.BLK                                                 CAPS @                                                          CAPS OFF  2 4 THRU  CAPS !                                                                                                      $1000 FOR.ME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    \ MORE MEMORY ALLOCATION                                5 /15/88CODE FOR.ME (S n --  ) \ n=number of paragraphs                    CS PUSH ES POP                                                 $4A # AH MOV $21 INT  BX POP  NEXT END-CODE                                                                                   CODE allocate.memory (S n -- a|e f ) \ n=number of paragraphs     $48 # AH MOV  $21 INT   AX PUSH                                 $73 IF TRUE  # BX MOV                                               ELSE BX BX XOR THEN NEXT END-CODE                                                                                         CODE deallocate (S seg -- e F| T ) \ pass segment to release      ES DX MOV  BX ES MOV $49 # AH MOV    $21 INT                    $73 IF AX PUSH TRUE  # BX MOV                                       ELSE BX BX XOR THEN NEXT END-CODE                                                                                                                                                         \ MORE MEMORY ALLOCATION                                5 /15/88: ALL.ERROR  ( err# -- )  ." Memory allocate error# " . QUIT ;  : ALLOCATE: (S n --  )    \ see screen 0 for usage                 1 ?ENOUGH   allocate.memory                                        IF ( error)  ALL.ERROR                                          ELSE  CONSTANT THEN    ;                                                                                                  : [ALL]  ( n -- )                                                   >R  allocate.memory                                             IF  ( error )  ALL.ERROR   THEN  R> !   ;                                                                                   : [ALLOCATE:]  ' >BODY [COMPILE] LITERAL  COMPILE [ALL]  ;        IMMEDIATE                                                                                                                                                                                                                                                     \ DEALLOCATE MEMORY                                     5 /15/88: DEALLOCATE: ( -- )                                              ' >BODY  DUP @ SWAP OFF ?DUP                                    IF deallocate ABORT" Memory deallocation error" THEN ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                5 /15/88                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        5 /15/88Name this file                                                  Set CAPS to off                                                    and restore when done                                                                                                        only need 64K for kernel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                5 /15/88FOR.ME  allocate the requested # of paragraphs for the current          program                                                                                                                                                                                 allocate.memory ( n -- a/e f )  Allocate the requested n           paragraphs of memory.  Return a true and an address or          a false and an error code.                                                                                                                                                                   deallocate  ( seg -- e False or True ) pass a segment of memory    to release,  return a true or return a false and an error       code.                                                                                                                                                                                                                                                                                                                5 /15/88                                                                see Screen 0 for usage of ALLOCATE:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             [ALLOCATE:] is a version of ALLOCATE: to be used inside a         definition to reserve the next word in the compilation          stream