Basic Input Output System check hardware devices, in a process called POST (power on self test), like recognize ammount of memory, hard drivers and others devices...
The code (read code and/or data) inside bios are called firmware. So, bios offers a setup program to us configure devices on the motherboard.
The firmware offers too some interruptions, so, you can use bios code to reach some facilities while coding (using 'int' instruction).
When you wakeup you computer, bios get the control, check everything, if find some problems, it send a speaker sound (beeps), if not, it access the code on specific offset, on configured boot device, and that will wakeup the O.S.
The batery (cmos) hold your saved configuration, and if you like to reset that information, remove the batery and generate a short-circuit on specifc jumper (to discharge the capacitor).
Bios know a valid boot code by searching by a signature (55aah, or 0aa55h, I forgot), generaly on the first sector of that device.
One day, i was updating 5 same computer bios (same motherboard), and on the half of write process to bios, blackout ocurred. After, I was able to put computer on, but bios code does not work, appears to me like a standby mode. So, how can I update bios using an image inside floppy if I cannot access floppy?
So, I removed that chip (integrated circuit), put a good one (removed from other motherboard) on that motherboard, turn computer on, read their code to update, and before write, with much patience and carefully to not create a short-circuit, I removed the good bios chip, put the damaged (firmware) one, and after started the write process. I was able to restore the damaged bios code. This was my last choice, and worked.
So, if I was able to update that internally bios code, we can create functions too and insert in that bios, like let's supose, optimized strlen function, and access then using interruptions or probably other ways. Not the best place to put that function, but... . From ms-dos times, I remember one debug program that offers you an easy way to overwrite specific memory places (like video rom bios). In today days, I remember see some discussions on vmware board about bios code and testing.
Old bios have only a rom part, new ones offers you a writeable part.