GEMDOS.TXT

From Atari Wiki
Revision as of 14:24, 16 December 2023 by Olivier.jan (talk | contribs)
Jump to navigation Jump to search

INCOMPLETE CHECK FRENCH VERSION 


   ***-------------- FUNCTIONS GEMDOS BY NUMBER ---------------***

   $00      Pterm0    Terminate process
   $01      Cconin    Read a character from standard input
   $02      Cconout   Write a character to standard output
   $03      Cauxin    Read a character from AUX: standard input
   $04      Cauxout   Write a character to AUX: standard output
   $05      Cprnout   Write a character to PRN: standard output
   $06      Crawio    Raw input/output on standard input/output
   $07      Crawcin   Raw input on standard input
   $08      Cnecin    Read a character from standard input without echo
   $09      Cconws    Write a string to standard output
   $0A      Cconrs    Read a formatted string from standard input
   $0B      Cconis    Test standard input status
   $0E      Dsetdrv   Set default disk drive
   $10      Cconos    Test standard output status
   $11      Cprnos    Test PRN: standard output status
   $12      Cauxis    Test AUX: standard input status
   $13      Cauxos    Test AUX: standard output status
   $19      Dgetdrv   Get default disk drive
   $1A      Fsetdta   Set Disk Transfer Address (DTA) address
   $20      Super     Enter/Exit/Inquire Supervisor mode
   $2A      Tgetdate  Inquire date
   $2B      Tsetdate  Set date
   $2C      Tgettime  Inquire time
   $2D      Tsettime  Set time
   $2F      Fgetdta   Inquire Disk Transfer Address (DTA) address
   $30      Sversion  Inquire GEMDOS version number
   $31      Ptermres  Terminate resident program
   $36      Dfree     Inquire free space on a disk
   $39      Dcreate   Create a subdirectory
   $3A      Ddelete   Delete a subdirectory
   $3B      Dsetpath  Set current directory
   $3C      Fcreate   Create a file
   $3D      Fopen     Open a file
   $3E      Fclose    Close a file
   $3F      Fread     Read from a file
   $40      Fwrite    Write to a file
   $41      Fdelete   Delete a file
   $42      Fseek     Set file position
   $43      Fattrib   Inquire/Set file attributes
   $45      Fdup      Duplicate file handle id
   $46      Fforce    Force file handle
   $47      Dgetpath  Inquire current directory
   $48      Malloc    Allocate memory
   $49      Mfree     Free memory
   $4A      Mshrink   Shrink allocated memory block
   $4B      Pexec     Load/Execute a program
   $4C      Pterm     Terminate a program
   $4E      Fsfirst   Search for the first occurrence of a file
   $4F      Fsnext    Search for the next occurrence
   $56      Frename   Rename a file
   $57      Fdatime   Set/Inquire file creation date and time


   ***-------------- GEMDOS FUNCTIONS BY NAME ----------------------***

   $03      Cauxin    Read a character from AUX: standard input
   $12      Cauxis    Test AUX: standard input status
   $13      Cauxos    Test AUX: standard output status
   $04      Cauxout   Write a character to AUX: standard output
   $01      Cconin    Read a character from standard input
   $0B      Cconis    Test standard input status
   $10      Cconos    Test standard output status
   $02      Cconout   Write a character to standard output
   $0A      Cconrs    Read a formatted string from standard input
   $09      Cconws    Write a string to standard output
   $08      Cnecin    Read a character from standard input without echo
   $11      Cprnos    Test PRN: standard output status
   $05      Cprnout   Write a character to PRN: standard output
   $07      Crawcin   Raw input on standard input
   $06      Crawio    Raw input/output on standard input/output
   $39      Dcreate   Create a subdirectory
   $3A      Ddelete   Delete a subdirectory
   $36      Dfree     Inquire free space on a disk
   $19      Dgetdrv   Get default disk drive
   $47      Dgetpath  Inquire current directory
   $0E      Dsetdrv   Set default disk drive
   $3B      Dsetpath  Set current directory
   $43      Fattrib   Inquire/Set file attributes
   $3E      Fclose    Close a file
   $3C      Fcreate   Create a file
   $57      Fdatime   Set/Inquire file creation date and time
   $41      Fdelete   Delete a file
   $45      Fdup      Duplicate file handle id
   $46      Fforce    Force file handle
   $2F      Fgetdta   Inquire Disk Transfer Address (DTA) address
   $3D      Fopen     Open a file
   $3F      Fread     Read from a file
   $56      Frename   Rename a file
   $42      Fseek     Set file position
   $1A      Fsetdta   Set Disk Transfer Address (DTA) address
   $4E      Fsfirst   Search for the first occurrence of a file
   $4F      Fnext     Search for the next occurrence
   $40      Fwrite    Write to a file
   $48      Malloc    Allocate memory
   $49      Mfree     Free memory
   $4A      Mshrink   Shrink allocated memory block
   $4B      Pexec     Load/Execute a program
   $4C      Pterm     Terminate a program
   $00      Pterm0    Terminate a program (return code 0)
   $31      Ptermres  Terminate a resident program
   $20      Super     Enter/Exit/Inquire Supervisor mode
   $30      Sversion  Inquire GEMDOS version number
   $2A      Tgetdate  Inquire date
   $2C      Tgettime  Inquire time
   $2B      Tsetdate  Set date
   $2D      Tsettime  Set time

   *------------------------------------------------------------------*
   $00      Pterm0    Terminate a program

        void Pterm0()

   Terminate a process, closing all files it has opened and releasing
   the memory it has allocated. Returns $0000 as the exit code to the
   parent program.
   *------------------------------------------------------------------*
   $01  Cconin    Read a character from standard input

        LONG Cconin()
     
   Read a character from standard input (identifier 0). If the standard
   input is the console, the long word returned in D0 contains the ASCII
   code and the keyboard code of the pressed key (scan code):

          ________________________________________________
         | 31..24      | 23.. 16   |  15..8   |   7..0    |
         |-------------|-----------|----------|-----------|
         |             |  scan code|   $00    | character |
         | $00 or bits | or $00    |          | ASCII     |
         | of shift    | or $00    |          |           |
         |_____________|___________|__________|___________|

   Function keys (F1 to F10, HELP, UNDO, etc...) return ASCII code $00
   with the appropriate keyboard code (see the intelligent keyboard
   manual for the key codes). The ST BIOS places the state of special
   keys in bits 24 to 31 (see the ST BIOS programmer's guide for more
   details).

   ERRORS
        Does not return any indication of end of file.
        Does not recognize 'Control_C'
        Impossible to know if the input is a character device or a file.
        There should be a way to type the 256 possible codes from the
        keyboard.
   *------------------------------------------------------------------*
   $02 Cconout   Write a character to the standard output
        void  Cconout(c)
        WORD c
   Write the character 'c' to the standard output (identifier 0).
   The eight most significant bits of 'c' are reserved and must be zero.
   Tabs are not interpreted.
   *------------------------------------------------------------------*
   $03 Cauxin    Read a character from AUX: standard input

        WORD Cauxin()

   Read a character from identifier 1 (the AUX: serial port, usually).

   NOTE
        Output flow control of the RS232 does not work with this
        function. Programs should use the BIOS character device call
        to avoid losing received characters.
   *------------------------------------------------------------------*
   $04 Cauxout   Write a character to the AUX: standard output
        void Cauxout(c)
        WORD c

   *------------------------------------------------------------------*
   $05 Cprnout   Write a character to the PRN: standard output
        void Cprnout(c)
        WORD c

   Write 'c' to identifier 2 (the PRN: printer port, usually). The high
   bits of 'c' are reserved and must be zero. Tabs are not interpreted.

   *------------------------------------------------------------------*
   $06 Crawio    Raw input/output on standard input/output
        LONG Crawio(w)
        WORD w;

   NOTES
        By its very design this function cannot write '$ff' to the
        standard output.
        $00 cannot be differentiated from an end of file.
   *------------------------------------------------------------------*
   $07 Crawcin   Raw input on standard input
        LONG Crawcin()

   NOTE     No end of file indication.
   *------------------------------------------------------------------*
   $08 Cnecin    Read a character from standard input without echo
        LONG Cnecin()

   Read a character from standard input. If the input device is 'CON:',
   no echo is made. Control characters are interpreted.
   *------------------------------------------------------------------*
   $09 Cconws    Write a string to standard output
        void Cconws(string)
        char *string;
   Write a string starting from 'string' and ending with 0, to the
   standard output.
   *------------------------------------------------------------------*
   $0A Cconrs    Read a formatted string from standard input
        void Cconrs(buf)
        char *buf
   Read a string from standard input. The usual control characters are
   interpreted:

                   ____________________________________________
                  | Character   |    Function                |
                  |-------------|-----------------------------|
                  | <return>, ^J | End of line                |
                  |   ^H, <rub>  | Erase last character        |
                  |   ^U, ^X     | Erase entire line          |
                  |      ^R      | Recopy line                |
                  |      ^C      | End program                |
                  |______________|_____________________________|

   The first character of 'buf' contains the maximum number of bytes to
   read (buffer size minus two). On output, the second byte contains
   the number of characters read. The string is located between 'buf+2'
   and 'buf+2+buf[1]'. It is not guaranteed that the string ends with 0.

   NOTE     Crashes on end of files.
   *------------------------------------------------------------------*
   $0B Cconis    Test standard input status
        WORD Cconis()
   Returns $FFFF if a character is available on standard input, $0000
   otherwise.
   *------------------------------------------------------------------*
   $0E Dsetdrv   Set default disk drive
        LONG Dsetdrv(drv)
        WORD drv;
   Set disk 'drv' as the default. Drives are numbered 0 to 15 (A: to P:).
   Returns in D0.L the bitmap of active drives:
           (bit 0 = A, bit 1 = B, etc..).

   An 'active drive' is a drive from which a directory has been made.

   NOTE GEMDOS only supports 16 drives (bits 0 to 15). Future systems will
   support 32 .
   *------------------------------------------------------------------*
   $10 Cconos    Test standard output status
        WORD Cconos()

   Returns $FFFF if the console is ready to receive a character,
   $0000 if the console is NOT ready.
   *------------------------------------------------------------------*
   $11 Cprnos    Test PRN: standard output status
        WORD Cprnos()
   Returns $FFFF if 'PRN:' is ready to receive a character, $0000
   otherwise.
   *------------------------------------------------------------------*
   $12 Cauxis    Test AUX: standard input status
        WORD Cauxis()
   Returns $FFFF if a character is available on 'AUX:' input (identifier 1),
   $0000 otherwise.
   *------------------------------------------------------------------*
   $13 Cauxos    Test AUX: standard output status
        WORD Cauxos()
   Returns $FFFF if 'AUX:' (identifier 1) is ready to receive a
   character, $0000 otherwise.
   *------------------------------------------------------------------*
   $19 Dgetdrv   Get default disk drive
        WORD Dgetdrv()
   Returns the number of the current drive, ranging from 0 to 15.
   *------------------------------------------------------------------*
   $1A Fsetdta   Set Disk Transfer Address (DTA) address
        void Fsetdta(adr)
        char adr;
   Sets the DTA address to 'adr'. The data storage buffer on a file (DTA)
   is only used by the functions Fsfirst() and Fsnext().
   *------------------------------------------------------------------*
   $20 Super     Enter/Exit/Inquire Supervisor mode
        LONG Super(stack)
        WORD *stack;
        'stack' is equal to -1L ($FFFFFFFF):
   the function returns $0000 if the processor is in User mode, $0001 if
   it is in Supervisor mode.

   'stack' is different from -1L:
        if the processor is in User mode, the function returns
        to Supervisor mode. If 'stack' is NUL ($00000000), the
        supervisor stack will be the same as the user stack before
        the call. Otherwise the supervisor stack will be placed at 'stack'.

        if the processor was in Supervisor mode, it returns
        to User mode after the function call. 'stack' must be the value
        of the user stack that was returned by the first function call.

   ATTENTION
        The original Supervisor stack must be replaced before the end
        of the program, otherwise the system will crash on program exit.

   *------------------------------------------------------------------*
   $2A Tgetdate  Inquire date
        WORD Tgetdate()

   Returns the date in DOS format:

        15 __________________9_8_________5_4_________0 
        |  Years since 1980 |   month   |   day     |
        |      0.....119     |  1...12   |  1...31   |
        |____________________|___________|___________|

   RETURN
        bits 0 to 4 contain the day from 1 to 31.
        bits 5 to 8 contain the month from 1 to 12.
        bits 9 to  15 contain the year (from 1980 onward)
        ranging from 0 to 119.
   *------------------------------------------------------------------*
   $2B Tsetdate  Set date
        WORD Tsetdate(date)
        WORD date;
   Set 'date' as the current date in the format described in
   Tgetdate().

   RETURN   0 if the date is valid.
            ERROR if the date format is incorrect.

   NOTE
        GEMDOS is not picky about the date; for instance, February 31 does
        not bother it.
        GEMDOS does NOT notify BIOS that the date has changed.
   *------------------------------------------------------------------*
   $2C Tgettime  Inquire time
        WORD Tgettime()

   Returns the current time in DOS format:

              15__________11_10________5_4__________0
             |    hour      |   minute  |   second   |
             |   0...23     |   0...59  |   0...28   |
             |______________|___________|____________|

   RETURN    Bits :
        0 to 4    contain the seconds divided by 2 (0 to 28)
        5 to 10   contain the minutes  (0 to 59)
        11 to 15  contain the hours   (0 to 23)
   *------------------------------------------------------------------*
   $2D Tsettime  Set time
        WORD Tsettime(time)
        WORD time;
   Set 'time' as the current time in the format described in
   Tgettime().

   RETURN   0 if the provided time format is valid;
            ERROR if the time format is invalid.

   NOTE
        GEMDOS does not notify BIOS that the time has changed.
   *------------------------------------------------------------------*
   $2F Fgetdta   Inquire Disk Transfer Address (DTA) address
        LONG Fgetdta()
   Returns the current address of the data storage buffer on a file
   (DTA), used by the functions Fsfirst() and Fsnext().
   *------------------------------------------------------------------*
   $30 Sversion  Inquire GEMDOS version number
        WORD Sversion()

   Returns the GEMDOS version number in reverse format. The most
   significant byte contains the low part of the number, the least
   significant byte, the high part.

   NOTE
        The GEMDOS version on the 5/29/85 diskette and the first
        ROM version on 11/20/85 have $1300 as the number.

        The GEMDOS and TOS version numbers are NOT the same. (see
        the ST BIOS reference manual for the TOS version number).
     
   *------------------------------------------------------------------*
   $31 Ptermres  Terminate a resident program
        void Permres( rest,retcode)
        LONG rest;
        WORD retcode;

   Ends the current program, preserving some of its memory.
   'rest' is the number of bytes belonging to the program that
   should be kept, including and starting at the base page.
   'retcode' is the exit code returned to the parent program.

   The memory that the program has allocated (in addition to its TPA
   zone) is NOT freed.
   It is impossible to recall the program terminated by Ptermres().

   NOTE 
        Open files are closed when the process ends.
   *------------------------------------------------------------------*
  $36 Dfree     Requests free space on a disk
        void Dfree(buf,nbdisq)
        LONG *buf;
        WORD nbdisq;

   Requests information about the disk 'nbdisq' and places it in
   four long words starting at 'buf':
             __________________________________________________
            |  buf + 0  | number of free blocks on the disk    |
            |-----------|--------------------------------------|
            |  buf + 4  | total number of blocks on the disk   |
            |-----------|--------------------------------------|
            |  buf + 8  | size of a sector in bytes            |
            |-----------|--------------------------------------|
            |  buf + 12 | number of sectors per block          |
            |___________|______________________________________|

   NOTE   Incredibly slow on a hard disk (5 to 10 seconds).
   *------------------------------------------------------------------*
   $39 Dcreate   Creation of a subdirectory on disk C
        WORD Dcreate(path)
        char *path;

   'Path' points to a 0-terminated string specifying the path
   of the new directory.
   RETURN
        0 if successful;
        ERROR or the appropriate error number in case of failure.
   *------------------------------------------------------------------*
   $3A Ddelete   Deletes a subdirectory
        WORD Ddelete(path)
        char *path;
   Deletes a directory that must be empty (it can, however,
   contain the special files "." and ".."). 'Path' points to
   a 0-terminated string specifying the path of the directory to
   delete.

   RETURN   0 if successful;
            ERROR or the appropriate error number in case of failure.
   *------------------------------------------------------------------*
   $3B Dsetpath  Sets the current directory
        WORD Dsetpath(path)
        char *path;
   Sets 'path', (a 0-terminated string), as the current directory.
   If the path starts with a drive letter followed by a colon, the current directory is set to the specified drive.

   The system maintains a current directory for each drive.

   RETURN   0 if successful;
            ERROR or the appropriate error number in case of failure.
   *------------------------------------------------------------------*
   $3C Fcreate   Creation of a file
        WORD Fcreate(filename,attribs)
        char *filename;
        WORD attribs;
   Creates a file 'filename' and returns its non-standard,
   write-only identifier. The attribute word is stored in the
   directory; the attribute bits are:
         _________________________________________________________
        |  mask  |       description                             |
        |--------|-----------------------------------------------|
        | $01    | file created read-only                        |
        | $02    | file transparent to directory                 |
        | $04    | system file                                   |
        | $08    | file containing a volume name on 11 bits      |
        |________|_______________________________________________|

   RETURN
        A positive number, the identifier or :
        ERROR or the appropriate error number.

   NOTES
        If the read-only bit is set, a write-only identifier 
        is returned, and moreover, this identifier does not 
        allow writing.

        Theoretically, only one volume number is allowed on a
        root directory. GEMDOS does not enforce this, which
        can cause some confusion.
   *------------------------------------------------------------------*
   $3D Fopen     Opening a file
        WORD Fopen(filename,mode)
        char *filename;
        WORD mode;
   Opens the file 'filename' in mode 'mode' and returns its non-
   standard identifier. The opening mode can be:
                      ____________________________
                     | mode  |     description    |
                     |-------|---------------------|
                     | 0     | read-only           |
                     | 1     | write-only          |
                     | 2     | read and write      |
                     |_______|_____________________|

   RETURN
        A positive number, the identifier
        A negative error number.
   *------------------------------------------------------------------*
   $3E Fclose    Closing a file
        WORD Fclose(fileid)
        WORD fileid;
   Closes the file with the identifier 'fileid'.

   RETURN   0 if successful;
            ERROR or an appropriate error number in case of failure.
   *------------------------------------------------------------------*
   $3F Fread     Reading from a file
        LONG Fread(fileid,nbre,buffer)
        WORD fileid;
        LONG nbre;
        char *buffer;

   Reads 'nbre' bytes from the file with identifier 'fileid', and
   places them in memory starting from the address 'buffer'.

   RETURN
        The number of bytes actually read, or:
        0 if end of file code,
        A negative error number.
   *------------------------------------------------------------------*
   $40 Fwrite    Writing to a file
        LONG Fwrite(fileid,nbre,buffer)
        WORD fileid;
        LONG nbre;
        char *buffer;

   Writes 'nbre' bytes from memory starting from the address 'buffer',
   into the file with identifier 'fileid'.

   RETURN   The number of bytes actually written if successful.
            A negative error number otherwise.
   *------------------------------------------------------------------*
   $41 Fdelete   Deleting a file
        WORD Fdelete(filename)
        char *filename;
   Deletes the file named 'filename'.

   RETURN   0 if successful
            A negative error number otherwise.
   *------------------------------------------------------------------*
   $42 Fseek     Positioning the file pointer
        LONG Fseek(offset,fileid,mode)
        LONG offset;
        WORD fileid;
        WORD mode;
   Positions the pointer in the file defined by the identifier
   'fileid'. 'Offset' is a signed number; a positive value
   moves the pointer towards the end of the file, a negative value
   towards the beginning. The positioning mode can be:
              _____________________________________________
             | mode   |  Move offset bytes...              |
             |--------|------------------------------------|
             |    0   | from the beginning of the file     |
             |    1   | from the current position          |
             |    2   | from the end of the file           |
             |________|____________________________________|

   RETURN   The current position in the file.
            A negative error number if error.
   *------------------------------------------------------------------*
   $43 Fattrib   Set or request file attributes
        WORD Fattrib(filename,flag,attribs)
        char *filename;
        WORD flag;
        WORD attribs;
   'Filename' points to a 0-terminated path. If 'flag' is
   1, the file attributes 'attribs' are set (no return value).
   If 'flag' is 0, they are returned.

        The attribute bits are:
         _________________________________________________________
        | mask   |               description                      |
        |--------|------------------------------------------------|
        | $01    | read-only file                                 |
        | $02    | file transparent to directory                  |
        | $04    | 'system' file                                  |
        | $08    | file containing a volume name (11 bytes)       |
        | $10    | file subdirectory                              |
        | $20    | file written and then closed                   |
        |________|________________________________________________|

   NOTE   The archive bit, $20, does not seem to work as
   expected.
   *------------------------------------------------------------------*
   $45 Fdup      Duplicates a file identifier
        WORD Fdup(fileid)
        WORD fileid;
   The identifier 'fileid' must be a standard identifier (0 to
   5). Fdup() returns a non-standard identifier (6 or higher) that points to the same file.

   RETURN   An identifier or :
   EIHNDL   'fileid' is not a standard identifier
            ENHNDL    No more non-standard identifiers
   *------------------------------------------------------------------*
   $46 Fforce    Force a file identifier
        Fforce(stdh,nonstdh)
        WORD stdh;
        WORD nonstdh;

   Forces the standard identifier 'stdh' to point to the same file
   or device as the non-standard identifier 'nonstdh'.

   RETURN   0 if OK
            EIHNDL    invalid identifier.
   *------------------------------------------------------------------*
   $47 Dgetpath  Requests the current directory
        void Dgetpath(buf,driveno)
        char *buf;
        WORD driveno;
   The current directory for the drive 'driveno' is copied into
   'buf'. The drive number starts at 1 for drive A:, 2
   for drive B:, etc..., 0 specifying the default disk.

    NOTE
   The maximum size of a path is not limited by the system.
   It is up to the application to provide enough space for the
   buffer. 128 bytes seem sufficient for 8 or 9 subdirectories.
   *------------------------------------------------------------------*
   $48 Malloc    Memory allocation request
        LONG Malloc(size)
        LONG size;
   If 'size' is -1L ($FFFFFFFF) the function returns the size of the
   largest free block in the system. Otherwise if 'size' is
   different from -1L, the function tries to allocate 'size' bytes for
   the current program. The function returns a pointer to the
   beginning of the allocated block if all went well, or NULL if there
   was no block large enough to satisfy the request.

     NOTE
   A program can have, at any given moment, no more than 20 blocks 
   allocated by 'Malloc()'. Exceeding this limit can disrupt GEMDOS. 
   (However, it is possible to make as many 'Malloc()' calls as 
   one wishes as long as they are followed by the call of the 
   'Mfree()' function, 20 being the maximum number of 
   fragments a program can generate).
   *------------------------------------------------------------------*
   $49 Mfree     Memory Release
        WORD Mfree(adbloc)
        LONG adbloc;
   Releases the memory block starting at 'adbloc'. The block must be one
   of those allocated by Malloc().

   RETURN
        0 if the release was successful.
        ERROR or the appropriate error number otherwise.
   *------------------------------------------------------------------*
   $4A Mshrink   Shrinks the size of an allocated block
        WORD Mshrink(0,bloc,newsize)
        WORD) 0;
        LONG bloc;
        LONG newsize;
   Shrinks the size of an allocated memory block. 'Bloc' points to the
   base page of a program or to a memory block allocated by
   Malloc(), 'newsize' is the new size of the block.
   The first argument of the block must be a null word.

   RETURN
        0        if the size adjustment was successful.
        EIMBA    if the memory block address was invalid.
        EGSBF    if the new requested size was incorrect.

   NOTE
        A block can only be shrunk; the new size of the block
        must necessarily be smaller than the previous one.

   N.B.: The 'C' Alcyon compiler adds, during compilation,
   the first call parameter '0'. Therefore, it should not be included
   in the function call if using this compiler.

   Function call with 'C' Alcyon: Mshrink(bloc,newsize);
   *------------------------------------------------------------------*
   $4B Pexec     Load/Execute a program
        WORD Pexec(mode,ptr1,ptr2,ptr3)
        WORD mode;
        char *ptr1;
        char *ptr2;
        char *ptr3;

   This function allows different uses depending on the 'mode' flag:

        ___________________________________________________________
       |     mode     |     ptr1     |    ptr2     |      ptr3     |
       |--------------|--------------|-------------|---------------|
       | 0: load and  | file to      | command set | environment   |
       |     execute  | execute      |             | string        |
       |--------------|--------------|-------------|---------------|
       | 3: load      | file to      | command set | environment   |
       |   without    | load         |             | string        |
       |   launching  |              |             |               |
       |--------------|--------------|-------------|---------------|
       | 4: execute   | address of   | (unused)    | (unused)      |
       |    only      | the base page|             |               |
       |--------------|--------------|-------------|---------------|
       | 5: create a  | (unused)     | command set | environment   |
       |  base page   |              |             | string        |
       |______________|______________|_____________|_______________|

   The name of the file to load or execute, 'ptr1', and the command set
   string, 'ptr2', are paths, terminated by 0. The environment
   string 'ptr3', is either NULL (0L), or a pointer to a structure of string in the form:
                  "string1\0"
                  "string2\0"
                  etc...
                  "string3\0"
                  "\0"

   The environment string can be any number of
   strings ended by a 0, followed by a null string (a simple 0).
   The program inherits a copy of the parent's environment string if 'ptr3' is 'NULL'.

   Mode 0 (load and execute) will load the specified file,
   compose its base page, and execute it. The value returned by
   Pexec() will be the exit code of the child process (see Pterm0()
   and Pterm()).

   Mode 3 (load without executing) will load the specified file,
   compose the base page, and return a pointer to this
   base page. The program is not executed.

   Mode 4 (execute only) receives a pointer to a base page.
   The program starts its execution at the beginning of the text area,
   as specified in the base page.

   Mode 5 (creation of a base page) will allocate the largest
   free memory block and create most of its base page.
   Some entries such as the size of the initialized/uninitialized data areas and their
   base address ARE NOT installed. The calling program is responsible for them.

   A child program inherits the standard file descriptors
   from its parent. It actually employs a call to Fdup() and
   Fforce() on identifiers 0 to 5.

   Since system resources are allocated during the creation of
   the base page, the spawned process MUST terminate by
   releasing them. This is particularly important when
   using overlays. (see 'the Pexec cookbook' for more
   details on Pexec()).
   *------------------------------------------------------------------*
   $4C Pterm     Ends a program
        void Pterm(retcode)
        WORD retcode;
   Ends the current program, closes all open files, and
   frees allocated memory. Returns 'retcode' to the parent process.
   *------------------------------------------------------------------*
   $4E Fsfirst   Searches for the first occurrence of a file
        WORD Fsfirst(fspec,attribs)
        char *fspec;
        WORD attribs;
   Searches for the first occurrence of the file 'fspec'. The file
   specifier can contain special characters ('?' or
   '*') in the file name but not in the path specification. 'Attribs' controls the type of file that will be returned
   by Fsfirst(). Its format has been described in the documentation on
   'Fattrib()'.

   If 'attribs' is zero, only normal files will be
   searched (no volume name, hidden file, subdirectory, or
   system file will be returned). If 'attribs' is set to
   hidden files or system files, then those will
   be taken into account for the search. If 'attribs' is set
   to find a volume name, then only volume names will be searched.

   When a file is found, a 44-byte structure is
   written at the location pointed to by the DTA.
            _________________________________________________
           | offset |  size    |   contents                  |
           |--------|----------|-----------------------------|
           | 0 to 20|          | (reserved)                  |
           |   21   |  byte    | attribute bits              |
           |   22   |  word    | creation time               |
           |   24   |  word    | creation date               |
           |   26   |  long    | file size                   |
           |   30   | 14 bytes | file name and extension     |
           |________|__________|_____________________________|

   The file name and its extension end with a 0, and do not
   contain spaces.
   RETURN   0 if the file was found
            EFILNF     if the file was not found, or the
            appropriate error number.
   *------------------------------------------------------------------*
   $4F Fsnext    Searches for subsequent occurrences
        WORD Fsnext()
   Searches for subsequent occurrences of a file. The first
   occurrence must be searched for by Fsfirst(). Bytes 0 to
   20 must remain unchanged since the call of Fsfirst() or
   the last call of Fsnext().

   RETURN   0 if the file was found
        ENMFIL     if there are no more files found, or the
        appropriate error number.
   *------------------------------------------------------------------*
   $56 Frename   Renames a file
        WORD Frename(0,oldname,newname)
        WORD) 0;
        char *oldname;
        char *newname;
   Renames a file 'oldname' to 'newname'. The new name must not
   already exist but can be in a different directory.

   The first parameter must be 0 (word).

   RETURN   0         if OK
            EACCDN    if the new name already exists
            EPTHNF    if the old name was not found
            ENSAME    if the disk identifier (A,B,..) is not
                      the same for both names.
   *------------------------------------------------------------------*
   $57 Fdatime   Sets or requests the creation time of a file
         void Fdatime(fileid,pttemp,flag)
        WORD fileid;
        LONG pttemp;
        WORD flag;
   The file is recognized by its identifier 'fileid'. 'Pttemp'
   points to two words containing the time and date in DOS
   format (the time is in the first word, the date in the second).

   If 'flag' is 1, the date and time are set in the file
   from 'pttemp'.

   If 'flag' is 0, the date and time are read and placed
   in 'pttemp'.
   *------------------------------------------------------------------*

Back to ASM_Tutorial