0

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
nrz
  • 10,435
  • 4
  • 39
  • 71
Dumitru
  • 771
  • 2
  • 12
  • 23

1 Answers1

0

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 ...

valplo
  • 693
  • 5
  • 13
  • I'm not sure the second part is true, since writing on 2 sequential sectors with the same head yields data separated exactly by 512 bytes, instead of 1024. Also, can you elaborate on the head-cylinder relationship? A link, maybe, where this is explained. – Dumitru Nov 16 '13 at 21:30
  • https://en.wikipedia.org/wiki/Cylinder-head-sector, in particular https://en.wikipedia.org/wiki/Cylinder-head-sector#CHS_to_LBA_mapping. – valplo Nov 16 '13 at 22:06
  • 1
    After a few tests, I finally understood the data layout on the floppy. Please edit your answer, since the head is incremented only when all 18 sectors of the first HT are passed, i.e. HTS 001 002 ... 0018 101 ... – Dumitru Nov 17 '13 at 18:10