# BIOS Programming



## jeriddian (Apr 7, 2007)

Hi guys,
I'm new to the forum. I run a large system with a gamer's board, P4 3.8 GHz, 8 GB RAM, Mirrorred 300 GB HDD, Radeon X1900XTX video card on an Apple 30" display, running XP Pro for now. I do a lot of graphics stuff with it.

But I also have a hobby restoring old computers, and right now I am restoring some old 80386 laptops that are 20 years old. Part of what I am doing is going to have to involve dealing with the hardware and the BIOS on these systems which is very primitive, of course, but also not that complicated. I just have to figure the different routines out.

My question right now that I cannnot quite figure out is as follows. When the computer boots up, at what address on the ROM BIOS does the CPU begin to read instructions? The beginning of this BIOS code with which I'm working begins with the manufacturer's identification string, and doesn't seem to get to any identifiable code until address 005Ah, which seems strange to me. Also I still don't know if the CPU will actually start reading instructions there. Looking over the code I can't pick out a more likely starting spot. I have disassmebled the BIOS code into an ASM file, and once I have edited the code, I can compile it back specifically for a BIOS and then exe2bin it into the raw BIN file (then I can burn the EPROMS). But this is the particular problem I have been having.

As I recall, in a DOS .EXE file PSP, the first byte is MZ which tells the computer its an EXE file, and then it will read until it sees the 'start to read instruction' code (I forget the hex number of it. got to look that up again), but I don't think they use that convention for the BIOS. Does anyone have any info as to from what address the CPU gets the first instruction to start booting the computer out of the ROM BIOS? Thanks for the help guys.


----------



## JohnWill (Oct 19, 2002)

The reset vector for the 80386DX and later x86 processors is 0xFFFF0, although the value of the CS register at reset is 0xF000 and the value of the IP register at reset is 0xFFF0. In actuality, current x86 processors fetch from the physical address 0xFFFFFFF0. This is due to a hidden base address portion of the CS register in real mode which defaults to 0xFFFF0000 after reset.

The "reset vector" is the address to fetch the first instruction, it's a 32 bit word pointing to the instruction to be executed.


----------



## jeriddian (Apr 7, 2007)

Thanks, JohnWill,
That helps me get started. I'm also working with a couple of 80386SX machines and one machine which is an 80286 laptop. I guess the reset vector for the 286 would be the same except cut down to the low 16 bits. Can I assume then that the reset vectors for an 80386SX is the same as the DX, and the physical addresses of the reset vector for the 80286 would be those 16 bit equivalents (the low bits)?


----------



## JohnWill (Oct 19, 2002)

The reset vector is always in high memory for the x86 family. Remember, the 80286 addresses 16mb as I recall in real mode.  In any case, if you look at a BIOS image, the reset vector is in the last 16 bytes.


----------

