OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 2:46 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Boot sector
PostPosted: Thu Dec 07, 2023 8:54 pm 
Offline

Joined: Thu Feb 02, 2023 5:13 pm
Posts: 3
With GPT we have this code as Boot Sector: section .text
Code:
    org 0x7C00
   
    mov bp, 0x7C00
    mov sp, bp
    mov ah, 0x0E

    mov al, 'O'
    int 0x10
   
    mov al, 'p'
    int 0x10

    mov al, 'S'
    int 0x10

    mov al, 'y'
    int 0x10

    mov al, 's'
    int 0x10

    mov al, '1'
    int 0x10
    jmp $

    times 510-($-$$) db 0
    dw 0xAA55 

Here we create .bin
nasm -f bin boot_sector.asm -o boot_sector.bin

create .img
fsutil file createnew boot_disk.img 1474560

copy
copy /B boot_sector.bin + boot_disk.img /B boot_disk.img
-----------------------------
after Oracle VM Box has decline this format, he recomend to convert

VBoxManage clonehd C:\boot_disk.img C:\boot_disk.vdi --format VDI

How do You think, can this work in principe? I not very trust GPT instruction.


Top
 Profile  
 
 Post subject: Re: Boot sector
PostPosted: Thu Dec 07, 2023 9:39 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
Code:
    mov sp, bp

The BIOS does not initialize SS. If you set SP without setting SS, your stack is at an unknown location.

Code:
    mov ah, 0x0E
    int 0x10

This BIOS call may modify AX, BP, SI, and DI. Your code relies on AH remaining unmodified, so your code may not work on some PCs.

Teuton wrote:
fsutil file createnew boot_disk.img 1474560
copy /B boot_sector.bin + boot_disk.img /B boot_disk.img

You create a disk image that's the correct size for a floppy disk, then you make it bigger when you add your boot sector, so the resulting file is the wrong size for a floppy disk.

Teuton wrote:
How do You think, can this work in principe?

Only if you correct the mistakes.

Teuton wrote:
I not very trust GPT instruction.

You shouldn't trust GPT. It doesn't know what it's talking about.


Top
 Profile  
 
 Post subject: Re: Boot sector
PostPosted: Thu Dec 07, 2023 10:49 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1605
Octocontrabass wrote:
Teuton wrote:
I not very trust GPT instruction.

You shouldn't trust GPT. It doesn't know what it's talking about.
I concur. GPT makes texts that look good but are complete nonsense. And especially in the case of source code, remembering where all the pieces go is important. This "bootloader" for example only prints a string (in a really circuitous way; I would have gone for a loop). Nothing is actually loaded. Because that part is quite difficult with lots of tradeoffs.

My advice for bootloaders remains the same: Use an existing one. Don't hobble yourself with implementing a new one and looking into all the different issues you may have. Especially when it comes to legacy (non-UEFI) ones, which are never going to be useful again.

_________________
Carpe diem!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group