Application Programming Interface

Introduction

The Application Programming Interface (API) is a set of methods in which the programmer can access the internals of the Operating System. The API features many different types of functions, and are grouped together by function below.

The current version of this API (for source inclusion into DexOS Applications) can be downloaded here.


Usage

Assembly-language Access

The assembly language API interface is accessed through a call-table scheme, whereby the call table is initialized on entry to the application (see code snippet below) and accessed through the "call" instruction (example: call [DexFunction]).

_entry:
    mov   AX, 0x18
    mov   DS, AX
    mov   ES, AX
    mov   EDI, Functions
    mov   AX, 0x0A00
    int   0x40

For more information on how to use the call table, please refer to the API Tutorial.

C-language Access

Currently, access to the API is by one of two means:

  • Including the compile-in API (for TCC); or
  • Writing inline GAS-syntax assembler.

The archives for the TCC API library were lost to a forum crash, therefore one must write GAS assembler. This is the beyond the scope of this article.


List

CallTableAddress [+00]

Inputs: N/A
Outputs: N/A
Notes: This function is a dummy function. It shouldn't be modified, accessed or used.


;----------;
; 0 - CallTableAddress ;
;
----------;
; ;
; Input: None. ;
; ;
; Output: None. ;
;…………………………………………….;
; Store the address of calltable ;
;…………………………………………….;
;=========================================================;
; This Doc Lists Regs Used by Call Functions.    10/06/05 ;
;---------------------------------------------------------;
;                                                         ;
; Dex4u V0.01                                             ;
; (c) Craig Bamford, All rights reserved.                 ;
;=========================================================;

 ;----------------------------------------------------;
 ; 0 - CallTableAddress                               ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Store the address of calltable                    ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 1 - Function1                                      ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Not used.                                         ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 2 - RealModeInt10h                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;  Input : AX                                        ;
 ;          BX                                        ;
 ;          DX                                        ;
 ;          CX                                        ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;                                                    ;
 ;    NOTE: Call "RealModeRegs" for reg or Error etc. ;
 ;....................................................;
 ;  Call realmode int 10h.                            ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 3 - RealModeRegs                                   ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;  Input : None.                                      ;
 ;                                                    ;
 ;  Output: AX                                        ;
 ;          BX                                        ;
 ;          DX                                        ;
 ;          CX                                        ;
 ;                                                    ;
 ;  Error: STC                                        ;
 ;....................................................;
 ;  Fills regs with result from above int 10h .       ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 4 - WaitForKeyPress                                ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: AL = ASCII code.                          ;
 ;          AH = ScanCode.                            ;
 ;....................................................;
 ;  Wait for keypress.                                ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 6 - ExtendedMemory                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: EAX = Extended Memory.                    ;
 ;          EBX = Total Ram (MB).                     ;
 ;....................................................;
 ;  Extended Memory.                                  ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 7 - ConvenMemorySize                               ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: EAX = Conventional Memory (KB).           ;
 ;....................................................;
 ;  Conven Memory Size in KB.                         ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 9 - PrintString                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: DS:ESI = String.                          ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Prints a 0 Termanated String.                     ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 10 - PrintChar                                     ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: AL = Char.                                ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Prints a char,from al in textmode.                ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 11 - PrintCharCursor                               ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: AL = Char.                                ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Prints a char,from al in textmode + moves cursor. ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 12 - SetCursorPos                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: AL = X .                                  ;
 ;          AH = Y .                                  ;
 ;                                                    ;
 ;  Output: AH = 0 On Succes.                         ;
 ;          CF = 1 Error, (eg: bigger than screenXY). ;
 ;....................................................;
 ;  Sets Cursor Pos.                                  ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 13 - WriteHex32                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = HexNumber.                          ;
 ;                                                    ;
 ;  Output: EAX = High ASCII.                         ;
 ;          EBX = Low ASCII.                          ;
 ;....................................................;
 ;  Print the hex value,in eax to text mode.          ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 14 - WriteHex16                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: AL = HexNumber.                           ;
 ;                                                    ;
 ;  Output: AX = ASCII.                               ;
 ;....................................................;
 ;  Print the hex value, in al to text mode.          ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 15 - UpperCase                                     ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: ES:EDI = String.                          ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Converts a 0 termanated string,to uppercase.      ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 16 - UpperCase                                     ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: ES:EDI = String1 buffer (0 termanated).   ;
 ;          DS:ESI = String2 buffer (0 termanated)    ;
 ;             ECX = Number of letters.               ;
 ;                                                    ;
 ;  Output: STC = Error (If strings are not the same) ;
 ;....................................................;
 ;  Compear two 0 termanated string.                  ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 17 - SetDex4uFonts                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Goes to realmode and back sets 50x80 mode/fonts.  ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 18 - FloppyfileLoad                                ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EDI = Address to load file to.            ;
 ;          ESI = Points to name of file to load.     ;
 ;                                                    ;
 ;  Output: STC = Error.                              ;
 ;                (If file not found/Drive not ready) ;
 ;....................................................;
 ;  Loads a file from floppy.                         ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 19 - CdfileLoad                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EDI = Address to load file to.            ;
 ;          ESI = Points to name of file to load.     ;
 ;          CX  = File name lenth,(number of letters) ;
 ;                                                    ;
 ;  Output: STC = Error.                              ;
 ;                (If file not found/Drive not ready) ;
 ;....................................................;
 ;  Loads a file from CD.                             ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 20 - SetDelay                                      ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: AX = Delay.                               ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Sets a delay, 18 = 1 second.                      ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 21 - DetectPciBus                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: STC = if no pci bus.                      ;
 ;....................................................;
 ;  Detect Pci Bus present.                           ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 22 - PciFindDevice                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = Device+vendor ID                    ;
 ;                                                    ;
 ;  Output: EAX = PCI address if device found.        ;
 ;          STC = if no vender/device mach found.     ;
 ;                         NOTE: eax invalid if stc.  ;
 ;....................................................;
 ;  Scan PCI space looking for a device+vendor ID.    ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 23 - PciRegWrite8                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;           DL = Data to write.                      ;
 ;                                                    ;
 ;  Output:  None.                                    ;
 ;....................................................;
 ;  Pci Reg Write 8 bit.                              ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 24 - PciRegWrite16                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;           DX = Data to write.                      ;
 ;                                                    ;
 ;  Output:  None.                                    ;
 ;....................................................;
 ;  Pci Reg Write 16 bit.                             ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 25 - PciRegWrite32                                 ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;          EDX = Data to write.                      ;
 ;                                                    ;
 ;  Output:  None.                                    ;
 ;....................................................;
 ;  Pci Reg Write 32 bit.                             ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 26 - PciRegRead8                                   ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;                                                    ;
 ;  Output:  DL = Reg Data.                           ;
 ;....................................................;
 ;  Pci Reg read 8 bit.                               ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 27 - PciRegRead16                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;                                                    ;
 ;  Output:  DX = Reg Data.                           ;
 ;....................................................;
 ;  Pci Reg read 16 bit.                              ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 28 - PciRegRead32                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: EAX = PCI Bus/Device/fn/register number.  ;
 ;                                                    ;
 ;  Output:  EDX = Reg Data.                          ;
 ;....................................................;
 ;  Pci Reg read 32 bit.                              ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 29 - Function29                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Not used.                                         ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 30 - GetUserInput                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: EDI = Buffer address.                     ;
 ;           CX = Number of letters in buffer.        ;
 ;....................................................;
 ;  Gets user input, until enter is pressed.          ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 31 - LoadVesaInfo                                  ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: ESI = Address of vesa info map.           ;
 ;           CX = Number of dwords to load.           ;
 ;                                                    ;
 ;   NOTE: the Dword size may not be implemented,     ;
 ;         so if unshore, hardcode it with 193 DW.    ;
 ;....................................................;
 ;  Loads address of VesaInfo block.                  ;
 ;....................................................;

 ;----------------------------------------------------;
 ; 32 - SetVesaMode                                   ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;    NOTE: There will be regs used, when more modes- ;
 ;          implemented.                              ;
 ;                                                    ;
 ;  Output: AH = 1 , On Error.                        ;
 ;                                                    ;
 ;    NOTE: need vesa info structure filling in,      ;
 ;          use "LoadVesaInfo" function first.        ;
 ;....................................................;
 ; Sets VesaMode,(temp hardcoded 4112h 640*480 32bpp).;
 ;....................................................;

 ;----------------------------------------------------;
 ; 33 - Function33                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;   Input: None.                                     ;
 ;                                                    ;
 ;  Output: None.                                     ;
 ;....................................................;
 ;  Not used.                                         ;
 ;....................................................;
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License