of 14

Contents of Part One | Bios | Pointer (Computer Programming)

All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
CONTENTS OF PART ONE ã ã ã ã ã ã Rom Bios Calls Video Bios Calls Input/Output Port Access Extended Video Bios Calls Making Libraries Pointers to Functions ROM BIOS CALLS The ROM BIOS (Basic Input Output System) provides device control for the PC's major devices (disk, video, keyboard, serial port, printer), allowing a programmer to communicate with these devices without needing detailed knowledge of their operation. The ROM routines are accessed via the Intel 8088/86 software generated interru
  CONTENTS OF PART ONE ã Rom Bios Calls ã Video Bios Calls ã Input/Output Port Access ã Extended Video Bios Calls ã Making Libraries ã Pointers to Functions ROM BIOS CALLS The ROM BIOS (Basic Input Output System) provides device control for the PC's major devices (disk,video, keyboard, serial port, printer), allowing a programmer to communicate with these deviceswithout needing detailed knowledge of their operation. The ROM routines are accessed via the Intel8088/86 software generated interrupts. The interrupts 10H through to 1AH each access a differentroutine.Parameters are passed to and from the BIOS routines using the 8088/86 CPU registers. The routinesnormally preserve all registers except AX and the flags. Some registers are altered if they return valuesto the calling process. ROM BIOS INTERRUPT ROUTINES 10Video routines11Equipment Check12Memory Size Determination13Diskette routines14Communications routines15Cassette16Keyboard routines17Printer18Cassette BASIC19Bootstrap loader1ATime of Day The interrupts which handle devices are like a gateway which provide access to more than one routine.The routine executed will depend upon the contents of a particular CPU register. Each of the softwareinterrupt calls use the 8088/86 register contents to determine the desired function call. It is necessary touse a C definition of the CPU programming model, this allows the registers to be initialised with thecorrect values before the interrupt is generated. The definition also provides a convienent place to storethe returned register values. Luckily, the definition has already been created, and resides in the header file dos.h. It is a union of type REGS, which has two parts, each structures.One structure contains the eight bit registers (accessed by .h.), whilst the other structure contains the 16 bit registers (accessed by .x.) To generate the desired interrupt, a special function call has been provided. This function accepts the interrupt number, and pointers to the programming model unionfor the entry and return register values. The following program demonstrates the use of these conceptsto set the display mode to 40x25 color. #include <dos.h>union REGS regs;main(){regs.h.ah = 0;regs.h.al = 1;int86( 0x10, &regs, &regs );printf( Fourty by Twenty-Five color mode. );}  VIDEO ROM BIOS CALLS The ROM BIOS supports many routines for accessing the video display. The following table illustratesthe use of software interrupt 0x10. SCREEN DISPLAY MODE FUNCTION CALL (regs.h.ah = 0) regs.h.alScreen Mode040.25 BW140.25 CO280.25 BW380.25 CO4320.200 CO5320.200 BW6640.200 BW7Mono-chrome8160.200 16col PCjr9320.200 16col PCjrA640.200 4col PCjrD320.200 16col EGAE640.200 16col EGAF640.350 mono EGA10640.350 16col EGA Note: The change screen mode function call also has the effect of clearing the video screen! The other routines associated with the video software interrupt 0x10 are, (Bold represents return values) Function Callregs.h.ahEntry/Exit ValuesSet display mode0Video mode in alSet cursor type1Start line=ch, end line=cl(Block cursor, cx = 020C)Set cursor position2Row,column in dh,dl, page number inbhRead cursor position3Page number in bh, dh,dl on exithas row,columnRead light pen pos4ah=0 light pen not activeah=1 light pen activateddh,dl has row,columnch has raster line (0-199)bx has pixel column (0-139,639)Select active page5New page number in alScroll active page up6Lines to scroll in al(0=all)upper left row,column in ch,cllower right row,col in dh,dlattribute for blank line in bhScroll active page dn7Same as for scroll upRead char and attr8Active page in bhal has characterah has attributeWrite char and attr9Active page in bhnumber of characters in cxcharacter in alattribute in blWrite character0aActive page in bhnumber of characters in cxcharacter in alSet color palette0bPalette color set in bh(graphics) color value in bl  Write dot0cRow,column in dx,cxcolor of pixel in alRead dot0dRow,column in dx,cx color in alWrite teletype0eCharacter in al, active page in bhforegrnd color(graphics) in blReturn video state0fCurrent video mode in alcolumns in ah,active page in bh PORT ACCESS The C language can be used to transfer data to and from the contents of the various registers andcontrollers associated with the IBM-PC. These registers and control devices are port mapped, and areaccessed using special IN and OUT instructions. Most C language support library's include functionsto do this. The following is a brief description of how this may be done. /* #include <conio.h> */outp( Port_Address, value); /* turboC uses outportb() */value = inp( Port_address); /* and inportb() */ The various devices, and their port values, are shown below, Port RangeDevice 00 - 0f DMA Chip 873720 - 21 8259 PIC40 - 43 Timer Chip 825360 - 63 PPI 8255 (cassette, sound)80 - 83 DMA Page registers200 - 20f Game I/O Adapter278 - 27f Reserved2f8 - 2ff COM2378 - 37f Parallel Printer3b0 - 3bf Monochrome Display3d0 - 3df Color Display3f0 - 3f7 Diskette3f8 - 3ff COM1 PROGRAMMING THE 6845 VIDEO CONTROLLER CHIP The various registers of the 6845 video controller chip, resident on the CGA card, are Port Value Register Description 3d0 6845 registers3d1 6845 registers3d8 DO Register (Mode control)3d9 DO Register (Color Select)3da DI Register (Status)3db Clear light pen latch3dc Preset light pen latch PROGRAMMING EXAMPLE FOR THE BORDER COLOR  The register which controls the border color is the Color Select Register located at port 3d9. Bits 0 - 2determine the border color. The available colors and values to use are,  Value ColorValue Color 0 Black8 Dark Grey1 Blue9 Light Blue2 Green0a Light Green  3 Cyan0b Light Cyan4 Red0c Light Red5 Magenta0d Light Magenta6 Brown 0e Yellow7 Light Grey0f White The following program will set the border color to blue. #include <conio.h> /* needed for outp() */#include <stdio.h> /* needed for getchar() */#include <dos.h> /* for REGS definition */#define CSReg 0x3d9#define BLUE 1void cls(){union REGS regs;regs.h.ah = 15; int86( 0x10, &regs, &regs );regs.h.ah = 0; int86( 0x10, &regs, &regs );}main(){cls();printf( Press any key to set border color to blue.\n );getchar();outp( CSReg, BLUE );} PROGRAMMING EXAMPLE FOR 40x25 COLOR MODE The 6845 registers may be programmed to select the appropiate video mode. This may be done via aROM BIOS call or directly. The values for each of the registers to program 40.25 color mode are, 38,28,2d,0a,1f,6,19,1c,2,7,6,7,0,0,0,0 The default settings for the registers for the various screen modes can be found in ROM BIOS listing'sand technical reference manuals.To program the various registers, first write to the address register at port 3d4, telling it which register you are programming, then write the register value to port 3d5. The mode select register must also be programmed. This is located at port 3d8. The sequence of events is,1: Disable the video output signal2: Program each register 3: Enable video output, setting mode register The following program illustrates how to do this, #include <conio.h> /* needed for outp() */#include <stdio.h> /* needed for getchar() */#include <process.h> /* needed for system calls */#define MODE_REG 0x3d8#define VID_DISABLE 0#define FOURTY_25 0X28#define ADDRESS_REG 0x3d4#define REGISTER_PORT 0x3d5static int mode40x25[] = {0x38,0x28,0x2d,0x0a,0x1f,6,0x19,0x1c,2,7,6,7,0,0,0,0 };void cls(){union REGS regs;regs.h.ah = 15; int86( 0x10, &regs, &regs );
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks