GEMDOS.TXT

From Atari Wiki
Revision as of 14:22, 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 time, 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
   desired as long as they are followed by the call of the
   'Mfree()' function, 20 being the maximum number of


Back to ASM_Tutorial