I am working on a project using nasm and Virtual Machine. Having Head, Track and Sector, and the start value of the segment, I have to make a code with extension.sh. which will use this data so that I can write to floppy/ram specifically in the area calculated according to my values. For example, for this case:
The allocated sectors are within the limit 2281-2310
Head: 0 (0x0) Track: 14 (0xE) Sector: 63 (0x3F) to Header: 0 (0x7) Track: 7 (0x7) Sector: 64 (0x40) And the compilation code of the program that contains the bootloader, and the kernel (main) is as follows:
nasm -f bin -o boot.bin boot.asm &&
nasm -f bin -o menu.bin menu.asm &&
truncate boot.bin -s 1167872 &&
cat boot.bin menu.bin > boot.img &&
truncate boot.img -s 1474560 &&
rm boot.bin menu.bin
I understand why the number 1167872 is used here, it's because we multiply the start number of the sector by 512. 2281*512=1167872
But I have a second case, where the beginning of the sector is 511 to 540. Head = 0 Track = 28 (correctly it is 14, but for this code it corresponds to 28) and Sector = 8. And the code to create the image is as follows.
`#!/bin/bash
#build.sh
rm -f floppy.img
nasm -f bin -o 1s_bootloader.com 1s_bootloader.asm
truncate -s 1474560 1s_bootloader.com
mv 1s_bootloader.com floppy.img
nasm -f bin -o 2s_bootloader.com 2s_bootloader.asm
dd if=2s_bootloader.com of=floppy.img bs=512 count=2 seek=1 conv=notrunc
echo -n -e '\x46\x46' | dd of=floppy.img bs=1 count=2 seek=1534 conv=nottrunc
rm -f 2s_bootloader.com
nasm -f bin -o main.com main.asm
dd if=main.com of=floppy.img bs=512 count=2 seek=1015 conv=notrunc
echo -n -e '\x41\x4d\x4f\x47\x55\x53' | dd of=floppy.img bs=1 count=6 seek=520698 conv=notrunc
rm -f main.com`
And in this case I don't understand how to calculate the value, 1534, 1015, and 520698. What would be the formula or combination to obtain these numbers? and how it is calculated And if count has any importance, and these values '\x41\x4d\x4f\x47\x55\x53', '\x46\x46'.
What values should I enter in the code, build.sh so that it works for track 36, head 1, sector 8, Interval 1321-1350? Other details that would be important: Each block has 30 sectors; 15360 bytes for each block
I tried to divide this value seek=520698 by 512, as in the first case. But I don't get an integer. I tried to make a connection between these numbers, but I can't figure it out. I need help in determining the formula by which the second code was written.