Download presentation
Presentation is loading. Please wait.
Published byDerek Rogers Modified over 8 years ago
1
ROM BIOS Chapter 9
2
The ROM BIOS PC computer come with a set od built in routines collectively called the ROM BIOS. These routines are permanent part of machine. C program can make use of these routines to perform a variety of input/output activities
3
Advantages of Using ROM BIOS Mostly handle input/output operations, Some of routines duplicates C library functions. e.g. there is a BIOS routine to put a character on the screen, similarly in operation to putch() /getche() Many of routines that are built into ROM, However there is no equivalent in C. the most important capability lacking in the C library is in graphics For example to change graphics modes or to put dot on the graphics screen required a call to ROM BIOS routine
4
ROM BIOS Library Dozens of ROM BIOS routines, The exact number depends on the PC Family of computer Largest category dealing with video display e.g. set the video mode, control the cursor size and position, read and write character, and place dots on the color screen, among others There are also ROM routines for others input/output devices, including the diskette drives, the serial port, the cassette reader, user-defined devices, the keyboard, and the printer
5
Accessing the ROM BIOS The ROM BIOS routines are written in assembly language and were designed to be called by assembly language programs Calling from C is not as simple as calling C library functions Understanding of microprocessor chip that power on the computer is required Chip can be 8086,80286,80386, or 80486, depends on the particular machine
6
Microprocessor Architecture for C Program strcat(s1,s2) values placed in an area of memory called stack, where the function can find and operate on them When we use C to call BIOS routine, instead of values being placed in an area of memory, they are placed in hardware device called registers.
7
Registers Registers are like memory locations but they have far more capabilities. Registers are the heart of microprocessor. They are used to perform arithmetic and many other operations Few of microprocessor registers are AX,BX,CX and DX, consists of two Bytes. Upper or lower case can be used for register names Registers are like integer variables in C, Hold two bytes of data Unlike C variables, registers are fixed, they always there and they always have same name. they can thought of as special- purpose permanent variables Registers can be access in two different ways: either as four two-bytes registers, or as eight one-bytes registers
8
Registers In the on-byte interpretation each register is split into a high half(AH,BH,CH and DH) and low half (AL,BL,CL,DL) Register itself is the same physical object whether used as one two-bytes device or two one bytes devices. The rest of hardware in the chip interprets each differently and so each must be accessed differently by the software Union is the mechanism used to communicate with the registers
9
Interrupt Numbers An interrupt provides access to a group of ROM BIOS routines An interrupt can be group of functions and each of these groups has its own interrupt number For instance, all the routines that deal with the video display used interrupt number 10(hex) and all those that deal with the disk drive used number 13(hex) To specify routines with in one of these groups, we place a value in one-byte AH register. Various other registers may also hold values, depending on the specific function called
10
int86() Function The “int” stand for interrupt and the “86” refers to the 80x86 family of chip int86(interrupt number, &inregs,&outregs)
11
Find the Memory Size of RAM ROM BIOS routine : Memory size Interrupt 12 hex:Memory size Input registers: None Output registers: AX-memory size in Kbytes #include #define VIDEO 0x12/* BIOS interrupt */ main() { struct WORDREGS/* registers as 16-bit words */ { unsigned int ax; unsigned int bx; unsigned int cx; unsigned int dx; unsigned int si; unsigned int di; unsigned int flage; };
12
prints memory size struct BYTEREGS/* registers as 8-bit words */ { unsigned char al,ah; unsigned char bl,bh; unsigned char cl,ch; unsigned char dl,dh; }; union REGS/* either bytes or words */ { struct WORDREGS x; struct BYTEREGS h; }; union REGS regs;/* regs to be type union REGS */ int size; int86(VIDEO,®s,®s);/* call video interrupt */ size =regs.x.ax;/* get value from AX register */ printf("Merory size is %d kbytes",size); }
13
Setting the cursor size On the Monochrome screen, the cursor consists of 14 short horizontal lines (0-13) EGA color display have only 9 lines (0-8) – ROM BIOS routine: Set cursor size – Interrupt 10 hex: Video – Input registers: AH=01 CH= start scan line (0-13 dec) CL= ending scan line (0-13 dec) – Output register None
14
sets cursor size #include #include "dos.h"/* declares REGS */ #define CURSIZE 1/* "set cursor size: service */ #define VIDEO 0x10/* vidio BIOS interrupt number */ void main( int argc,char *argv[]) { union REGS regs; int start,end; if(argc !=3) { printf("Example usage: C>sector 12 13"); exit(); } start=atoi(argv[1]);/* string to integer */ end=atoi(argv[2]); regs.h.ch=(char)start;/* starting line number */ regs.h.cl=(char)end;/* endinbg line number */ regs.h.ah=CURSIZE;/* service number*/ int86(VIDEO, ®s, ®s);/* call video interrupt */ }
15
Making the cursor disappear Set Bit 5 one in CH register to disappear cursor To reappear cursor set zero, no matter which values used for starting and stopping lines Hex 20 in binary – 00010000 #include #include /* declares REGS */ #define cursize 1/* "set cursor size" service */ #define VIDEO 0x10/* video BIOS interrupt nmber */ #define stopbit 0x20/* this bit turns cursor off */ void main(void) { union REGS regs; regs.h.ch=STOPBIT;/* turns cursor off */ regs.h.ah=CURSIZE;/* service number */ int86(VIDEO, ®s, ®s);/* call video interrupt */ }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.