Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:19:29+00:00 2026-06-18T02:19:29+00:00

I was writing a bootsector based on a FAT12 filesystem. After a while I

  • 0

I was writing a bootsector based on a FAT12 filesystem. After a while I came up with a problem.

.FindBootSectorTwo:
    push SI
    push DI
    push CX
    mov CX, 11
    mov SI, BootloaderSTG2
    rep cmpsb
    pop CX
    pop DI
    pop SI
    je LOAD_BOOTLOADER_STG2
    nop
    add DI, 32
    loop .FindBootSectorTwo
    jmp ERROR_NOT_FOUND

This label searches for a file called BLS2.SYS and if it finds it, it jumps to LOAD_BOOTLOADER_STG2 label. The beginning of LOAD_BOOTLOADER_STG2 label:

LOAD_BOOTLOADER_STG2:
    push SI
    push CX
    push DI
    ;sub DI, 32
    mov SI, DI
    mov CX, 11
    call Printname
    pop DI
    pop CX
    pop SI
    pop DS

If I try to subtract 32 from DI, it gives me the right file name — BLS2.SYS, but if I don’t , I get only a bunch of spaces. What could be the problem here? Is this is a bug, that the program finds the wrong file, or I just don’t understand something here? I’m launching this code on Bochs, on a x86 machine. P.S. here’s the LOAD_ROOT label together with .FindBootSectorTwo.

LOAD_ROOT: ; in this label I search for an entry to Root directory, where my file is. When I find the root directory, I load it at: 0x0800:0x0000
mov [BS_DriveNumber], DL
mov AX, 0x0000
mov SS, AX
mov SP, 0x7C00
mov DS, AX
mov ES, AX
xor DX, DX
movzx AX, [BPB_NumberOfFATs]
mov BX, [BPB_SectorsPerFAT]
mul BX ; BX = NumFATS * SecPerFAT
mov BX, AX
add BX, [BPB_ReservedSectors] ; BX now contains LBA value aka NumFATS * SecPerFAT + ResvSecs
push DI
push ES
mov AX, [BPB_RootEntries]
shl AX, 5
xor DX, DX
div WORD[BPB_BytesPerSector] ; AL = (RootEntries * 32) / BytesPerSec
mov AH, 0x0002
push AX
mov AX, 0x0800
mov ES, AX ; ES = 0x0800
pop AX
mov DI, 0x0000
call ReadSectors
mov CX, [BPB_RootEntries]
push DS
push AX
mov AX, 0x0800
mov ES, AX
mov DS, AX
pop AX
mov DI, 0x0000
.FindBootSectorTwo: ; here I search for a file called BLS2.SYS (at 0x0800:0x0000), when I find it, the program jumps to LOAD_BOOTLOADER_STG2
    push SI
    push DI
    push CX
    mov CX, 11
    mov SI, BootloaderSTG2
    rep cmpsb
    pop CX
    pop DI
    pop SI
    je LOAD_BOOTLOADER_STG2
    nop
    add DI, 32
    loop .FindBootSectorTwo
    jmp ERROR_NOT_FOUND

If you need any additional peaces of code — tell me. I’ll give you whatever you need.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:19:30+00:00Added an answer on June 18, 2026 at 2:19 am

    The code is subtracting 32 from DI so points to the beginning of the file name string. Then you can print it accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing a python program, and I came up with this error while using the
I'm writing a bootsector for a FAT12 file system on a 1.44MB floppy disk
Writing another question for SO, I came to a pattern that I use very
Writing to a file is not working after hosting the web application, whereas they
Writing a 4-player iPhone game app with programmable mix of human/autoComputer players. After each
writing to a text file is working good...But my problem is text file is
Writing my first PHP Class and came across an issue, the following is my
Writing a function to generate and push some random data inside of the unknown
Writing Classic ASP code in JScript has a lot going for it: more humane
Writing htaccess that allows me to remove index.php from the URL can confuse search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.