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.
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.
%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 %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 the %key and %value. Start with empty %key. %i %SETA 1 ; Begin 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 the 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.