I'm trying to write to a sector on the second cylinder of a floppy image. For a test I tried writing the numbers 1-9 on the first sector of the second cylinder.
The logic would be that, having 18 sectors on a cylinder, and every sector being 512 bytes, this result should appear at byte 9216/0x2400 (following byte 8704/0x2200 which is the 18th sector of the first cylinder). Strangely, after checking the results with hexdump
the sequence resides at byte 18432/0x4800 instead.
I would like to understand why the 1st and 2nd cylinder of the floppy (in perspective of the assembly program) are not contiguous.
The NASM assembly program:
org 7c00h
jmp begin
data db 1,2,3,4,5,6,7,8,9
begin:
mov ax, 0
mov es, ax
mov bx, data
mov al, 1
mov ah, 3
mov dh, 0
mov dl, 0
mov ch, 1
mov cl, 1
int 13h
There are, in fact, 36 sectors on a cylinder, since the floppy is two-headed. The raw .img stores sectors sequentially alternating sides:
HTS 001 002 ... 0018 101 ...