GEMDOS.TXT

From Atari Wiki
Revision as of 14:08, 16 December 2023 by Olivier.jan (talk | contribs)
Jump to navigation Jump to search
   ***-------------- 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     Inquire free space on a disk
        void Dfree(buf,drive)
        LONG *buf;
        WORD

Back to ASM_Tutorial