flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Programing a Bootstrap

Author
Thread Post new topic Reply to topic
connor



Joined: 07 Jun 2016
Posts: 79
connor 06 Jun 2019, 04:38
What im thinking about now is mastering the art of making a custom boot program.

To load a file of my choice, in my case a custom cpm86.sys file

and not just that,

to boot in 34/64 bir real mode.


HOW DOES BOOT WORK?


Description: other versions of the cpm system files
Download
Filename: SYS LOADING PRJ.zip
Filesize: 163.58 KB
Downloaded: 841 Time(s)


_________________
cars tech weed bitches country & thug life


Last edited by connor on 24 Oct 2019, 04:13; edited 2 times in total
Post 06 Jun 2019, 04:38
View user's profile Send private message Reply with quote
connor



Joined: 07 Jun 2016
Posts: 79
connor 12 Jun 2019, 04:49
putting it in another way;

How do you code a floppy, usb, hard drive or a cd to boot on start up?


a boot disk from scratch?


in 32/64 real mode?

thats supposed to be a question

_________________
cars tech weed bitches country & thug life
Post 12 Jun 2019, 04:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 12 Jun 2019, 06:58
Normally a boot sector can't do too much, so it simply loads in more sectors from a fixed location on the HDD/SSD to a fixed location in memory and runs that new code. Often the fixed location is just the next sectors after the boot sector. You might find that referred to as a second stage boot loader.

Form there, with more code to do more things it can do much more. So you can have various functions to decode the disk format and find a boot file, switch to 32-bit unreal, or 32-bit protected, or 64-bit protected mode. Or generally whatever is needed. You don't even have to have a disk format in place, or even an OS, your code can be a simple single purpose application.
Post 12 Jun 2019, 06:58
View user's profile Send private message Visit poster's website Reply with quote
connor



Joined: 07 Jun 2016
Posts: 79
connor 14 Jun 2019, 06:30
Any exapmles?

& can it all be done with a assembly compiler or do i need something special?
Post 14 Jun 2019, 06:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 14 Jun 2019, 06:47
There are a few examples of boot sectors on this board. Have a look in the OS Construction forum.

You can do everything with assembler. You don't need anything special.
Post 14 Jun 2019, 06:47
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 28 Jul 2019, 02:12
You can look at FreeDOS (though it uses NASM).
Post 28 Jul 2019, 02:12
View user's profile Send private message Visit poster's website Reply with quote
bzt



Joined: 09 Nov 2018
Posts: 77
bzt 21 Sep 2019, 15:38
connor wrote:
Any exapmles?

& can it all be done with a assembly compiler or do i need something special?
Boot records are explained in great detail on this site. Also contains the disassembly with tons of comments. The linked boot record reads a file from a FAT filesystem into memory (IBMDOS.COM) and then transfers control to it.

There are other disassembled examples as well, eg. Windows floppy boot sector and Windows disk boot sector (for FAT32).

Also the xv6 boot sector simply loads the kernel starting from the second sector (although this code has a minimal part written in C for ELF loading).

Obviously, if you want to load an executable that was compiled for 32 bit protected mode, then you'll have to set up protected mode before you transfer the control (same stands for 64 bit long mode). This can be done in the boot sector if you're very talented and experienced, but it's more common to have a minimal trampoline code in the executable (meaning the function _start (being the entry point) is compiled for real-mode, which sets up whatever mode you need and then jumps to the real main function). Or you could implement a two stage loader, in which case the boot sector loads the second stage, which in turn are free to load the executable from any filesystem and set up any mode for it without the 512 byte size constraint.

For a two stage loader example, take a look at my boot loader. This does not support floppies (LBA mode only), but it is compatible with the no emulation El Torito CD-ROM boot standard as well, and it is written for FASM. It loads the second stage from a configurable starting sector.
Post 21 Sep 2019, 15:38
View user's profile Send private message Reply with quote
connor



Joined: 07 Jun 2016
Posts: 79
connor 26 Oct 2019, 04:14
Laughing


Description: .
Download
Filename: CCPM86 31 DSK set non bootable.zip
Filesize: 288.94 KB
Downloaded: 751 Time(s)


_________________
cars tech weed bitches country & thug life
Post 26 Oct 2019, 04:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.