home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
153_01
/
biosio.asm
< prev
next >
Wrap
Assembly Source File
|
1985-03-11
|
13KB
|
537 lines
; *** biosio.asm ***
;
; IBM-PC microsoft "C" under PC-DOS v2.00
;
; MICROSOFT "C" callable 8088 assembly routines that interface directly
; with the basic I/O system (BIOS).
;
; NOTE -- The IBM Technical Reference Manual contains a listing of the
; BIOS and more complete descriptions of each interrupt.
;
; Written by L. Cuthbertson, April 1984
;
;**********************************************************************
;
PGROUP GROUP PROG
PROG SEGMENT BYTE PUBLIC 'PROG'
PUBLIC KEYRD,KEYHIT,KEYSHIF
PUBLIC BIOSINI,BIOSSET,BIOSPOS
PUBLIC BIOSUP,BIOSDWN,BIOSRCA,BIOSWCA,BIOSWC
PUBLIC BIOSWD,BIOSTTY,BIOSCUR
PUBLIC COMINI,COMOUT,COMIN,COMSTAT
PUBLIC INP,OUTP
ASSUME CS:PGROUP
;
;**********************************************************************
;
; *** KEYBOARD I/O ***
;
; NOTE - Keyboard interrupt description starts on page A-23 of Tech
; Ref Manual.
;
;**********************************************************************
;
; Read a keyboard entry - wait for entry if one not ready.
;
; synopsis c = keyrd();
;
; int c; high order bits contain scan code
; low order bits contain character
;
; NOTE - Scan codes are described on page 2-17 of the Technical
; Reference Manual.
;
KEYRD PROC NEAR
PUSH BP
MOV BP,SP
MOV AH,0 ; READ NEXT CHARACTER ENTERED
INT 16H ; BIOS KEYBOARD I/O INTERRUPT
POP BP
RET
KEYRD ENDP
;
; Check to see if there is a character in the keyboard buffer.
;
; synopsis iret = keyhit();
;
; int iret; = 0 if no character availible
; = 1 character is availible
;
KEYHIT PROC NEAR
PUSH BP
MOV BP,SP
MOV AH,1 ; CHECK KEYBOARD BUFFER FUNCTION
INT 16H ; BIOS KEYBOARD I/O INTERRUPT
MOV AX,0 ; ASSUME THAT NO CHARACTER READY
JZ K1
MOV AX,1 ; CHARACTER READY
K1:
POP BP
RET
KEYHIT ENDP
;
; Check to see what the shift key status is.
;
; synopsis iret = keyshif();
;
; int iret; shift key status
;
; 0x80 = insert state is active
; 0x40 = cap lock state has been toggled
; 0x20 = num lock state has been toggled
; 0x10 = scroll lock state has been toggled
; 0x08 = alternate shift key depressed
; 0x04 = control shift key depressed
; 0x02 = left shift key depressed
; 0x01 = right shift key depressed
;
; NOTE - from page A-2 and A-3 of Tech Ref Manual
;
KEYSHIF PROC NEAR
PUSH BP
MOV BP,SP
MOV AH,2 ; CHECK SHIFT STATUS FUNCTION
INT 16H ; BIOS KEYBOARD I/O INTERRRUPT
POP BP
RET
KEYSHIF ENDP
;
; *********************************************************************
;
; *** VIDEO I/O ***
;
; NOTE - the video I/O interrupt description starts on page A-43 of the
; Tech Ref Manual.
;
; *********************************************************************
;
; Initialize screen I/O using the BIOS set mode call
;
; synopsis biosini(stype);
;
; int stype; screen type
;
; 0 = 40x25 BW (power on default)
; 1 = 40x25 Color
; 2 = 80x25 BW
; 3 = 80x25 Color
; graphics mode
; 4 = 320x200 Color
; 5 = 320x200 BW
; 6 = 640x200 BW
; internal use only
; 7 = 80x25 BW card
;
BIOSINI PROC NEAR
PUSH BP
MOV BP,SP
MOV AL,[BP+4] ; SCREEN TYPE IN AL
MOV AH,0 ; SET MODE FUNCTION
INT 10H ; BIOS VIDEO I/O INTERRUPT
POP BP
RET
BIOSINI ENDP
;
; Set the current cursor position.
;
; synopsis biosset(irow,icol);
;
; *** no value returned ***
; int irow; 0 to 24
; int icol; 0 to 79
;
BIOSSET PROC NEAR
PUSH BP
MOV BP,SP
MOV DH,[BP+4] ; ROW
MOV DL,[BP+6] ; COLUMN
MOV BH,0 ; CURRENT PAGE NUMBER
MOV AH,2 ; CURSOR POSITION SET FUNTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSSET ENDP
;
; Return the current cursor postion.
;
; synopsis iret = biospos();
;
; int iret; high order bits contain row
; low order bits contain column
;
BIOSPOS PROC NEAR
PUSH BP
MOV BP,SP
MOV BH,0 ; CURRENT PAGE NUMBER
MOV AH,3 ; CURSOR POSITION FUNCTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
MOV AH,DH ; MOVE INT RETURN INTO FUNCTION RETURN
MOV AL,DL ; DITTO
POP BP
RET
BIOSPOS ENDP
;
; Scroll the screen up within a defined window.
;
; synopsis biosup(numlines,trow,tlcol,brow,brcol,fchar);
;
; int numlines; number of lines to scroll up
; int trow; top row of window
; int tlcol; top left column of window
; int brow; bottom row of window
; int brcol; bottom right column of window
; int fchar; fill character of opened line
;
; note: numlines = 0 blanks entire window. Upper left corner of full
; screen is 0,0 while the bottom right corner of full screen is
; 24,79.
;
BIOSUP PROC NEAR
PUSH BP
MOV BP,SP
MOV AL,[BP+4] ; NUMBER OF LINES TO SCROLL
MOV CH,[BP+6] ; TOP ROW OF WINDOW
MOV CL,[BP+8] ; TOP LEFT COLUMN OF WINDOW
MOV DH,[BP+10] ; BOTTOM ROW OF WINDOW
MOV DL,[BP+12] ; BOTTOM RIGHT COLUMN OF WINDOW
MOV BH,[BP+14] ; FILL CHARACTER
MOV AH,6 ; SCROLL UP FUNCTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSUP ENDP
;
; Scroll the screen down within a defined window.
;
; synopsis biosdwn(numlines,trow,tlcol,brow,brcol,fchar);
;
; int numlines; number of lines to scroll down
; int trow; top row of window
; int tlcol; top left column of window
; int brow; bottom row of window
; int brcol; bottom right column of window
; int fchar; fill character of opened line
;
; note: numlines = 0 blanks entire window. Upper left corner of full
; screen is 0,0 while the bottom right corner of full screen is
; 24,79.
;
BIOSDWN PROC NEAR
PUSH BP
MOV BP,SP
MOV AL,[BP+4] ; NUMBER OF LINES TO SCROLL
MOV CH,[BP+6] ; TOP ROW OF WINDOW
MOV CL,[BP+8] ; TOP LEFT COLUMN OF WINDOW
MOV DH,[BP+10] ; BOTTOM ROW OF WINDOW
MOV DL,[BP+12] ; BOTTOM RIGHT COLUMN OF WINDOW
MOV BH,[BP+14] ; FILL CHARACTER
MOV AH,7 ; SCROLL DOWN FUNCTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSDWN ENDP
;
; Read the contents of a given screen cell.
;
; synopsis iret=biosrca();
;
; int iret; high order bits contain attributes
; low order bits contain character
;
; NOTE - Attributes are defined on page 13-9 of the DOS v2.0 manual
;
BIOSRCA PROC NEAR
PUSH BP
MOV BP,SP
MOV BH,0 ; ACTIVE DISPLAY PAGE
MOV AH,8 ; READ CHARACTER + ATTRIBUTES FUNCTION
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSRCA ENDP
;
; Write a character to the screen - with attributes.
;
; synopsis bioswca(char,count,att);
;
; *** no value returned ***
; int char; character to output
; int count; number of times to output character
; int att; character attribute
;
; NOTE - Attributes are defined on page 13-9 of the DOS v2.0 manual
;
BIOSWCA PROC NEAR
PUSH BP
MOV BP,SP
MOV AL,[BP+4] ; CHARACTER
MOV CX,[BP+6] ; NUMBER OF CHARACTERS TO WRITE
MOV BL,[BP+8] ; CHARACTER ATTRIBUTE
MOV BH,0 ; ACTIVE DISPLAY PAGE
MOV AH,9 ; WRITE CHARACTER/w ATTRIBUTES FUNCTION
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSWCA ENDP
;
; Write a character to the screen - no attributes.
;
; synopsis bioswc(char,count);
;
; *** no value returned ***
; int char; character to output
; int count; number of times to output character
;
BIOSWC PROC NEAR
PUSH BP
MOV BP,SP
MOV AL,[BP+4] ; CHARACTER
MOV CX,[BP+6] ; NUMBER OF CHARACTERS TO WRITE
MOV BL,0; ; CHARACTER ATTRIBUTE - NULL
MOV BH,0 ; ACTIVE DISPLAY PAGE
MOV AH,10 ; WRITE CHARACTER ONLY FUNCTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSWC ENDP
;
; Write a dot in graphics mode.
;
; synopsis bioswd(irow,icol);
;
; *** no value returned ***
; int irow;
; int icol;
;
BIOSWD PROC NEAR
PUSH BP
MOV BP,SP
MOV DX,[BP+4] ; ROW
MOV CX,[BP+6] ; COLUMN
MOV AL,1 ; GREEN COLOR
MOV AH,12 ; WRITE A DOT FUNCTION NUMBER
INT 10H ; VIDEO I/O INTERRUPT
POP BP
RET
BIOSWD ENDP
;
; Write a character to the screen using the BIOS ascii teletype call.
; The teletype call will send cr/lf if column 79 is written to (0-79).
; It will scroll the screen up if row 24 (0-24) column 79 is written to.
; It will also beep the bell if ^g is received and provide a destructiv