I\'m not crazy, just reinventing the wheel :D
I wrote boot-loaders, mouse & keyboard mini-drivers, mini OS and so on.
I\'m always trying to avoid DOS inter
BIOS can be written in any of your favorite language, although lower level languages give you more control. Assembly and machine code are almost the same, the difference being microcode interface and what you type, eg. for machine code you'd only type 2 characters, and assembly give you alphanumerics. My hunt for custom BIOS began when I needed computer to boot up every few hours and haven't found any BIOS that does that.
To flash BIOS, follow manufacturer guidelines. BIOS has now been replaced with UEFI (for added security). Checkout: https://www.pcworld.com/article/187437/how-to-update-your-bios.html
x86 and amd64 instruction reference: https://www.felixcloutier.com/x86/
x86 instructions with extensions: https://en.wikipedia.org/wiki/X86_instruction_listings
i386 instruction ref: https://css.csail.mit.edu/6.858/2014/readings/i386.pdf
x86 Assembly Guide: https://www.cs.virginia.edu/~evans/cs216/guides/x86.html
Intel Instruction Set Ref: https://software.intel.com/sites/default/files/managed/a4/60/325383-sdm-vol-2abcd.pdf
A BIOS can be written in assembly but doesn't have to be, some parts need to be to get the parameters for the system call since they don't match the compilers calling convention.
How do you flash it? Varies from motherboard to motherboard, I would start with an open source virtual machine and write a bios for that. Or create a virtual machine where you have written the bios. The mechanism varies from vendor to vendor, generally you boot dos (dos is not dead, it is very much alive in the PC world, esp motherboard development and embedded systems). I wouldn't mess around with a real motherboard, if you don't already know the answers to all of these questions you are going to brick a number of motherboards if you take that path.
You can try to take a bios upgrade for your mother board and reverse engineer it (although there is probably a click through agreement that says that you wont). If you figure it out you can both load it and hack at at. I wouldn't go there, you will brick your system before you figure it out.
Is writing a bios really what you are after? Fairly old school, would be like writing 6502 code for fun. There are many low level problems that are more useful and as interesting.
If you can write asm the writing machine code is not that difficult at all, you could just go do that for fun. x86 is dreadful, you should spend some time learning other systems and their asm and machine code (and writing operating systems for them). ARM dominates the world and doesn't rely on a bios. I have been told that to get a video card up on a non-x86 system you still have to fiddle something in x86 on the x86 bios, could figure out how to bring up a mainstream video card without the need to run the x86 bios. watch an emulator run the bios and see what it does, figure it out replace that power on init without the bios doing it...Writing an instruction set simulator or disassembler is the next step beyond writing machine code, I wouldn't waste even a second of time on x86 though, I can suggest a list of alternatives (or you could just play with the simulators I have written or collected).
If an x86 bios is the way you want to go, your best path is to write, replace, or hack on a bios for a virtual machine being qemu, virtualbox, or other. Replacing that bios with yours would likely be replacing a file in some directory or using a command line option to specify an alternate bios. Once you are well experienced in that then if there are still motherboards with legacy bioses on them perhaps you can hack your way into programming one (need to buy several of each type of motherboard as you WILL brick some). With so many embedded systems out there that can be had for $20 to $200 with the same level of experience gained, it doesn't make sense to hack on a pc motherboard without decent schematics and documentation. You could dig up an original PC with the schematic and bios listing being documented, and the bios being socketed so if yours doesn't boot (and doesn't destroy the motherboard) it isn't a brick you can reprogram or replace the bios chip. Probably want to use a microcontroller to stand in as a fake bios, as finding the right hardware to reprogram more bios chips is perhaps harder to find that working original PC's...There is an amiga community that is likely a lot more fun and would be happy to have you improving/tweaking their bios, say putting modern hardware behind the legacy system calls.
FWIW Modbin is a DOS program that as the name suggests MODifies BIN images especially for the purpose of both simple qnd fairly extreme changes to existing BIOS code.
If you can obtain an old mobo (many are thrown away still working) I would encourage you to play around with the BIOS. It's informative and fun, if one is so inclined and you seem to be :) There was a time that I downloaded BIOS images from mobos that had the same or similar enough chipsets though made by a different manufacturer...sometimes to considerable advantage including such simple ones as continuing to get BIOS updates after the original mobo manufacturer dropped the ball or went belly up, but also features and performance oriented options and alterations.
This led to "HOT Flashing" which is pulling up a socketed BIOS chip so that the pins just barely made contact and once booted up, pulling that one and substituting a bad one (often one I had fuxored) while still running and flashing it employing the cached BIOS feature that kept the system active. Fun stuff for those of us of the geek persuasion and gave me the confidence to write device drivers for OS/2
There are ways to flash the bios other than to have the pc running perhaps. But it requires some hardware. Shouldn't be very expensive though.
You could try something like this kind of tecnique: http://hackaday.com/2010/11/18/build-your-own-soic-progamming-clip/
This talk i saw today: https://conference.hitb.org/hitbsecconf2015ams/sessions/how-many-million-bioses-would-you-like-to-infect/
It explained it in more detail, though you might not be looking for infection, some tecniques for getting to the bios are covered, where the programming clip is one of them.
If you want to write a BIOS for an IBM PC Compatible computer (which is what the majority of desktop PCs are today, albeit with more extensions to the CPU instruction set, and some different BUS interfaces), then I suggest you look through the IBM PC, IBM PC XT, and IBM PC AT Technical Reference Manuals. Particularly the IBM PC AT manual, as that is what the de-facto standard is.
These manuals have a program listing of the complete BIOS that IBM used on their computers, and they are in assembly language. You might have to hunt through those manuals a little bit (especially the IBM PC AT one) to find them, as some aren't directly listed in the table of contents, but they are there. Hopefully those BIOSs can get you started.