EuroAssembler Index Manual Download Source Macros


Sitemap Links Forum Tests Projects

biosapi.htm
Enumerations
%Colors
Macro
BiosAPI

This file declares OS-independent macroinstructions for interaction with Basic Input Output System.

BIOS services run in 16bit real CPU mode and they do not require any operating system.
BIOS API functions can be used before or after DOS has been loaded, and some of them are usable in Windows virtual DOS machine (ntvdm) or similar emulators.


biosapi HEAD  ; Start of interface block includable to other programs.
↑ %Colors

Encoding of colors used in text-mode EGA/VGA display services.
The required color combination is a sum of foreground (ink) color plus background (paper) color left-shifted by 4 bits.

Example
MOV AH,%Red + %Yellow<<4
%Black     %SETA 0000b
%Blue      %SETA 0001b
%Green     %SETA 0010b
%Cyan      %SETA 0011b
%Red       %SETA 0100b
%Magenta   %SETA 0101b
%Brown     %SETA 0110b
%White     %SETA 0111b
%Gray      %SETA 1000b
%BrBlue    %SETA 1001b
%BrGreen   %SETA 1010b
%BrCyan    %SETA 1011b
%BrRed     %SETA 1100b
%BrMagenta %SETA 1101b
%BrYellow  %SETA 1110b
%Yellow    %SETA 1110b
%BrWhite   %SETA 1111b
↑ BiosAPI INT=10h, reg1=value1, reg2=value2...
Macro BiosAPI provides interaction with BIOS using software-called interrupts.
Documented
[IntList]
Input
INT= is the interrupt number, for instance INT=16h for keyboard service. Default value INT=10h (videoservice) may be omitted.
regX=valueX. Arbitrary number of keyword parameters can be specified and the corresponding 8bit or 16bit general-purpose register will be loaded with its value before the interrupt is called.
Registers are loaded in the order as specified in the macro invocation.
Names of registers and the INT= key are case-sensitive but both uppercase and lowercase may be used.
Output
Values returned from interrupt service are defined in the documentation.
Error
As specified in the documentation.
Examples
Read 5 sectors starting at sector 2, head 1, cylinder 0 from floppy disk A: to memory at ES:BX
BiosAPI INT=13h,AH=2,AL=5,CL=2,DH=1,CH=0,DL=0
Display in red on white 12-byte string addressed by ES:BP at row 3, column 5 on the monitor textmode screen:
BiosAPI INT=10h,AH=13h,AL=0,BH=0,BL=74h,CX=12,DH=3,DL=5
Parameters from previous example, which use 8bit registers, could also be joined to 16 bits. Thank to this, BiosAPI expands to slightly shorter but still equivalent code:
BiosAPI ax=0x1300,bx=0x0074,CX=12,DX=0x0305 ; will expand to ; MOV ax,0x1300 ; MOV bx,0x0074 ; MOV CX,12 ; MOV DX,0x0305 ; INT 10h
See also
DosAPI
BiosAPI %MACRO INT=10h, \
        AL=,AH=,CL=,CH=,DL=,DH=,BL=,BH=,AX=,CX=,DX=,BX=,BP=,SP=,SI=,DI=,DS=,ES=, \
        al=,ah=,cl=,ch=,dl=,dh=,bl=,bh=,ax=,cx=,dx=,bx=,bp=,sp=,si=,di=,ds=,es=
%intNr  %SET 10h      ; Default if not specified otherwise.
%kwlength %SETA %=#  ; %kwlength is now the number of keyword operands in BiosAPI invocation.
k   %FOR 1..%kwlength
%kw     %SET %=*{%k} ; %kw is now something like AH=5 or INT=16h.
%kwsize %SETS %kw    ; Number of characters in keyword operand %kw.
%key    %SET         ; Split the operand by = to %key and %value. Start with empty %key.
%i      %SETA 1      ; Start with the 1st character.
        %REPEAT
          %IF "%kw[%i]" === "="
            %EXITREPEAT           ; Equal-sign found, the split is done.
          %ELSE
            %key %SET %key%kw[%i] ; Append the %i-th character and continue.
            %i %SETA %i + 1
          %ENDIF
        %UNTIL %i > %kwsize
        %value %SET %kw[%i+1..%&]
        %IF "%key" == "INT"
          %intNr %SET %value ; Save the interrupt number for later to the variable %intNr.
        %ELSE
          %IF "%key"==="" || "%value"===""
             %ERROR ID=5910,'Bad parameter "%key=%value", ignored.'
          %ELSE
            MOV %key,%value  ; Emit the instruction loading register %key.
          %ENDIF
        %ENDIF
    %ENDFOR k                ; Process the next keyword operand.
    INT %intNr               ; Finally emit the BIOS service call.
  %ENDMACRO BiosAPI
 ENDHEAD biosapi ; End of interface block.

▲Back to the top▲