# format floppy

What shoul I change the value of vector 1Eh to format a DMF floppy or any floppy for that matter

offset ; what should they be ; current vector 1Eh settings & description

; to format a DMF floppy

0 ; 223 bits 7-4 = Step rate (Fh=2ms,Eh=4ms,Dh=6ms,etc.); bits 3-0 = Head unload time (0Fh = 240 ms)

1 ; 2 bits 7-1 = Head load time (01h = 4 ms); bit 0 = Non-DMA mode (always 0)

2 ; 37 delay until motor turned off (in clock ticks)

3 2 ; 02h for 512 bytes per sector (00h = 128, 01h = 256, 02h = 512, 03h = 1024)

4 20 ; 63 is old sector size

5 ; 27 or 1Bh length of gap between sectors for 3.5 inch floppy

6 ; 255 data length (ignored if bytes-per-sector field nonzero)

7 ; 108 or 6Ch gap length when formatting 3.5 inch floppy

8 ; 246 format filler byte (default 246 = F6h)

9 ; 15 head settle time in milliseconds

0Ah ; 5 motor start time in 1/8 seconds

• You're on the wrong way, Paul!

Unsigned as well as signed bytes (or words) are stored the same way.

The only difference is how you interprete these 8 bits.

You may interprete them as 8 bit unsigned then values from 0 to 255 are possible (256 values!). In this case, the decimal value is calculated as usual:

bit value (dec)

7 2^7=128

6 ...

5 ...

4 ...

3 ...

2 ...

1 2^1=2

0 2^0=1

1001 1011(binary)= 2^7 + 2^4 + 2^3 + 2^1 + 2^0 = 128 + 16 + 8 + 2 + 1 = 145 (decimal)

If you interprete them as 8 bit _signed_ the value range is -128 to 127 (256 values).

In this case, only the 7 lower bits (bit 0 to 6) are used to calculate the value (0..127 = 128 values).

Bit 7 is used to indicate if the value is unsigned or signed:

- bit 7=0 : unsigned

-> the value is positive or zero (value>=0)

-> calculate the value from bit 0 to 6 as described above!

-> possible values: 0..127

- bit 7=1 : signed

-> the value is negative (but not positive nor zero)

-> calculate the value from bit 0 to 6 as descibed above AND substract 128

-> possible values: -128..-1

watch out: bit 7 set does NOT mean: calculate value from bit 0 to 6 and negate it!

for example: interprete 10011010 (binary) as signed value

10011010 (binary)

calculate value from bit 0 to 6:

0011010b = 2^4 + 2^3 + 2^1 = 26 (decimal)

bit 7 is set, so substract 128:

26 - 128 = -102

some samples:

bits

76543210 hex unsigned signed

00000000 00h 0 0

00000001 01h 1 1

00100000 20h 32 32

01111111 7Fh 127 127

10000000 80h 128 -128

10000001 81h 129 -127

10000002 82h 130 -126

10100000 A0h 160 -96

11111110 FEh 254 -2

11111111 FFh 255 -1

That's very easy! Just do it! The sign will be handled correctly (automatically!).

But do only substract signed byte from bytes and signed words from words. If you use different variable sizes your result will be wrong.

binary decimal

10100000 -96

+00111000 +56

--------------

11011000 -40

==============

I hope this text hasn't confused you even more,

blackbird