1 ; **************************************************************************** 2 ; FDISK4R5.ASM (FDISK4R5.COM) - Retro DOS v5 Hard Disk Partitioning Utility 3 ; fdisk4.s (for MSDOS/WINDOWS) 4 ; **************************************************************************** 5 ; 32 bit cylinder numbers modification on fdisk3.s (2TB hardisk partitioning) 6 ; ---------------------------------------------------------------------------- 7 ; Last Update: 29/01/2026 8 ; ---------------------------------------------------------------------------- 9 ; Beginning: 05/11/2020 10 ; ---------------------------------------------------------------------------- 11 ; Assembler: NASM version 2.15 12 ; ---------------------------------------------------------------------------- 13 ; Modified from 'FDISK4.ASM' (FDISK4.COM) source code by Erdogan Tan 14 ; (04/05/2024) - TRDOS 386 v2 fixed disk partitioning utility - 15 ; **************************************************************************** 16 ; nasm fdisk4r5.s -l fdisk4r5.txt -o FDISK4R5.COM -Z error.txt 17 18 ; Masterboot / Partition Table at Beginning+1BEh 19 ptBootable equ 0 20 ptBeginHead equ 1 21 ptBeginSector equ 2 22 ptBeginCylinder equ 3 23 ptFileSystemID equ 4 24 ptEndHead equ 5 25 ptEndSector equ 6 26 ptEndCylinder equ 7 27 ptStartSector equ 8 28 ptSectors equ 12 29 30 ; BIOS Disk Parameters 31 DPDiskNumber equ 0h 32 DPDType equ 1h 33 DPReturn equ 2h 34 DPHeads equ 3h 35 DPCylinders equ 4h 36 DPSecPerTrack equ 6h 37 DPDisks equ 7h 38 DPTableOff equ 8h 39 DPTableSeg equ 0Ah 40 DPNumOfSecs equ 0Ch 41 42 ; BIOS INT 13h Extensions (LBA extensions) 43 ; Just After DP Data (DPDiskNumber+) 44 DAP_PacketSize equ 10h ; If extensions present, this byte will be >=10h 45 DAP_Reserved1 equ 11h ; Reserved Byte 46 DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127 47 DAP_Reserved2 equ 13h ; Reserved Byte 48 DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET 49 DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1 50 ; C1= Selected Cylinder Number 51 ; H0= Number Of Heads (Maximum Head Number + 1) 52 ; H1= Selected Head Number 53 ; S0= Maximum Sector Number 54 ; S1= Selected Sector Number 55 ; QUAD WORD 56 ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh 57 ; QUAD WORD (Also, value in 0h must be 18h) 58 ; TR-DOS will not use 64 bit Flat Address 59 60 ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters" 61 ; Just After DP Data (DPDiskNumber+) 62 GetDParams_48h equ 20h ; Word. Data Lenght, must be 26 (1Ah) for short data. 63 GDP_48h_InfoFlag equ 22h ; Word 64 ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid. 65 GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders. 66 GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads. 67 GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track. 68 GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors. 69 GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector. 70 71 pTableOffset equ 1BEh ; 446 72 73 ; Convert LBA to CHS 74 ; 08/02/2019 75 76 ; LBA = ((C1*H0+H1)*S0)+S1-1 77 ; 78 ; C1 = Selected Cylinder Number 79 ; H0 = Number of Heads (Maximum Head Number + 1) 80 ; H1 = Selected Head Number 81 ; S0 = Maximum Sector Number 82 ; S1 = Selected Sector Number 83 ; 84 ; Phoenix, Enchanced Disk Drive Specicifications, v1.1, Page 8) 85 86 [BITS 16] 87 [ORG 100h] 88 89 ; Note: 80386 cpu is required (this program will not run on 80286 systems) 90 91 ; Detect 80386 cpu (386+) 92 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 93 ; detect 386+ cpu 94 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 95 ; 06/11/2020 96 ; (https://forum.osdev.org/viewtopic.php?p=36822) 97 ; (ogotay) 98 99 00000000 9C pushf 100 00000001 B4D0 mov ah, 0D0h 101 00000003 50 push ax 102 00000004 9D popf 103 00000005 9C pushf 104 00000006 58 pop ax 105 00000007 9D popf 106 00000008 80FC50 cmp ah, 50h 107 0000000B 7408 je short _386_ok 108 109 ; Write program message and terminate 110 111 0000000D BE[BE40] mov si, TrDOS_Welcome 112 00000010 E8B419 call print_msg 113 114 00000013 CD20 int 20h 115 116 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 117 _386_ok: 118 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 119 120 ;cli 121 ;cld 122 ;push cs 123 ;pop ss 124 ;mov sp, 0FFFEh 125 ;sti 126 127 ;mov bx, SizeOfFile+100 128 129 00000015 BB[FC6D] mov bx, bss_end 130 131 00000018 83C30F add bx, 15 132 0000001B D1EB shr bx, 1 133 0000001D D1EB shr bx, 1 134 0000001F D1EB shr bx, 1 135 00000021 D1EB shr bx, 1 136 00000023 B44A mov ah, 4Ah ; modify memory allocation 137 ;push cs 138 ;pop es 139 00000025 CD21 int 21h 140 141 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 142 ; clear BSS 143 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 144 ; 03/02/2019 145 146 ;mov cx, bss_end 147 00000027 B9[8E6C] mov cx, bss_clear_end ; 15/02/2019 148 149 0000002A BF[4665] mov di, bss_start 150 0000002D 29F9 sub cx, di 151 0000002F 41 inc cx 152 00000030 D1E9 shr cx, 1 153 00000032 31C0 xor ax, ax 154 00000034 F3AB rep stosw 155 156 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 157 ; display program name & version 158 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 159 160 00000036 BE[BE40] mov si, TrDOS_Welcome 161 00000039 E88B19 call print_msg 162 163 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 164 ; get hard disk name 165 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 166 ; 11/10/2020 167 168 0000003C BE8000 mov si, 80h ; PSP command tail 169 0000003F AC lodsb 170 00000040 08C0 or al, al ; command tail length 171 00000042 7431 jz short A_05 ; jump if zero 172 A_01: 173 00000044 AC lodsb 174 00000045 3C20 cmp al, ' ' ; is it SPACE ? 175 00000047 74FB je short A_01 176 00000049 722A jb short A_05 177 178 ; check disk name 179 180 0000004B 3C68 cmp al, 'h' 181 0000004D 751B jne short A_03 182 0000004F 803C64 cmp byte [si], 'd' 183 00000052 7516 jne short A_03 184 00000054 46 inc si 185 00000055 AC lodsb 186 00000056 3C30 cmp al, '0' 187 00000058 7406 je short A_02 188 0000005A 720E jb short A_03 189 0000005C 3C33 cmp al, '3' 190 0000005E 770A ja short A_03 191 A_02: 192 00000060 803C20 cmp byte [si], ' ' 193 00000063 720B jb short A_04 194 00000065 7703 ja short A_03 195 00000067 46 inc si 196 00000068 EBF6 jmp short A_02 197 A_03: 198 0000006A BE[1F41] mov si, TrDOS_Usage 199 0000006D E90207 jmp _p_exit 200 A_04: 201 00000070 0450 add al, 80h - '0' 202 00000072 A2[4665] mov [DrvNum], al ; 80h .. 83h 203 204 A_05: 205 206 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207 ; get hard disk parameters 208 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 209 ; 11/10/2020 210 211 ; check bios int 13h extensions 212 00000075 B441 mov ah, 41h 213 00000077 BBAA55 mov bx, 55AAh 214 0000007A B280 mov dl, 80h 215 0000007C CD13 int 13h 216 0000007E 720B jc short A_06 217 00000080 81FB55AA cmp bx, 0AA55h 218 00000084 7505 jne short A_06 219 220 00000086 C606[A62E]01 mov byte [int13h_x], 1 221 A_06: 222 ;mov dl, 80h ; hd0 223 0000008B B408 mov ah, 08h ; return disk parameters 224 0000008D CD13 int 13h 225 0000008F 7313 jnc short A_10 226 A_07: 227 00000091 803E[4665]80 cmp byte [DrvNum], 80h ; hard disk name option ? 228 00000096 7206 jb short A_09 ; no, default 229 A_08: 230 00000098 BE[CE60] mov si, msg_drv_not_ready ; drive not ready 231 0000009B E9D406 jmp _p_exit 232 A_09: 233 0000009E BE[F860] mov si, msg_not_any_disks ; there is not a hard disk 234 000000A1 E9CE06 jmp _p_exit 235 A_10: 236 000000A4 08E4 or ah, ah ; ah = 0 ? 237 000000A6 75E9 jnz short A_07 ; no, there is an error ! 238 239 000000A8 8816[4765] mov [hdc], dl ; number of hard disks 240 241 000000AC A0[4665] mov al, [DrvNum] 242 243 000000AF 3C80 cmp al, 80h 244 000000B1 7308 jnb short A_11 ; option 245 ; default 246 000000B3 C606[4665]80 mov byte [DrvNum], 80h 247 000000B8 E98D00 jmp A_14 248 A_11: 249 ; hard disk name option 250 000000BB 80C27F add dl, 7Fh 251 252 000000BE 38D0 cmp al, dl 253 000000C0 77D6 ja short A_08 254 255 000000C2 80FA80 cmp dl, 80h 256 000000C5 760C jna short A_13 ; hd0 parameters are ready 257 A_12: 258 000000C7 88C2 mov dl, al ; [DrvNum] 259 260 000000C9 B408 mov ah, 08h ; return (get) disk parameters 261 000000CB CD13 int 13h 262 000000CD 72C2 jc short A_07 263 000000CF 08E4 or ah, ah 264 000000D1 75BE jnz short A_07 265 A_13: 266 000000D3 88C8 mov al, cl 267 000000D5 243F and al, 3Fh ; 63 268 000000D7 C0E906 shr cl, 6 269 000000DA 86E9 xchg ch, cl 270 000000DC 41 inc cx 271 000000DD 41 inc cx ; 15/10/2020 ; BIOS BugFix 272 ; (for reserved last cylinder) 273 000000DE 890E[BE3C] mov [cylinders], cx 274 ;mov word [cylinders+2], 0 ; 16/10/2020 275 000000E2 FEC6 inc dh 276 000000E4 8836[BC3C] mov [heads], dh 277 000000E8 A2[BA3C] mov [sectors], al 278 000000EB F6E6 mul dh 279 000000ED A3[086A] mov [hs], ax ; heads*sectors ; 15/10/2020 280 000000F0 F7E1 mul cx 281 000000F2 A3[4A65] mov [disksize], ax 282 000000F5 8916[4C65] mov [disksize+2], dx 283 000000F9 83E801 sub ax, 1 ; 17/10/2020 284 000000FC 83DA00 sbb dx, 0 285 000000FF A3[4E65] mov [chs_limit], ax 286 00000102 8916[5065] mov [chs_limit+2], dx 287 288 00000106 803E[A62E]01 cmp byte [int13h_x], 1 289 0000010B 0F82D500 jb A_20 290 291 0000010F BE[E26D] mov si, gdp_buffer 292 ;mov word [si], 30 ; buffer length (minimum) 293 00000112 C7041A00 mov word [si], 26 ; buffer length (minimum) 294 00000116 B448 mov ah, 48h 295 00000118 8A16[4665] mov dl, [DrvNum] 296 0000011C CD13 int 13h 297 0000011E 0F82C200 jc A_20 298 00000122 20E4 and ah, ah 299 00000124 0F85BC00 jnz A_20 300 301 ; 06/11/2020 302 ; number of physical sectors 303 ;mov ax, [si+16] 304 ;mov dx, [si+18] 305 ;mov [disksize], ax 306 ;mov [disksize+2], dx 307 308 00000128 668B4410 mov eax, [si+16] 309 0000012C 66A3[4A65] mov [disksize], eax 310 00000130 6631D2 xor edx, edx 311 312 ; 15/10/2020 313 ;mov cx, [hs] 314 ;call div32 315 ;; 16/10/2020 316 ;;mov [lba_cyls], ax 317 ;;mov [lba_cyls+2], dx 318 ;mov [cylinders], ax 319 ;mov [cylinders+2], dx 320 ;mov [lba_chs_remain], bx 321 322 ; 06/11/2020 323 00000133 66F736[086A] div dword [hs] 324 00000138 66A3[BE3C] mov [cylinders], eax 325 0000013C 8916[5265] mov [lba_chs_remain], dx 326 ; reset 327 00000140 6631C0 xor eax, eax 328 ;xor edx, edx 329 00000143 31D2 xor dx, dx 330 331 00000145 E99C00 jmp A_20 332 A_14: 333 00000148 80FA01 cmp dl, 1 334 0000014B 7686 jna short A_13 ; [DrvNum] = 80h 335 336 0000014D 80C230 add dl, '0' ; '2' to '4' 337 00000150 8816[E441] mov byte [TrDOS_dnmax], dl 338 339 00000154 BE[C641] mov si, TrDOS_Options 340 00000157 E86D18 call print_msg 341 342 ; check bios int 13h extensions 343 0000015A 803E[A62E]01 cmp byte [int13h_x], 1 344 0000015F 732D jnb short A_16 345 A_15: 346 00000161 8A16[4665] mov dl, [DrvNum] 347 00000165 B408 mov ah, 08h ; return disk parameters 348 00000167 CD13 int 13h 349 00000169 724D jc short A_17 350 0000016B 08E4 or ah, ah 351 0000016D 7549 jnz short A_17 352 353 0000016F 88C8 mov al, cl 354 00000171 243F and al, 3Fh ; 63 355 00000173 C0E906 shr cl, 6 356 00000176 86E9 xchg ch, cl 357 00000178 41 inc cx 358 00000179 FEC6 inc dh 359 0000017B F6E6 mul dh 360 0000017D F7E1 mul cx 361 362 ; dx:ax = disk size 363 364 0000017F E85602 call display_hd_row 365 366 00000182 FE0E[4765] dec byte [hdc] 367 00000186 7430 jz short A_17 368 00000188 FE06[4665] inc byte [DrvNum] 369 0000018C EBD3 jmp short A_15 370 A_16: 371 0000018E BE[E26D] mov si, gdp_buffer 372 ;mov word [si], 30 ; buffer length (minimum) 373 00000191 C7041A00 mov word [si], 26 ; buffer length (minimum) 374 00000195 B448 mov ah, 48h 375 00000197 8A16[4665] mov dl, [DrvNum] 376 0000019B CD13 int 13h 377 0000019D 72C2 jc short A_15 378 0000019F 20E4 and ah, ah 379 000001A1 75BE jnz short A_15 380 381 ; number of phsical sectors 382 000001A3 8B4410 mov ax, [si+16] 383 000001A6 8B5412 mov dx, [si+18] 384 385 ; dx:ax = disk size 386 387 000001A9 E82C02 call display_hd_row 388 389 000001AC FE0E[4765] dec byte [hdc] 390 000001B0 7406 jz short A_17 391 000001B2 FE06[4665] inc byte [DrvNum] 392 000001B6 EBD6 jmp short A_16 393 A_17: 394 000001B8 BE[7452] mov si, CRLF 395 000001BB E80918 call print_msg 396 397 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 398 ; hard disk number input (getchar) 399 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 400 ; 11/10/2020 401 402 A_18: 403 000001BE 31C0 xor ax, ax 404 000001C0 CD16 int 16h ; wait for keyboard command 405 406 000001C2 83F800 cmp ax, 0 ; CTRL+BREAK 407 000001C5 761A jna short A_19 408 409 000001C7 3C03 cmp al, 'C'-40h ; 3 410 000001C9 7416 je short A_19 ; CTRL+C 411 000001CB 3C1B cmp al, 27 ; ESCape 412 000001CD 7412 je short A_19 413 414 000001CF 3C31 cmp al, '1' ; "(1) hd0" 415 000001D1 72EB jb short A_18 ; retry 416 000001D3 3A06[E441] cmp al, [TrDOS_dnmax] ; ('2' to '4') 417 000001D7 77E5 ja short A_18 ; retry 418 000001D9 044F add al, 80h-'1' ; bios disk num (80h-83h) 419 000001DB A2[4665] mov [DrvNum], al 420 000001DE E9E6FE jmp A_12 ; get disk parameters 421 A_19: 422 000001E1 E99105 jmp _exit ; Exit 423 424 A_20: 425 426 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 427 ; read masterboot sector 428 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 429 ; 12/10/2020 430 431 000001E4 BB[F052] mov bx, MasterBootBuff 432 000001E7 B90100 mov cx, 1 ; cylinder = 0 433 ; sector = 1 434 000001EA B600 mov dh, 0 ; head = 0 435 000001EC 8A16[4665] mov dl, [DrvNum] 436 000001F0 B80102 mov ax, 0201h ; read one sector 437 000001F3 CD13 int 13h 438 000001F5 7306 jnc short A_21 439 440 000001F7 BE[CE60] mov si, msg_drv_not_ready ; drive not ready 441 000001FA E98000 jmp A_26 442 A_21: 443 444 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 445 ; display CHS values and disk size (LBA) and partition table 446 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 447 ; 12/10/2020 448 449 000001FD B80300 mov ax, 3 ; clear screen 450 00000200 CD10 int 10h 451 452 00000202 E8E81E call init_partition_table ; 13/10/2020 453 454 00000205 E83C19 call display_chs_table 455 456 00000208 A1[4A65] mov ax, [disksize] 457 0000020B 8B16[4C65] mov dx, [disksize+2] 458 459 0000020F 81FA0001 cmp dx, 256 ; >= 8GB 460 00000213 7315 jnb short A_22 461 462 ;mov cx, 2048 ; /2048 (2048 sectors = 1 MB) 463 ;div cx 464 465 ; shift dx:ax to 8 bits right (/256) 466 00000215 88E0 mov al, ah 467 00000217 88D4 mov ah, dl 468 00000219 C1E803 shr ax, 3 ; /8 469 ; result = (dx:ax)/2048 470 471 ; ax = 0 to 8191 472 473 0000021C C606[1A42]4D mov byte [TrDOS_hdrow_unit], 'M' 474 00000221 EB11 jmp short A_23 475 476 477 A_29: ; 16/10/2020 478 00000223 E85C25 call partition_table_fix 479 00000226 73D5 jnc short A_21 480 481 00000228 CD20 int 20h 482 ;here: 483 ;jmp short here 484 485 A_22: 486 ; 1024 MB = 1GB (2097152 sectors) 487 ; DX/32 --> GB 488 0000022A 89D0 mov ax, dx 489 0000022C C1E805 shr ax, 5 ; /32 490 491 ; ax = 8 to 2047 492 0000022F C606[1A42]47 mov byte [TrDOS_hdrow_unit], 'G' 493 A_23: 494 ;xor dx, dx 495 00000234 BE[2042] mov si, TrDOS_hdrow_capacity 496 00000237 E8DD01 call convert_to_decimal 497 498 0000023A BE[2742] mov si, TrDOS_disksize 499 0000023D E88717 call print_msg 500 501 00000240 BE[2042] mov si, TrDOS_hdrow_capacity 502 00000243 E88117 call print_msg 503 504 00000246 BE[1A42] mov si, TrDOS_hdrow_unit 505 00000249 E87B17 call print_msg 506 507 ; 05/11/2020 508 ; fdisk4 can be used for 2TB hard disks 509 ; (because of 32 bit virtual cylinder number) 510 ; (fdisk3 limit is 502GB disks size and 65535 cylinders) 511 512 ;; 16/10/2020 513 ;;cmp word [lba_cyls+2], 0 514 ;cmp word [cylinders+2], 0 515 ;ja short A_27 ; Huge disk ! number of (lba) cylinders > 65335 516 ; ; Current FDISK version (v3) can not be used ! 517 518 0000024C BE[7452] mov si, CRLF 519 0000024F E87517 call print_msg 520 521 00000252 E88423 call dpt_1 522 523 00000255 BE[7452] mov si, CRLF 524 00000258 E86C17 call print_msg 525 526 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 527 ; display edit or exit option, getchar 528 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 529 530 0000025B BE[A350] mov si, msg_edit_or_exit 531 0000025E E86617 call print_msg 532 A_24: 533 00000261 30E4 xor ah, ah 534 00000263 CD16 int 16h 535 536 00000265 3C0D cmp al, 13 ; CR (ENTER) key 537 00000267 7419 je short A_28 538 539 00000269 3C1B cmp al, 27 ; ESCape key 540 0000026B 740D je short A_25 541 542 0000026D 3C20 cmp al, 32 ; SPACE key 543 0000026F 7411 je short A_28 544 545 00000271 3C03 cmp al, 3 ; CTRL+C 546 00000273 7405 je short A_25 547 548 00000275 83F800 cmp ax, 0 ; CTRL+BREAK 549 00000278 77E7 ja short A_24 550 A_25: 551 0000027A BE[7452] mov si, CRLF 552 A_26: 553 0000027D E84717 call print_msg 554 555 00000280 CD20 int 20h 556 ;here: 557 ; jmp short here 558 559 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 560 ; display fdisk program disk capacity limit message and then exit 561 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 562 ; 05/11/2020 563 ; (fdisk4 is proper for -upto- 2TB hard disks) 564 ;A_27: 565 ;; 16/10/2020 566 ;; 15/10/2020 567 ;; Display FDISK (v3) capacity limit (error) message 568 ; 569 ;mov ax, 65535 570 ;mul word [hs] 571 ; ; 1024 MB = 1GB (2097152 sectors) 572 ;; DX/32 --> GB 573 ;mov ax, dx 574 ;shr ax, 5 ; /32 575 ; 576 ;; ax = 8 to 2047 577 ;mov byte [TrDOS_hdrow_unit], 'G' 578 ;mov byte [TrDOS_hdrow_unit+1], 'B' 579 ;mov byte [TrDOS_hdrow_unit+2], '.' 580 ; 581 ;;xor dx, dx 582 ;mov si, TrDOS_hdrow_capacity 583 ;call convert_to_decimal 584 ; 585 ;mov si, msg_fdisk_capacity_err 586 ;call print_msg 587 ; 588 ;mov si, TrDOS_hdrow_capacity 589 ;call print_msg 590 ; 591 ;mov si, TrDOS_hdrow_unit 592 ;call print_msg 593 ; 594 ;jmp _exit 595 596 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 597 ; check defective pte and then init extended partition table(s) 598 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 599 600 A_28: 601 00000282 E8AF01 call check_defective_partition 602 00000285 729C jc A_29 ; ds:si -> defective pte 603 604 ; 17/10/2020 605 ; 26/02/2019 606 00000287 803E[E96C]00 cmp byte [epnumber], 0 607 0000028C 7603 jna short A_30 608 609 0000028E E8902A call init_ext_partition_table 610 A_30: 611 ; 17/10/2020 612 ; 04/02/2019 613 ;xor al, al ; MBR/PRIMARY PARTITIONS 614 ; 12/03/2021 615 ;xor eax, eax 616 00000291 E82C23 call display_partition_table 617 618 ; 17/10/2020 619 00000294 803E[E66C]00 cmp byte [pcount], 0 620 00000299 0F86E300 jna A_38 ; empty partition table 621 622 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 623 ; check CHS parms against start sector address and partition size 624 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 625 626 A_31: 627 ; Check disk parameters with current CHS settings 628 0000029D 31DB xor bx, bx 629 0000029F 31C9 xor cx, cx 630 A_32: 631 ; 17/10/2020 632 000002A1 80BF[956C]00 cmp byte [part_table_sys_id+bx], 0 633 000002A6 7670 jna short A_33 634 635 ; 27/10/2020 636 ;mov ax, [sectors] 637 ;mul word [heads] 638 ; dx = 0, ax = heads*sectors 639 640 ; 06/11/2020 641 ;mov dx, [part_table_start_cyl+bx] 642 000002A8 668B87[916C] mov eax, [part_table_start_cyl+bx] ; 10/03/2021 643 ; 27/10/2020 644 ;cmp ax, 1023 ; fixed cylinder number (> 1023) 645 ; (partition's start sector is used for fixing) 646 000002AD 663DFF030000 cmp eax, 1023 ; 06/11/2020 647 000002B3 7763 ja short A_33 ; no need to check CHS parms here 648 ; (also, CHS to LBA calculation is not applicable) 649 ;mov dx, [hs] ; heads*sectors 650 ; 651 ;mul dx 652 ; ; dx:ax = cylinder*heads*spt 653 654 ; 10/03/2021 655 000002B5 66F726[086A] mul dword [hs] 656 000002BA 6689C6 mov esi, eax 657 658 ;mov si, ax 659 ;mov di, dx 660 661 000002BD 6631C0 xor eax, eax 662 000002C0 8A87[8F6C] mov al, [part_table_start_head+bx] 663 000002C4 F626[BA3C] mul byte [sectors] 664 ;add si, ax 665 ;adc di, 0 666 ; di:si = (cylinder*heads*spt) + head*spt 667 ; 10/03/2021 668 000002C8 6601C6 add esi, eax 669 670 000002CB 8A87[906C] mov al, [part_table_start_sector+bx] 671 000002CF 30E4 xor ah, ah 672 000002D1 FEC8 dec al ; 1 -> 0 673 ;add si, ax 674 ;adc di, 0 675 ; di:si = (cylinder*heads*spt) + head*spt + sector - 1 676 ; (start sector as converted to LBA) 677 678 ; 10/03/2021 679 000002D3 6601F0 add eax, esi 680 ;xor esi, esi 681 682 ; 07/11/2020 683 ;;cmp di, [part_table_rel_sec_hw+bx] 684 ;cmp di, [bx+part_table_rel_sec+2] 685 ;jne short A_34 ; Invalid ! 686 687 ;;cmp si, [part_table_rel_sec_lw+bx] 688 ;cmp si, [bx+part_table_rel_sec] 689 ;jne short A_34 ; Invalid ! 690 ; di:si = partition's start sector (LBA) 691 692 000002D6 663B87[9C6C] cmp eax, [part_table_rel_sec+bx] 693 000002DB 7548 jne short A_34 ; Invalid ! 694 695 ; 27/10/2020 696 ;mov ax, [sectors] 697 ;mul word [heads] 698 ; dx = 0, ax = heads*sectors 699 700 ; 10/03/2021 701 000002DD 668B87[986C] mov eax, [part_table_end_cyl+bx] 702 000002E2 663DFF030000 cmp eax, 1023 703 ; 27/10/2020 704 ;cmp ax, 1023 ; fixed cylinder number (> 1023) 705 ; (partition's end sector is used for fixing) 706 000002E8 772E ja short A_33 ; no need to check CHS parms here 707 ; (also, CHS to LBA calculation is not applicable) 708 ;mov ax, [hs] ; heads*sectors 709 ; 710 ;mul dx 711 ; ; dx:ax = cylinder*heads*spt 712 ;mov si, ax 713 ;mov di, dx 714 715 000002EA 66F726[086A] mul dword [hs] 716 000002EF 6689C6 mov esi, eax 717 718 000002F2 6631C0 xor eax, eax 719 000002F5 8A87[966C] mov al, [part_table_end_head+bx] 720 000002F9 F626[BA3C] mul byte [sectors] 721 ;add si, ax 722 ;adc di, 0 723 ; di:si = (cylinder*heads*spt) + head*spt 724 ; 10/03/2021 725 000002FD 6601C6 add esi, eax 726 727 00000300 8A87[976C] mov al, [part_table_end_sector+bx] 728 00000304 30E4 xor ah, ah 729 ;dec al ; 63 -> 62 730 ;add si, ax 731 ;adc di, 0 732 ; di:si = (cylinder*heads*spt) + head*spt + sector 733 ; (end sector + 1 as converted to LBA) 734 ; 10/03/2021 735 00000306 6601C6 add esi, eax 736 737 ;mov ax, [part_table_num_sec_lw+bx] 738 ;mov dx, [part_table_num_sec_hw+bx] 739 ; 740 ;add ax, [part_table_rel_sec_lw+bx] 741 ;adc dx, [part_table_rel_sec_hw+bx] 742 ; ; dx:ax = partition's end sector (LBA) + 1 743 744 ; 10/03/2021 745 00000309 668B87[A06C] mov eax, [part_table_num_sec+bx] 746 0000030E 660387[9C6C] add eax, [part_table_rel_sec+bx] 747 748 00000313 6639C6 cmp esi, eax 749 00000316 750D jne short A_34 ; Invalid ! 750 751 ;cmp ax, si 752 ;jne short A_34 ; Invalid ! 753 754 ;cmp dx, di 755 ;jne short A_34 ; Invalid ! 756 A_33: 757 00000318 FEC1 inc cl 758 759 0000031A 80F904 cmp cl, 4 760 0000031D 7311 jnb short A_35 761 762 ;add bx, 18 ; partition table structure size 763 ; 05/11/2020 764 0000031F 83C316 add bx, 22 ; partition table structure size 765 766 00000322 E97CFF jmp A_32 767 A_34: 768 ;mov si, msg_defective_pt 769 ; 10/03/2021 770 00000325 66BE[075C0000] mov esi, msg_defective_pt 771 0000032B E89916 call print_msg 772 0000032E EB50 jmp short A_38 773 774 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 775 ; sort MBR partitions 776 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 777 778 A_35: 779 ; 10/03/2021 780 00000330 6631F6 xor esi, esi 781 ; 06/11/2020 782 00000333 6631D2 xor edx, edx 783 784 ; LBA and CHS values of all partitions are OK (here) 785 786 ; sort MBR (primary) partitions 787 788 00000336 E86F1F call sort_partition_table 789 790 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 791 ; Check partition (start, size) overlaps after sorting 792 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 793 794 ; Checking partition overlaps (via start and end cylinders) 795 796 00000339 31DB xor bx, bx 797 ;mov dx, 18 798 ; 05/11/2020 799 0000033B BA1600 mov dx, 22 800 A_36: 801 0000033E FEC3 inc bl 802 803 00000340 8A87[1E6A] mov al, [bx+sort] 804 00000344 F6E2 mul dl 805 00000346 89C6 mov si, ax ; current 806 807 00000348 80BC[956C]00 cmp byte [part_table_sys_id+si], 0 808 0000034D 762C jna short A_37 809 810 0000034F 8A87[1D6A] mov al, [bx+sort-1] 811 00000353 F6E2 mul dl 812 00000355 89C7 mov di, ax ; previous 813 814 ;mov ax, [part_table_end_cyl+di] 815 ;cmp ax, [part_table_start_cyl+si] 816 ;jb short A_37 817 ; 29/10/2020 818 ;ja short A_34 ; overlap ! 819 ; 10/03/2021 820 00000357 668B85[986C] mov eax, [part_table_end_cyl+di] 821 0000035C 663B84[916C] cmp eax, [part_table_start_cyl+si] 822 00000361 7218 jb short A_37 823 00000363 77C0 ja short A_34 ; overlap ! 824 825 ; 17/10/2020 826 ;and ax, ax 827 ;jnz short A_34 ; overlap error (except empty entries) 828 829 ; 29/10/2020 830 ; same cylinder 831 ; check end-start sectors for overlap 832 833 ;and ax, ax 834 ;jz short A_37 ; empty pt entries 835 ; (previous pte is empty) 836 ; 10/03/2021 837 00000365 6621C0 and eax, eax 838 00000368 7411 jz short A_37 ; empty pt entries 839 ; (previous pte is empty) 840 841 ;mov ax, [part_table_rel_sec_lw+di] ; previous 842 ;mov dx, [part_table_rel_sec_hw+di] 843 ;add ax, [part_table_num_sec_lw+di] 844 ;adc dx, [part_table_num_sec_hw+di] 845 ;;jc short A_34 846 ; ; dx:ax = end sector + 1 847 ; 10/03/2021 848 0000036A 668B85[9C6C] mov eax, [part_table_rel_sec+di] ; previous 849 0000036F 660385[A06C] add eax, [part_table_num_sec+di] 850 851 ;cmp dx, [part_table_rel_sec_hw+si] ; current 852 ;jb short A_37 853 ;ja short A_34 ; overlap error ! 854 ;cmp ax, [part_table_rel_sec_lw+si] 855 ;jnb short A_34 ; overlap error ! 856 ; 10/03/2021 857 00000374 663B84[9C6C] cmp eax, [part_table_rel_sec+si] ; current 858 00000379 73AA jnb short A_34 ; overlap error ! 859 A_37: 860 0000037B 80FB03 cmp bl, 3 861 0000037E 72BE jb short A_36 862 863 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 864 ; display partition table editing options 865 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 866 867 A_38: 868 00000380 BE[DE56] mov si, mbr_editing_options 869 00000383 E84116 call print_msg 870 871 00000386 BE[8C57] mov si, enter_option_number_msg 872 00000389 E83B16 call print_msg 873 874 0000038C 803E[1C6A]00 cmp byte [ldrives], 0 875 00000391 760C jna short A_39 876 877 00000393 BE[7452] mov si, CRLF 878 00000396 E82E16 call print_msg 879 880 00000399 BE[4F5D] mov si, str_display_ebr_pt 881 0000039C E82816 call print_msg 882 A_39: 883 ;mov si, CRLF 884 ;call print_msg 885 886 A_40: 887 0000039F 30E4 xor ah, ah 888 000003A1 CD16 int 16h 889 890 000003A3 3C30 cmp al, '0' 891 000003A5 742A je short A_41 892 893 000003A7 3C31 cmp al, '1' 894 000003A9 0F84A600 je create_partition 895 000003AD 3C32 cmp al, '2' 896 000003AF 0F842F01 je activate_partition 897 000003B3 3C33 cmp al, '3' 898 000003B5 0F84C801 je delete_partition 899 000003B9 3C34 cmp al, '4' 900 000003BB 0F84CB02 je write_pt_mbr 901 902 000003BF 3C1B cmp al, 27 ; ESCape 903 000003C1 740E je short A_41 904 905 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906 ; display (EPT) logical drives/partitions if 'SPACE' is pressed 907 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 908 909 ; 28/02/2019 910 000003C3 803E[1C6A]00 cmp byte [ldrives], 0 911 000003C8 76D5 jna short A_40 912 913 000003CA 3C20 cmp al, 20h ; SPACE 914 000003CC 75D1 jne short A_40 915 916 000003CE E9E423 jmp display_extended_pt 917 918 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919 ; exit if ESC key or '0' is pressed 920 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 921 922 A_41: 923 ; terminate 924 000003D1 CD20 int 20h 925 926 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 927 ; display partition table again 928 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 929 930 A_42: 931 ; 24/02/2019 932 ;xor al, al ; MBR/PRIMARY PARTITIONS 933 ; 12/03/2021 934 ;xor eax, eax 935 000003D3 E8EA21 call display_partition_table 936 000003D6 EBA8 jmp short A_38 937 938 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 939 ; display a row for hard disk name, number and capacity 940 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 941 ; 11/10/2020 942 943 display_hd_row: 944 ; dx:ax = disk size 945 946 000003D8 81FA0001 cmp dx, 256 ; >= 8GB 947 000003DC 730E jnb short dhdr_1 948 949 ;mov cx, 2048 ; /2048 (2048 sectors = 1 MB) 950 ;div cx 951 952 ; shift dx:ax to 8 bits right (/256) 953 000003DE 88E0 mov al, ah 954 000003E0 88D4 mov ah, dl 955 000003E2 C1E803 shr ax, 3 ; /8 956 ; result = (dx:ax)/2048 957 958 ; ax = 0 to 8191 959 960 000003E5 C606[1A42]4D mov byte [TrDOS_hdrow_unit], 'M' 961 000003EA EB0A jmp short dhdr_2 962 963 dhdr_1: 964 ; 1024 MB = 1GB (2097152 sectors) 965 ; DX/32 --> GB 966 000003EC 89D0 mov ax, dx 967 000003EE C1E805 shr ax, 5 ; /32 968 969 ; ax = 8 to 2047 970 000003F1 C606[1A42]47 mov byte [TrDOS_hdrow_unit], 'G' 971 dhdr_2: 972 ;xor dx, dx 973 000003F6 BE[2042] mov si, TrDOS_hdrow_capacity 974 000003F9 E81B00 call convert_to_decimal 975 976 000003FC FE06[0542] inc byte [TrDOS_hdrow_n] ; next number for "(#)" 977 978 00000400 BE[0242] mov si, TrDOS_hdrow 979 00000403 E8C115 call print_msg 980 00000406 BE[2042] mov si, TrDOS_hdrow_capacity ; db "#### ", 0 981 00000409 E8BB15 call print_msg 982 0000040C BE[1A42] mov si, TrDOS_hdrow_unit ; "GB" or "MB" 983 0000040F E8B515 call print_msg 984 985 00000412 FE06[0A42] inc byte [TrDOS_hdrow_i] ; next number for "hd#" 986 987 00000416 C3 retn 988 989 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 990 ; convert binary number to decimal character string 991 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 992 ; 11/10/2020 993 994 convert_to_decimal: 995 ; ax = binary number 996 ; si = decimal string start addr (max. 5 digits + space) 997 00000417 B90A00 mov cx, 10 998 0000041A 89E5 mov bp, sp 999 ctd_1: 1000 0000041C 31D2 xor dx, dx 1001 0000041E F7F1 div cx 1002 00000420 52 push dx ; 0 to 9 1003 00000421 09C0 or ax, ax 1004 00000423 75F7 jnz short ctd_1 1005 ctd_2: 1006 00000425 58 pop ax 1007 00000426 0430 add al, '0' 1008 00000428 8804 mov [si], al 1009 0000042A 46 inc si 1010 0000042B 39E5 cmp bp, sp 1011 0000042D 77F6 ja short ctd_2 1012 ;mov byte [si], 20h ; space before size unit char 1013 ;inc si 1014 ;mov byte [si], 0 ; ASCIIZ string terminator (Z) 1015 0000042F C7042000 mov word [si], 20h 1016 00000433 C3 retn 1017 1018 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1019 ; check defective partition signature 1020 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1021 ; 16/10/2020 1022 1023 check_defective_partition: 1024 00000434 BB[8E6C] mov bx, part_table_boot_ind 1025 00000437 31F6 xor si, si 1026 chk_dp_1: 1027 00000439 803FFF cmp byte [bx], 0FFh ; invalid/defective/partition sign 1028 0000043C 7509 jne short chk_dp_2 1029 0000043E C1E604 shl si, 4 ; * 16 1030 00000441 81C6[AE54] add si, MasterBootBuff+446 1031 00000445 F9 stc 1032 00000446 C3 retn 1033 chk_dp_2: 1034 ;cmp bx, part_table_boot_ind+(22*4) ; 05/11/2020 1035 00000447 83FE03 cmp si, 3 1036 0000044A 7306 jnb short chk_dp_3 1037 ;add bx, 18 1038 ; 05/11/2020 1039 0000044C 83C316 add bx, 22 1040 0000044F 46 inc si 1041 00000450 EBE7 jmp short chk_dp_1 1042 chk_dp_3: 1043 ;sub si, si 1044 00000452 C3 retn 1045 1046 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1047 ; create a disk partition (on MBR partition table) 1048 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1049 ; 18/10/2020 1050 1051 ; 12/03/2021 1052 ; 11/03/2021 (fdisk4.s) 1053 create_partition: 1054 ; 19/10/2020 1055 ; 10/02/2019 (hdimage.s) 1056 00000453 31C0 xor ax, ax 1057 ;xor eax, eax ; 12/03/2021 1058 00000455 A2[E469] mov byte [wholedisk], al ; 0 ; Reset wholedisk flag 1059 1060 ; 19/10/2020 1061 00000458 3806[E66C] cmp byte [pcount], al ; 0 ; number of (valid) partitions 1062 0000045C 761C jna short cp_1 1063 ;cp_0: 1064 0000045E 803E[E66C]04 cmp byte [pcount], 4 1065 00000463 7318 jnb short cp_2 ; full pt ! 1066 1067 ; al = 0 1068 00000465 E8A81E call find_part_free_space 1069 ; Following values are for the max. free space on disk 1070 1071 ;and cx, cx 1072 ; 12/03/2021 1073 00000468 6621C9 and ecx, ecx 1074 0000046B 7421 jz short cp_3 ; there is not free space on disk 1075 1076 ;mov [c_cylinders], cx ; count of free cylinders in the gap 1077 0000046D 891E[B06D] mov [c_fspc_offset], bx ; offset from beginning of 'fspc:' 1078 ;mov [c_gap], al ; gap (space index) number of this free space 1079 ; ; 0 -> before partition 1 (as PTE) 1080 ; ; 1-2-3 -> between partitions 1 to 4 1081 ; ; 4 -> after partition 4 (as PTE) 1082 1083 ; Start to job with non-aligned (full) free sectors of this max. space 1084 1085 ;mov ax, [free_space.sectors_unused+bx] 1086 ;mov dx, [free_space.sectors_unused+2+bx] 1087 ; 12/03/2021 1088 00000471 668B87[4E6D] mov eax, [free_space.sectors_unused+bx] 1089 1090 ;mov [pp_Sectors], ax 1091 ;mov [pp_Sectors+2], dx 1092 ; 12/03/2021 1093 00000476 66A3[E069] mov [pp_Sectors], eax 1094 cp_1: 1095 0000047A E9C807 jmp B_01 ; New/Empty disk, create partition menu 1096 ;cp_2: 1097 ; 13/02/2019 1098 ; There is not a free pt entry to create a new partition 1099 1100 ;xor al, al ; MBR/PRIMARY PARTITIONS 1101 ; 12/03/2021 1102 ;xor eax, eax 1103 cp_2: 1104 0000047D E84021 call display_partition_table 1105 1106 00000480 BE[6E58] mov si, msg_full_pt 1107 00000483 E84115 call print_msg 1108 00000486 BE[9B58] mov si, msg_to_create_new_p 1109 00000489 E83B15 call print_msg 1110 1111 0000048C EB64 jmp ap_0 1112 cp_3: 1113 ; 19/10/2020 1114 0000048E 803E[E96C]00 cmp byte [epnumber], 0 1115 00000493 7708 ja short create_logical_drives 1116 ;cp_4: 1117 ; 15/02/2019 1118 ; There is not (enough) free space to create a new partition 1119 1120 00000495 BE[B958] mov si, msg_no_free_space 1121 00000498 E82C15 call print_msg 1122 0000049B EB55 jmp ap_0 1123 1124 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1125 ; create logical -dos- drives 1126 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1127 ; 19/10/2020 1128 1129 ; 12/03/2021 (fdisk4.s) 1130 create_logical_drives: 1131 ; 05/03/2019 1132 0000049D E83C26 call check_ext_free_space 1133 000004A0 7238 jc short cld_5 1134 cld_1: 1135 ; 05/03/2019 1136 000004A2 803E[1C6A]04 cmp byte [ldrives], 4 1137 000004A7 7203 jb short cld_2 1138 000004A9 E97723 jmp eetc_2 1139 cld_2: 1140 ; 01/11/2020 1141 ;mov [ep_free_sectors], ax 1142 ;mov [ep_free_sectors+2], dx 1143 ; 12/03/2021 1144 000004AC 66A3[D46D] mov [ep_free_sectors], eax 1145 1146 000004B0 BE[5260] mov si, msg_c_ldd_q 1147 000004B3 E81115 call print_msg 1148 cld_3: 1149 000004B6 28E4 sub ah, ah 1150 000004B8 CD16 int 16h 1151 1152 000004BA 3C1B cmp al, 27 ; ESCAPE key 1153 ;je cp_esc 1154 000004BC 7419 je short cld_6 ; 19/10/2020 1155 000004BE 24DF and al, 0DFh 1156 000004C0 3C4E cmp al, 'N' 1157 000004C2 740D je short cld_4 1158 000004C4 3C59 cmp al, 'Y' 1159 000004C6 75EE jne short cld_3 1160 000004C8 BE[AE59] mov si, _msg_YES 1161 000004CB E8F914 call print_msg 1162 1163 000004CE E98223 jmp edit_ext_table_create_x 1164 cld_4: 1165 000004D1 BE[B459] mov si, _msg_NO 1166 000004D4 E8F014 call print_msg 1167 cld_6: 1168 ;jmp cp_esc 1169 ; 19/10/2020 1170 000004D7 E9F9FE jmp A_42 1171 cld_5: 1172 000004DA BE[2260] mov si, msg_c_part_error 1173 000004DD E8E714 call print_msg 1174 1175 ; 21/03/2021 1176 ;cmp byte [ldrives], 3 1177 ;;jna short cld_2 1178 ; 21/03/2021 1179 ;jna short ap_0 1180 1181 ;mov si, msg_c_ldd_error 1182 ;call print_msg 1183 1184 000004E0 EB10 jmp short ap_0 1185 1186 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1187 ; set active partition 1188 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1189 ; 19/10/2020 1190 1191 activate_partition: 1192 ; 12/02/2019 1193 ;xor al, al ; MBR/PRIMARY PARTITIONS 1194 ; 12/03/2021 1195 ;xor eax, eax 1196 000004E2 E8DB20 call display_partition_table 1197 1198 000004E5 803E[E66C]00 cmp byte [pcount], 0 1199 000004EA 7713 ja short ap_1 1200 1201 000004EC BE[2258] mov si, msg_empty_pt 1202 000004EF E8D514 call print_msg 1203 ap_0: 1204 000004F2 BE[D052] mov si, msg_press_any_key 1205 000004F5 E8CF14 call print_msg 1206 1207 000004F8 30E4 xor ah, ah 1208 000004FA CD16 int 16h 1209 ap_5: 1210 ;jmp ap_esc 1211 ; 19/10/2020 1212 000004FC E9D4FE jmp A_42 1213 1214 ap_1: 1215 ; Set valid_ppnums (MBR partition IDs) list 1216 000004FF BE[AE54] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 1217 00000502 BB[306C] mov bx, valid_ppnums 1218 00000505 B104 mov cl, 4 1219 ap_2: 1220 00000507 8A4404 mov al, [si+ptFileSystemID] 1221 0000050A 8807 mov [bx], al 1222 0000050C FEC9 dec cl 1223 0000050E 7406 jz short ap_3 1224 00000510 43 inc bx 1225 00000511 83C610 add si, 16 1226 00000514 EBF1 jmp short ap_2 1227 ap_3: 1228 00000516 BE[A15A] mov si, msg_enter_pn_to_act 1229 00000519 E8AB14 call print_msg 1230 ap_getchar: 1231 0000051C 30E4 xor ah, ah 1232 0000051E CD16 int 16h 1233 1234 ; 19/10/2020 1235 00000520 3C1B cmp al, 27 1236 ;je ap_esc 1237 00000522 74D8 je short ap_5 1238 1239 ;cmp al, '0' 1240 ;;je ap_esc 1241 ;je short ap_5 1242 1243 00000524 3C31 cmp al, '1' 1244 00000526 72F4 jb short ap_getchar 1245 00000528 3C34 cmp al, '4' 1246 0000052A 77F0 ja short ap_getchar 1247 1248 0000052C 30E4 xor ah, ah 1249 0000052E 89C2 mov dx, ax 1250 1251 00000530 80EA31 sub dl, '1' 1252 00000533 89D6 mov si, dx 1253 00000535 38A4[306C] cmp byte [si+valid_ppnums], ah ; 0 1254 00000539 76E1 jna short ap_getchar ; Empty partition table entry, it is not shown 1255 1256 0000053B BB0700 mov bx, 07h 1257 0000053E B409 mov ah, 09h 1258 00000540 B90100 mov cx, 1 1259 00000543 CD10 int 10h 1260 1261 00000545 BE[AE54] mov si, MasterBootBuff+pTableOffset 1262 00000548 BF[8E6C] mov di, part_table_boot_ind ; (**) 1263 1264 ; Clear all of possible active partition flags 1265 0000054B 8834 mov [si], dh ; 0 1266 0000054D 887410 mov [si+16], dh ; 0 1267 00000550 887420 mov [si+32], dh ; 0 1268 00000553 887430 mov [si+48], dh ; 0 1269 1270 ; 09/03/2021 1271 ; This may not be needed !? 1272 ; (**) (Primary partitions structure/list) 1273 00000556 8835 mov [di], dh ; 0 1274 00000558 887516 mov [di+22], dh ; 0 1275 0000055B 88752C mov [di+44], dh ; 0 1276 0000055E 887542 mov [di+66], dh ; 0 1277 1278 00000561 20D2 and dl, dl 1279 00000563 740D jz short ap_4 1280 1281 00000565 89D0 mov ax, dx 1282 1283 00000567 C0E004 shl al, 4 ; * 16 1284 0000056A 01C6 add si, ax 1285 1286 ;mov al, 18 1287 ; 05/11/2020 1288 0000056C B016 mov al, 22 1289 0000056E F6E2 mul dl ; 1 to 3 1290 00000570 01C7 add di, ax 1291 ap_4: 1292 ; Then set active partition as requested by user 1293 00000572 C60480 mov byte [si], 80h 1294 00000575 C60580 mov byte [di], 80h ; (**) 1295 1296 00000578 BE[7452] mov si, CRLF ; Next line 1297 0000057B E84914 call print_msg 1298 1299 ; NOTE: Only the MBR buffer has been changed 1300 ; (Masterboot sector will not be updated unless/till 1301 ; MBR partition table -and MBR code- will be written 1302 ; to disk image as result of 'write part. table' command.) 1303 1304 ;; wait for 1 second 1305 ;mov ah, 02h 1306 ;int 1Ah 1307 ;mov [GetChar], dh 1308 ;ap_wait: 1309 ;mov ah, 02h 1310 ;int 1Ah 1311 ;cmp dh, [GetChar] 1312 ;je short ap_wait 1313 1314 ; 17/10/2020 1315 0000057E E952FE jmp A_42 ; display partition table again 1316 1317 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1318 ; delete selected partition 1319 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1320 ; 19/10/2020 1321 1322 delete_partition: 1323 ; 10/02/2019 1324 ;xor al, al ; MBR/PRIMARY PARTITIONS 1325 ; 12/03/2021 1326 ;xor eax, eax 1327 00000581 E83C20 call display_partition_table 1328 1329 00000584 803E[E66C]00 cmp byte [pcount], 0 1330 00000589 7712 ja short dp_1 1331 1332 0000058B BE[2258] mov si, msg_empty_pt 1333 0000058E E83614 call print_msg 1334 1335 00000591 BE[D052] mov si, msg_press_any_key 1336 00000594 E83014 call print_msg 1337 1338 00000597 30E4 xor ah, ah 1339 00000599 CD16 int 16h 1340 1341 0000059B EB73 jmp short dp_esc 1342 1343 dp_1: 1344 ; Set valid_ppnums (MBR partition IDs) list 1345 0000059D BE[AE54] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 1346 000005A0 BB[306C] mov bx, valid_ppnums 1347 000005A3 B104 mov cl, 4 1348 dp_2: 1349 000005A5 8A4404 mov al, [si+ptFileSystemID] 1350 000005A8 8807 mov [bx], al 1351 000005AA FEC9 dec cl 1352 000005AC 7406 jz short dp_3 1353 000005AE 43 inc bx 1354 000005AF 83C610 add si, 16 1355 000005B2 EBF1 jmp short dp_2 1356 dp_3: 1357 000005B4 BE[DD58] mov si, msg_enter_pn_to_del 1358 000005B7 E80D14 call print_msg 1359 dp_getchar1: 1360 000005BA 30E4 xor ah, ah 1361 000005BC CD16 int 16h 1362 1363 ; 19/10/2020 1364 000005BE 3C1B cmp al, 27 1365 000005C0 744E je short dp_esc 1366 000005C2 3C30 cmp al, '0' 1367 000005C4 744A je short dp_esc 1368 ;cmp al, '1' 1369 000005C6 72F2 jb short dp_getchar1 1370 000005C8 3C34 cmp al, '4' 1371 000005CA 77EE ja short dp_getchar1 1372 1373 000005CC 30FF xor bh, bh 1374 000005CE 88C3 mov bl, al 1375 ;dec bl 1376 000005D0 80EB31 sub bl, '1' 1377 000005D3 38BF[306C] cmp byte [bx+valid_ppnums], bh ; 0 ; 12/02/2019 1378 000005D7 76E1 jna short dp_getchar1 ; Empty partition table entry, it is not shown 1379 1380 000005D9 881E[3A6C] mov [del_part_num], bl ; Selected partition number to be deleted. 1381 000005DD A2[0159] mov [chr_del_pnum1], al ; Partition number for "Enter ..." text 1382 000005E0 A2[A359] mov [chr_del_pnum2], al ; Partition number for "Do you want ..." text 1383 1384 000005E3 BE[0159] mov si, chr_del_pnum1 ; write partition number (user input) 1385 000005E6 E8DE13 call print_msg 1386 1387 ;xor al, al 1388 000005E9 A2[0159] mov [chr_del_pnum1], al ; 0 ; reset 1389 1390 000005EC BE[0559] mov si, msg_delete_partition_q ; question for deleting (with warning) 1391 000005EF E8D513 call print_msg 1392 1393 dp_getchar2: 1394 000005F2 30E4 xor ah, ah 1395 000005F4 CD16 int 16h 1396 1397 000005F6 3C1B cmp al, 27 1398 000005F8 7416 je short dp_esc 1399 1400 000005FA 24DF and al, 0DFh 1401 000005FC 3C59 cmp al, 'Y' 1402 000005FE 7413 je short dp_yes 1403 00000600 3C4E cmp al, 'N' 1404 00000602 75EE jne short dp_getchar2 1405 dp_no: 1406 00000604 BE[B559] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 1407 00000607 E8BD13 call print_msg 1408 1409 0000060A BE[7452] mov si, CRLF ; Next line 1410 0000060D E8B713 call print_msg 1411 1412 ;jmp short dp_esc 1413 1414 ;cp_esc: 1415 ;ap_esc: 1416 ;wptmbr_esc: 1417 dp_esc: 1418 ;xor al, al ; MBR/PRIMARY PARTITIONS 1419 ;call display_partition_table 1420 ;jmp A_38 ; 17/10/2020 1421 1422 ; 19/10/2020 1423 00000610 E9C0FD jmp A_42 1424 1425 dp_yes: 1426 00000613 BE[AF59] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 1427 00000616 E8AE13 call print_msg 1428 1429 00000619 BF[AE54] mov di, MasterBootBuff+pTableOffset 1430 0000061C A0[3A6C] mov al, [del_part_num] 1431 0000061F 20C0 and al, al 1432 00000621 7406 jz short dp_4 1433 00000623 98 cbw 1434 ;xor ah, ah 1435 00000624 C0E004 shl al, 4 ; * 16 1436 00000627 01C7 add di, ax 1437 dp_4: 1438 00000629 BE[7452] mov si, CRLF ; Next line 1439 0000062C E89813 call print_msg 1440 1441 ; 27/02/2019 1442 0000062F 807D0405 cmp byte [di+ptFileSystemID], 05h ; EXTENDED (CHS) 1443 ;jne short dp_5 1444 00000633 7406 je short dp_6 1445 ; 24/10/2020 1446 00000635 807D040F cmp byte [di+ptFileSystemID], 0Fh ; EXTENDED (LBA) 1447 00000639 7545 jne short dp_5 1448 dp_6: 1449 0000063B 3806[1C6A] cmp byte [ldrives], al ; 0 1450 0000063F 763F jna short dp_5 1451 1452 00000641 BE[255C] mov si, msg_ext_part_del_error 1453 00000644 E88013 call print_msg 1454 00000647 BE[655C] mov si, msg_cancel_continue 1455 0000064A E87A13 call print_msg 1456 1457 0000064D 30E4 xor ah, ah 1458 0000064F CD16 int 16h 1459 1460 00000651 3C1B cmp al, 27 ; ESCape 1461 00000653 74BB je short dp_esc 1462 1463 00000655 E8BA27 call delete_logical_drives 1464 1465 ; 28/02/2019 1466 00000658 803E[1C6A]01 cmp byte [ldrives], 1 1467 0000065D 73B1 jnb short dp_esc 1468 1469 ;xor al, al ; MBR/PRIMARY PARTITIONS 1470 ; 12/03/2021 1471 ;xor eax, eax 1472 0000065F E85E1F call display_partition_table 1473 1474 00000662 BE[F85C] mov si, msg_delete_ext_part 1475 00000665 E85F13 call print_msg 1476 1477 dp_ask_again: 1478 00000668 28E4 sub ah, ah 1479 0000066A CD16 int 16h 1480 1481 0000066C 3C1B cmp al, 27 ; ESCape 1482 0000066E 74A0 je short dp_esc 1483 1484 00000670 3C0D cmp al, 13 ; ENTER/CR 1485 00000672 75F4 jne short dp_ask_again 1486 1487 00000674 BF[AE54] mov di, MasterBootBuff+pTableOffset 1488 00000677 A0[3A6C] mov al, [del_part_num] 1489 0000067A 98 cbw 1490 0000067B C0E004 shl al, 4 ; * 16 1491 0000067E 01C7 add di, ax 1492 dp_5: 1493 00000680 31C0 xor ax, ax 1494 1495 ; clear partition table entry in MBR buffer 1496 00000682 B90800 mov cx, 8 1497 00000685 F3AB rep stosw 1498 1499 ; NOTE: Only the MBR buffer will be cleared 1500 ; (Masterboot sector will not be updated unless/till 1501 ; MBR partition table -and MBR code- will be written 1502 ; to disk image as result of 'write part. table' command.) 1503 1504 00000687 E973FB jmp A_21 ; 17/10/2020 1505 1506 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1507 ; write partition table (and MBR code) onto disk 1508 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1509 ; 18/10/2020 1510 1511 ; 13/03/2021 (fdisk4.s) 1512 write_pt_mbr: 1513 ; 18/10/2020 (fdisk3.s) 1514 ; 11/02/2019 (hdimage.s) 1515 ;xor al, al ; MBR/PRIMARY PARTITIONS 1516 ; 12/03/2021 1517 ;xor eax, eax 1518 0000068A E8331F call display_partition_table 1519 1520 0000068D BE[B959] mov si, msg_write_masterboot_sector 1521 00000690 E83413 call print_msg 1522 1523 00000693 A2[066A] mov [GetChar], al ; 0 1524 1525 00000696 BE[9C5A] mov si, option_input 1526 00000699 E82B13 call print_msg 1527 1528 0000069C B403 mov ah, 3 1529 ;mov bx, 7 1530 0000069E CD10 int 10h ; Return Cursor Position 1531 ; DL = Column 1532 1533 000006A0 FECA dec dl ; previous char ; ']' 1534 000006A2 FECA dec dl ; previous char ; '[ ]' 1535 1536 000006A4 B402 mov ah, 2 1537 ;mov bx, 7 1538 000006A6 CD10 int 10h ; Set Cursor Position 1539 1540 ; write char at current cursor position 1541 1542 000006A8 B030 mov al, '0' ; Write default char 1543 1544 ;;mov bx, 07h 1545 000006AA B409 mov ah, 09h 1546 000006AC B90100 mov cx, 1 1547 000006AF CD10 int 10h 1548 1549 wptmbr_getchar: 1550 000006B1 30E4 xor ah, ah 1551 000006B3 CD16 int 16h 1552 1553 000006B5 3C1B cmp al, 1Bh ; 27 1554 ;je wptmbr_esc ; 19/10/2020 1555 000006B7 0F8418FD je A_42 1556 1557 000006BB 3C0D cmp al, 0Dh ; 13 1558 000006BD 7414 je short wptmbr_1 1559 1560 000006BF 3C31 cmp al, '1' 1561 000006C1 72EE jb short wptmbr_getchar 1562 1563 000006C3 3C32 cmp al, '2' 1564 000006C5 77EA ja short wptmbr_getchar 1565 1566 000006C7 A2[066A] mov [GetChar], al 1567 1568 ;;mov bx, 07h 1569 000006CA B409 mov ah, 09h 1570 000006CC B90100 mov cx, 1 1571 000006CF CD10 int 10h 1572 000006D1 EBDE jmp short wptmbr_getchar 1573 1574 wptmbr_1: 1575 000006D3 803E[066A]00 cmp byte [GetChar], 0 1576 000006D8 76D7 jna short wptmbr_getchar 1577 1578 000006DA BE[6A5A] mov si, msg_writing_ptable 1579 000006DD E8E712 call print_msg 1580 1581 000006E0 803E[066A]32 cmp byte [GetChar], '2' 1582 000006E5 7523 jne short wptmbr_2 ; Do not write Singlix MBR code 1583 1584 ; Write CHS parameters in Singlix (FS specific) MBR 1585 1586 000006E7 BE[A72E] mov si, TRDOS386_MASTERBOOT_SECTOR 1587 000006EA B9DF00 mov cx, 446/2 ; Copy Singlix FS 1 MBR code 1588 ; except Partition Table 1589 000006ED BF[F052] mov di, MasterBootBuff 1590 000006F0 F3A5 rep movsw 1591 1592 ; This (Below) is not needed; because, if MBR magicword 1593 ; would not be 0AA55h, we would not be able to come here! 1594 ;;add di, 64 ; skip partition table 1595 ;;mov ax, 0AA55h 1596 ;;stosw 1597 ;mov word [MBIDCode], 0AA55h 1598 1599 ; 12/02/2019 1600 ; Copy CHS parameters to Singlix MBR (on disk) 1601 1602 ; 13/03/2021 1603 ;mov di, MasterBootBuff+420 1604 000006F2 BF[9354] mov di, MasterBootBuff+419 1605 1606 ; (if disk size > 512 GB, number of cylinders will be > 65535) 1607 000006F5 A0[C03C] mov al, [cylinders+2] 1608 000006F8 AA stosb 1609 ; 1610 000006F9 A1[BE3C] mov ax, [cylinders] 1611 000006FC AB stosw ; cylinders 1612 000006FD A1[BC3C] mov ax, [heads] 1613 00000700 AB stosw ; heads 1614 00000701 A1[BA3C] mov ax, [sectors] 1615 00000704 AB stosw ; sectors 1616 1617 ; 13/03/2021 1618 ; copy 32 bit disk size (total LBA sectors) to MBR offset 426 1619 00000705 BE[4A65] mov si, disksize 1620 00000708 A5 movsw 1621 00000709 A5 movsw 1622 1623 wptmbr_2: 1624 ;xor ax, ax ; 0 1625 ;xor dx, dx ; 0 1626 ;; DX_AX = Masterboot Sector = 0 1627 ;mov bx, MasterBootBuff 1628 ;; ES:BX = Sector Buffer 1629 ;call write_hd_sector 1630 ;jc short print_error_code 1631 ; ! display error msg and then exit ! 1632 1633 0000070A C606[4965]05 mov byte [rcnt], 5 ; retry count 1634 1635 0000070F BB[F052] mov bx, MasterBootBuff 1636 1637 00000712 B90100 mov cx, 1 ; cylinder = 0 1638 ; sector = 1 1639 00000715 B600 mov dh, 0 ; head = 0 1640 00000717 8A16[4665] mov dl, [DrvNum] 1641 wptmbr_3: 1642 0000071B B80103 mov ax, 0301h ; write one sector 1643 0000071E CD13 int 13h 1644 00000720 730C jnc short wptmbr_4 1645 1646 00000722 FE0E[4965] dec byte [rcnt] 1647 00000726 7431 jz short print_error_code 1648 1649 00000728 30E4 xor ah, ah 1650 ;mov dl, [DrvNum] 1651 0000072A CD13 int 13h ; BIOS Service func (ah) = 0 1652 ; Reset disk system 1653 0000072C EBED jmp short wptmbr_3 1654 1655 wptmbr_4: 1656 0000072E BE[935A] mov si, _msg_OK 1657 00000731 E89312 call print_msg 1658 1659 ; wait for 1 second 1660 00000734 B402 mov ah, 02h 1661 00000736 CD1A int 1Ah 1662 00000738 8836[066A] mov [GetChar], dh 1663 wptmbr_wait: 1664 0000073C B402 mov ah, 02h 1665 0000073E CD1A int 1Ah 1666 00000740 3A36[066A] cmp dh, [GetChar] 1667 00000744 74F6 je short wptmbr_wait 1668 1669 00000746 BE[D052] mov si, msg_press_any_key 1670 00000749 E87B12 call print_msg 1671 1672 0000074C 30E4 xor ah, ah ; "Press any key to continue" 1673 0000074E CD16 int 16h 1674 1675 00000750 BE[7452] mov si, CRLF 1676 00000753 E87112 call print_msg 1677 1678 ;jmp wptmbr_esc 1679 ; 19/10/2020 1680 00000756 E97AFC jmp A_42 1681 1682 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1683 ; print error message and exit 1684 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1685 ; 18/10/2020 (fdisk3.s) 1686 1687 print_error_code: 1688 ; 25/02/2019 (hdimage.s) 1689 1690 00000759 88E0 mov al, ah ; error code 1691 0000075B E83D13 call bin_to_hex 1692 0000075E A3[8252] mov [error_code], ax 1693 1694 00000761 BE[7452] mov si, CRLF 1695 00000764 E86012 call print_msg 1696 1697 00000767 BE[7752] mov si, Msg_Error 1698 0000076A E85A12 call print_msg 1699 1700 0000076D CD20 int 20h ; Exit 1701 1702 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1703 ; exit, print_msg & exit 1704 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1705 ; 19/10/2020 1706 1707 _crlf_exit: 1708 0000076F BE[7452] mov si, CRLF 1709 _p_exit: 1710 ; 11/10/2020 1711 00000772 E85212 call print_msg 1712 _exit: 1713 00000775 B8004C mov ax, 4C00h ; terminate 1714 00000778 CD21 int 21h 1715 1716 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1717 ; display create partition menu & get partition type input 1718 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1719 ; 19/10/2020 1720 1721 create_partition_input: 1722 ; 15/02/2019 1723 ; clear screen 1724 0000077A B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1725 0000077D CD10 int 10h 1726 1727 0000077F BE[6E42] mov si, msg_create_partition_h ; header 1728 00000782 E84212 call print_msg 1729 00000785 BE[6343] mov si, msg_create_partition_m ; menu 1730 00000788 E83C12 call print_msg 1731 cpi_1: 1732 0000078B 30E4 xor ah, ah 1733 0000078D CD16 int 16h 1734 0000078F 3C1B cmp al, 27 ; ESC key 1735 00000791 7445 je short cpi_4 ; 25/02/2019 1736 00000793 3C30 cmp al, '0' 1737 00000795 7441 je short cpi_4 ; 25/02/2019 1738 00000797 72F2 jb short cpi_1 1739 00000799 3C34 cmp al, '4' 1740 0000079B 77EE ja short cpi_1 1741 1742 0000079D 30E4 xor ah, ah 1743 0000079F 2C30 sub al, '0' 1744 1745 ;mov [pp_type], al 1746 1747 ;mov byte [pp_type_user], 0 1748 1749 000007A1 3C01 cmp al, 1 ; DOS partition 1750 000007A3 7536 jne short cpi_5 ; ah = 0 1751 ; (al = 2 -> singlix, al = 3 -> retro unix) 1752 cpi_2: 1753 ; clear screen 1754 000007A5 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1755 000007A8 CD10 int 10h 1756 1757 000007AA BE[1945] mov si, msg_create_dos_partition_h ; header 1758 000007AD E81712 call print_msg 1759 000007B0 BE[ED48] mov si, msg_create_dos_partition_m ; menu 1760 000007B3 E81112 call print_msg 1761 cpi_3: 1762 000007B6 30E4 xor ah, ah 1763 000007B8 CD16 int 16h 1764 000007BA 3C1B cmp al, 27 ; ESC key 1765 000007BC 741A je short cpi_4 1766 000007BE 3C30 cmp al, '0' 1767 000007C0 7416 je short cpi_4 1768 000007C2 72F2 jb short cpi_3 1769 000007C4 3C33 cmp al, '3' 1770 000007C6 77EE ja short cpi_3 1771 1772 000007C8 30E4 xor ah, ah 1773 000007CA 2C30 sub al, '0' 1774 000007CC 3C01 cmp al, 1 1775 000007CE 7424 je short cpi_6 ; ah = 0 (al = primary dos partition) 1776 1777 ;mov byte [pp_type], 5 1778 1779 000007D0 3C02 cmp al, 2 1780 000007D2 7621 jna short cpi_7 1781 1782 000007D4 B80600 mov ax, 6 ; ah = 0 (al = logical dos drive/partition) 1783 000007D7 C3 retn 1784 1785 cpi_4: 1786 000007D8 31C0 xor ax, ax ; ah = 0 (al = 0 -> ESCape/Cancel) 1787 000007DA C3 retn 1788 cpi_5: 1789 000007DB 3C04 cmp al, 4 ; option num. for partition type (user) input 1790 000007DD 7515 jne short cpi_6 1791 1792 000007DF E84616 call partition_type_input 1793 1794 ; 29/10/2020 1795 000007E2 08C0 or al, al 1796 ;jz short cpi_6 ; invalid (zero) input or ESC key 1797 000007E4 74F2 jz short cpi_4 1798 1799 000007E6 B404 mov ah, 4 ; user/another type partition flag 1800 ; al = Partition ID 1801 000007E8 50 push ax 1802 000007E9 BE[D052] mov si, msg_press_any_key 1803 000007EC E8D811 call print_msg 1804 000007EF 28E4 sub ah, ah 1805 000007F1 CD16 int 16h 1806 000007F3 58 pop ax 1807 cpi_6: 1808 000007F4 C3 retn 1809 cpi_7: 1810 000007F5 B80500 mov ax, 5 ; ah = 0 (al = extended dos partition) 1811 000007F8 C3 retn 1812 1813 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1814 ; create primary (dos or non-dos) partition 1815 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1816 ; 19/10/2020 1817 ; (This procedure must be called after 'find_part_free_space') 1818 1819 ; 14/03/2021 (fdisk4.s) 1820 create_primary_partition: 1821 ; 16/02/2019 1822 1823 ; INPUT: 1824 ; none 1825 ; (CHS parameters and free space calculation result will be used.) 1826 ; 1827 ; OUTPUT: 1828 ; Partition table in MBR buffer will be updated. 1829 ; 1830 ; (Modified registers: ax, bx, cx, dx, si, di) 1831 1832 ; Create primary dos or non-dos partition, 1833 ; make partition table entry 1834 1835 ; 19/10/2020 1836 000007F9 803E[E66C]00 cmp byte [pcount], 0 ; count of (valid) partitions 1837 000007FE 770B ja short cpp_0 1838 1839 ; cylinder = 0, head = 1, sector = 1 1840 ; LBA = (((cylinder*heads)+head)*sectors)+sector-1 1841 1842 00000800 BE[AE54] mov si, MasterBootBuff+pTableOffset 1843 1844 ;mov ax, [sectors] ; LBA = 17 or 63 1845 ; 07/11/2020 1846 00000803 660FB606[BA3C] movzx eax, byte [sectors] 1847 ;xor dx, dx 1848 00000809 EB4F jmp short cpp_4 1849 cpp_0: 1850 ; 16/02/2019 1851 0000080B E85E1D call get_first_free_pte 1852 ; CX = First free PTE number, 0 to 3 1853 ; (CX = 3 if there is not a free PTE, and CF = 1) 1854 ; ((But CF = 1 is not possible here because pcount < 4)) 1855 ; SI = PTE address/offset in MBR buffer 1856 1857 ;mov si, MasterBootBuff+pTableOffset 1858 ;shl cl, 4 ; * 16 1859 ;add si, cx 1860 1861 ; 18/02/2019 1862 0000080E 8B3E[B06D] mov di, [c_fspc_offset] 1863 ;mov bx, [di+free_space.start] 1864 ;mov al, [heads] 1865 ;; 07/11/2020 1866 ;movzx eax, byte [heads] 1867 ;mul byte [sectors] 1868 ;;mul bx 1869 ; ; DX:AX = LBA of start cylinder, head 0, sector 1 1870 ; 14/03/2021 1871 00000812 66A1[086A] mov eax, [hs] ; [heads] * [sectors] 1872 ; 07/11/2020 1873 00000816 668B9D[466D] mov ebx, [di+free_space.start] 1874 0000081B 66F7E3 mul ebx 1875 ; ; EAX = LBA of start cylinder, head 0, sector 1 1876 1877 0000081E 8A0E[B26D] mov cl, [cylinder_boundary] 1878 1879 ;cmp cl, 0 ; Default (partition size unit is one of C, G, M) 1880 ; boundary alignment is forced as default 1881 ;je short cpp_4 1882 1883 ; 20/02/2019 1884 ;and cl, cl 1885 ;jz short cpp_1 1886 1887 00000822 80F959 cmp cl, 'Y' 1888 00000825 7433 je short cpp_4 ; cylinder boundary option (answer) = YES 1889 1890 00000827 80F94E cmp cl, 'N' 1891 0000082A 7507 jne short cpp_1 ; cylinder boundary option (answer) = YES/NO 1892 1893 ; cylinder boundary option (answer) = NO 1894 ;mov ax, [di+free_space.startsector] 1895 ;mov dx, [di+free_space.startsector+2] 1896 ; 07/11/2020 1897 0000082C 668B85[526D] mov eax, [di+free_space.startsector] 1898 00000831 EB27 jmp short cpp_4 1899 cpp_1: 1900 ;cmp cl, 27 ; ESCape 1901 ;jne short cpp_4 ; 'Y' 1902 1903 ; check cylinder boundary alignment of the start sector 1904 1905 ; if start sector is not aligned, end sector must not be aligned 1906 ; (this rule is valid for ESCape key from the user) 1907 1908 00000833 C606[B26D]59 mov byte [cylinder_boundary], 'Y' ; YES for end sector check 1909 1910 ;mov cx, [di+free_space.startsector] 1911 1912 ;or bx, bx 1913 1914 ;mov bx, [di+free_space.startsector+2] 1915 1916 ;jnz short cpp_2 ; start cylinder > 0 1917 1918 ;and bx, bx 1919 ;jnz short cpp_3 1920 1921 00000838 668B8D[526D] mov ecx, [di+free_space.startsector] 1922 0000083D 6609DB or ebx, ebx 1923 00000840 750B jnz short cpp_2 ; start cylinder > 0 1924 1925 ; 07/11/2020 1926 00000842 8A1E[BA3C] mov bl, [sectors] 1927 ;cmp cx, [sectors] 1928 ;je short cpp_4 ; start sector is as aligned 1929 00000846 6639D9 cmp ecx, ebx 1930 00000849 740F je short cpp_4 ; start sector is as aligned 1931 0000084B EB05 jmp short cpp_3 1932 cpp_2: 1933 ;cmp ax, cx 1934 ;jne short cpp_3 1935 ;cmp dx, bx 1936 ;je short cpp_4 1937 ; 07/11/2020 1938 0000084D 6639C8 cmp eax, ecx 1939 00000850 7408 je short cpp_4 1940 cpp_3: 1941 ;mov ax, cx 1942 ;mov dx, bx 1943 ; 07/11/2020 1944 00000852 6689C8 mov eax, ecx 1945 00000855 C606[B26D]4E mov byte [cylinder_boundary], 'N' 1946 cpp_4: 1947 ;mov [si+ptStartSector], ax 1948 ;mov [si+ptStartSector+2], dx 1949 ; 07/11/2020 1950 0000085A 66894408 mov [si+ptStartSector], eax 1951 1952 ; save start sector (for partition formatting procedure) 1953 ;mov [pp_StartSector], ax 1954 ;mov [pp_StartSector+2], dx 1955 0000085E 66A3[DC69] mov [pp_StartSector], eax 1956 1957 ; 14/03/2021 1958 00000862 668B0E[146A] mov ecx, [ppn_Sectors] 1959 1960 ; 19/10/2020 1961 00000867 803E[E66C]00 cmp byte [pcount], 0 1962 0000086C 7752 ja short cpp_5 1963 1964 ; 07/11/2020 1965 ;;xor cx, cx 1966 ;xor ecx, ecx 1967 ;mov [si+ptBeginCylinder], cx ; 0 1968 ;inc cl ; 1 1969 ;mov [si+ptBeginSector], cl ; 1 1970 ;mov [si+ptBeginHead], cl ; 1 1971 ; 14/03/2021 1972 0000086E C744030000 mov word [si+ptBeginCylinder], 0 1973 00000873 C6440201 mov byte [si+ptBeginSector], 1 1974 00000877 C6440101 mov byte [si+ptBeginHead], 1 1975 1976 ; set active partition flag 1977 ;mov byte [si+ptBootable], 80h ; bootable/active partition 1978 0000087B C60480 mov byte [si], 80h ; bootable/active partition 1979 1980 ; 18/02/2019 1981 1982 ;;mov cx, [ppn_Sectors] 1983 ;;mov bx, [ppn_Sectors+2] 1984 ; 07/11/2020 1985 ;mov ecx, [ppn_sectors] 1986 1987 0000087E 803E[E469]00 cmp byte [wholedisk], 0 1988 00000883 0F864101 jna cpp_12 1989 1990 ; 26/10/2020 1991 ;add ax, cx 1992 ;adc dx, bx 1993 ;sub ax, 1 1994 ;sbb dx, 0 1995 ; 07/11/2020 1996 00000887 6601C8 add eax, ecx 1997 0000088A 6648 dec eax ; sub eax, 1 1998 1999 ; 24/10/2020 2000 ;cmp dx, [chs_limit+2] 2001 ;jb short cpp_17 2002 ;ja short cpp_16 2003 ;cmp ax, [chs_limit] 2004 ;jna short cpp_17 2005 ; 07/11/2020 2006 0000088C 663B06[4E65] cmp eax, [chs_limit] 2007 00000891 760F jna short cpp_17 2008 cpp_16: 2009 00000893 C64405FE mov byte [si+ptEndHead], 0FEh 2010 00000897 C64406FF mov byte [si+ptEndSector], 0FFh 2011 0000089B C64407FF mov byte [si+ptEndCylinder], 0FFh 2012 0000089F E9BA01 jmp cpp_15 2013 cpp_17: 2014 000008A2 A0[BC3C] mov al, [heads] 2015 000008A5 FEC8 dec al 2016 000008A7 884405 mov [si+ptEndHead], al 2017 000008AA A0[BA3C] mov al, [sectors] 2018 000008AD 884406 mov [si+ptEndSector], al 2019 000008B0 A1[BE3C] mov ax, [cylinders] 2020 000008B3 48 dec ax 2021 000008B4 884407 mov [si+ptEndCylinder], al 2022 000008B7 C0E406 shl ah, 6 2023 000008BA 086406 or [si+ptEndSector], ah 2024 2025 ;jmp cpp_16 2026 000008BD E99C01 jmp cpp_15 ; 06/03/2019 2027 cpp_5: 2028 ; 14/03/2021 2029 ; eax = start sector 2030 2031 ; 18/02/2019 2032 000008C0 803E[B26D]59 cmp byte [cylinder_boundary], 'Y' 2033 000008C5 7535 jne short cpp_7 2034 2035 000008C7 30DB xor bl, bl ; head = 0 2036 2037 ; 14/03/2021 2038 ;mov cx, [di+free_space.start] 2039 000008C9 668B8D[466D] mov ecx, [di+free_space.start] 2040 ; ecx = start cylinder 2041 2042 ; 06/03/2019 2043 ;or ax, ax 2044 ;jnz short cpp_6 2045 2046 ;and cx, cx ; start cylinder = 0 ? 2047 ;jnz short cpp_6 2048 2049 ;or ax, cx 2050 ;;jnz short cpp_6 2051 ;jz short cpp_24 ; 31/10/2020 2052 ; 14/03/2021 2053 000008CE 6609C8 or eax, ecx 2054 000008D1 7409 jz short cpp_24 ; cyl = 0, sector = 0 2055 2056 ; 31/10/2020 2057 ;mov al, [sectors] 2058 ;mul byte [heads] 2059 ;mul cx 2060 ;; dx:ax = LBA sector address 2061 ;; bl = head = 0 2062 ;; cx = cylinder number 2063 ; 14/03/2021 2064 000008D3 66A1[086A] mov eax, [hs] ; [heads] * [sectors] 2065 000008D7 66F7E1 mul ecx 2066 ; eax = LBA sector address 2067 ; ecx = cylinder number 2068 ; bl = head = 0 2069 2070 000008DA EB05 jmp short cpp_6 2071 cpp_24: 2072 ; 14/03/2021 2073 ;mov ax, [sectors] 2074 000008DC A0[BA3C] mov al, [sectors] 2075 2076 ; cylinder 0, head 1, sector 1 (LBA = 17 or 63) 2077 000008DF FEC3 inc bl ; head = 1 2078 ; 14/03/2021 2079 ;xor dx, dx ; 0 2080 cpp_6: 2081 ; 31/10/2020 2082 ;mov [si+ptStartSector], ax 2083 ;mov [si+ptStartSector+2], dx 2084 ; 14/03/2021 2085 000008E1 66894408 mov [si+ptStartSector], eax 2086 2087 ;mov [pp_StartSector], ax 2088 ;mov [pp_StartSector+2], dx 2089 ; 14/03/2021 2090 000008E5 66A3[DC69] mov [pp_StartSector], eax 2091 2092 ;or cx, cx ; start cylinder ? 2093 ;jnz short cpp_25 ; > 0 2094 ; 14/03/2021 2095 000008E9 6609C9 or ecx, ecx ; start cylinder ? 2096 000008EC 7505 jnz short cpp_25 ; > 0 2097 2098 ;and bl, bl ; head = 0 ? 2099 ;jz short cpp_25 2100 2101 ; cylinder = 0, head = 1, dx:ax = [sectors] 2102 2103 ;;sub [pp_Sectors], ax 2104 ;;sbb [pp_Sectors+2], cx ; 0 2105 2106 ;sub [ppn_Sectors], ax 2107 ;sbb [ppn_Sectors+2], cx ; 0 2108 ; 14/03/2021 2109 000008EE 662906[146A] sub [ppn_Sectors], eax 2110 cpp_25: 2111 ; 14/03/2021 2112 ;mov ax, cx 2113 000008F3 6689C8 mov eax, ecx 2114 2115 ; 29/10/2020 2116 000008F6 C6440201 mov byte [si+ptBeginSector], 1 ; sector = 1 2117 000008FA EB1E jmp short cpp_8 2118 cpp_7: 2119 ; 18/02/2019 2120 2121 ; [wholedisk] = 0 2122 2123 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 2124 ; (DOS partition size will be changed -down- to 65535 sectors, 2125 ; if it is 65536 sectors.) 2126 2127 000008FC E86E01 call fix_32mb_dos_psize 2128 ; bx:cx = [ppn_sectors] = partition size 2129 ; dx:ax = start sector's LBA 2130 2131 ;cylinder = LBA / (heads_per_cylinder * sectors_per_track) 2132 ;temp = LBA % (heads_per_cylinder * sectors_per_track) 2133 ;head = temp / sectors_per_track 2134 ;sector = temp % sectors_per_track + 1 2135 2136 ; Convert LBA sector address to CHS parameters 2137 ;mov cx, [sectors] 2138 ;call div32 2139 ;; BX = Sector number - 1 2140 ;inc bl ; sector number (1 based) 2141 ;mov [si+ptBeginSector], bl 2142 2143 ; 14/03/2021 2144 ; eax = start sector address (LBA) 2145 2146 ; 07/11/2020 2147 000008FF 6629D2 sub edx, edx ; 14/03/2021 2148 ;movzx ecx, byte [sectors] 2149 00000902 6631C9 xor ecx, ecx 2150 00000905 8A0E[BA3C] mov cl, [sectors] 2151 00000909 66F7F1 div ecx 2152 0000090C FEC2 inc dl ; sector number (1 based) 2153 0000090E 885402 mov [si+ptBeginSector], dl 2154 ; eax = cylinders * heads + head 2155 2156 ;; DX_AX = cylinders * heads + head 2157 ;mov cx, [heads] 2158 ;call div32 2159 ;; ax = cylinder 2160 ;; bl = head 2161 2162 ; 07/11/2020 2163 ;sub edx, edx 2164 ;sub dx, dx 2165 00000911 28D2 sub dl, dl 2166 ;movzx ecx, byte [heads] 2167 00000913 8A0E[BC3C] mov cl, [heads] 2168 00000917 66F7F1 div ecx 2169 ; eax = cylinder 2170 ; dl = head 2171 cpp_8: 2172 ;; 24/10/2020 2173 ;;mov bh, 1 ; [si+ptBeginSector] 2174 ;cmp ax, 1023 ; CHS limit 2175 ;jna short cpp_18 2176 ; 07/11/2020 2177 0000091A 663DFF030000 cmp eax, 1023 2178 00000920 760C jna short cpp_18 2179 2180 ; > CHS limit 2181 ;mov ax, 1023 ; cylinder 2182 ;mov bl, 0FEh ; 254 (head) 2183 ;mov bh, 3Fh ; 63 (sector) 2184 ; 07/11/2020 2185 00000922 66B8FF030000 mov eax, 1023 2186 00000928 B2FE mov dl, 0FEh ; 254 2187 ; 26/10/2020 2188 0000092A C644023F mov byte [si+ptBeginSector], 3Fh 2189 cpp_18: 2190 ; 07/11/2020 2191 ; DL = Head number 2192 0000092E 885401 mov [si+ptBeginHead], dl 2193 2194 ;; BL = Head number 2195 ;mov [si+ptBeginHead], bl 2196 ; AX = Cylinder number 2197 ;and ax, 1023 2198 00000931 884403 mov [si+ptBeginCylinder], al 2199 00000934 C0E406 shl ah, 6 2200 ; 24/10/2020 2201 ;or ah, bh ; bh = sector number 2202 ; 26/10/2020 2203 00000937 086402 or [si+ptBeginSector], ah 2204 ;mov [si+ptBeginSector], ah 2205 2206 ; clear active partition flag (for now) 2207 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 2208 0000093A C60400 mov byte [si], 0 ; not bootable/active partition 2209 2210 ;mov di, [c_fspc_offset] 2211 2212 0000093D 803E[B26D]59 cmp byte [cylinder_boundary], 'Y' 2213 00000942 757B jne cpp_11 2214 2215 ;mov cl, [heads] 2216 ;mov al, [sectors] 2217 ;mov ch, al 2218 ;mul cl 2219 ;; ax = heads*sectors 2220 ; 14/03/2021 2221 ;mov eax, [hs] ; heads * spt 2222 2223 ;mov bx, [di+free_space.end] ; end cylinder of the partition 2224 ; 14/03/2021 2225 ;mov ebx, [di+free_space.end] 2226 00000944 668B85[4A6D] mov eax, [di+free_space.end] 2227 2228 00000949 803E[E469]00 cmp byte [wholedisk], 0 ; entire free space ? 2229 0000094E 771C ja short cpp_10 2230 2231 ;mov bx, ax 2232 ;mov ax, [ppn_Sectors] 2233 ;mov dx, [ppn_Sectors+2] 2234 ;add ax, [pp_StartSector] 2235 ;adc dx, [pp_StartSector+2] 2236 ;sub ax, 1 2237 ;sbb dx, 0 2238 ; ; dx:ax = end sector 2239 ;div bx 2240 ; ; ax = cylinder number 2241 ; 14/03/2021 2242 ;mov ebx, eax 2243 00000950 66A1[146A] mov eax, [ppn_Sectors] 2244 00000954 660306[DC69] add eax, [pp_StartSector] 2245 00000959 6648 dec eax 2246 0000095B 6631D2 xor edx, edx 2247 ;div ebx 2248 0000095E 66F736[086A] div dword [hs] ; heads * spt 2249 ; eax = (end) cylinder number 2250 2251 ; 31/10/2020 2252 ;and dx, dx 2253 ;jz short cpp_9 2254 ;inc ax ; + 1 (because of remainder > 0) 2255 cpp_9: 2256 ;xchg ax, bx 2257 ; ; bx = end cylinder 2258 ; ; ax = heads*sectors 2259 ; 14/03/2021 2260 ;xchg eax, ebx 2261 2262 ; free space limit check 2263 ;cmp bx, [di+free_space.end] 2264 ;jna short cpp_10 ; ok 2265 ;; end cylinder is out of free space 2266 ;dec bx ; decrease end cylinder number 2267 ; 14/03/2021 2268 00000963 663B85[4A6D] cmp eax, [di+free_space.end] 2269 00000968 7602 jna short cpp_10 ; ok 2270 0000096A 6648 dec eax 2271 cpp_10: 2272 0000096C 6650 push eax ; * ; end cylinder 2273 ;mul bx 2274 ; ; dx:ax = (end cylinder)*heads*sectors 2275 ; 14/03/2021 2276 0000096E 66F726[086A] mul dword [hs] ; heads * spt 2277 ; eax = (end cylinder)*heads*sectors 2278 ; edx = 0 2279 00000973 665A pop edx ; * ; end cylinder 2280 2281 ;push dx ; ** 2282 ;push ax ; * 2283 ; 14/03/2021 2284 00000975 6650 push eax ; ** 2285 2286 00000977 6631C0 xor eax, eax ; clear high word of eax 2287 0000097A A0[BA3C] mov al, [sectors] 2288 0000097D 8A26[BC3C] mov ah, [heads] 2289 2290 ; 24/10/2020 2291 ;cmp bx, 1023 ; CHS limit 2292 ;jna short cpp_19 2293 ;; > CHS limit 2294 ;mov bx, 1023 ; cylinder 2295 ;;mov cl, 0FFh ; 255 (head+1) 2296 ;;mov ch, 3Fh ; 63 (sector) 2297 ;mov cx, 3FFFh 2298 ; 14/03/2021 2299 00000981 6681FAFF030000 cmp edx, 1023 ; CHS limit 2300 00000988 7609 jna short cpp_19 2301 ; > CHS limit 2302 0000098A 66BAFF030000 mov edx, 1023 ; cylinder 2303 00000990 B83FFF mov ax, 0FF3Fh ; heads = 255, sector = 63 2304 cpp_19: 2305 ;dec cl ; heads - 1 = end head 2306 ; 14/03/2021 2307 00000993 FECC dec ah ; heads - 1 = end head 2308 2309 ; 14/03/2021 2310 ; al = sectors (spt), ah = end head 2311 2312 ;mov [si+ptEndHead], cl 2313 ; 14/03/2021 2314 00000995 886405 mov [si+ptEndHead], ah 2315 2316 ;; 26/10/2020 2317 ;;mov al, [sectors] 2318 ;; 31/10/2020 2319 ;mov al, ch 2320 ;mov [si+ptEndCylinder], bl 2321 ;;mov bl, al 2322 ;;shl bh, 6 ; shift high bytes (2 bits) of end cyl num 2323 ;; ; to 6 bits left 2324 ;;or bh, bl ; combine high bits of end cyl num and end sector 2325 ;shl bh, 6 2326 ;or bh, ch ; ch = end sector (= sectors) 2327 ;mov [si+ptEndSector], bh 2328 ; 14/03/2021 2329 00000998 885407 mov [si+ptEndCylinder], dl 2330 0000099B C0E606 shl dh, 6 2331 0000099E 08C6 or dh, al ; or dh, byte [sectors] 2332 000009A0 887406 mov [si+ptEndSector], dh 2333 2334 ; 24/10/2020 2335 ;;mov bl, [sectors] 2336 ;;xor bh, bh ; clear bh 2337 ;mov bx, [sectors] ; 17 or 63 2338 ;dec bl ; sectors - 1 ; 22/02/2019 2339 ; 14/03/2021 2340 000009A3 88C2 mov dl, al ; sectors (spt) 2341 000009A5 30F6 xor dh, dh 2342 000009A7 FECA dec dl 2343 ; edx = sectors - 1 2344 2345 ;mul cl ; sectors * [end head] 2346 ; 14/03/2021 2347 000009A9 F6E4 mul ah 2348 ; eax = sectors * [end head] 2349 2350 ;pop dx ; * 2351 ;; 22/02/2019 2352 ;xor cx, cx 2353 ;add ax, dx 2354 ;pop dx ; ** 2355 ;adc dx, cx ; 0 2356 ;add ax, bx 2357 ;adc dx, cx ; 0 2358 ;; dx:ax = ((([end cylinder]*heads)+[end head])*sectors)+sectors-1 2359 ; 14/03/2021 2360 000009AB 6601D0 add eax, edx ; ([end head]*sectors)+sectors-1 2361 000009AE 665A pop edx ; (end cylinder)*heads*sectors 2362 000009B0 6601D0 add eax, edx 2363 ; eax = (([end cylinder]*heads)+[end head])*sectors)+sectors-1 2364 2365 ; calculate aligned partition size in sectors 2366 ;mov cx, ax 2367 ;mov bx, dx 2368 ;add cx, 1 2369 ;adc bx, 0 2370 ;sub cx, [si+ptStartSector] 2371 ;sbb bx, [si+ptStartSector+2] 2372 ; ; bx:cx = partition size 2373 ;;mov [ppn_Sectors], cx 2374 ;;mov [ppn_Sectors+2], bx 2375 ;;jmp cpp_16 2376 ; 14/03/2021 2377 000009B3 6689C1 mov ecx, eax 2378 000009B6 6641 inc ecx 2379 000009B8 662B4C08 sub ecx, [si+ptStartSector] 2380 ; ecx = partition size in sectors 2381 2382 000009BC E99D00 jmp cpp_15 ; 06/03/2019 2383 cpp_11: 2384 ; 20/02/2019 2385 ;mov cx, [ppn_Sectors] 2386 ;mov bx, [ppn_Sectors+2] 2387 ; 14/03/2021 2388 000009BF 668B0E[146A] mov ecx, [ppn_Sectors] 2389 2390 ;;;mov ax, [di+free_space.startsector] 2391 ;;;mov ax, [di+free_space.startsector+2] 2392 ;;mov ax, [si+ptStartSector] 2393 ;;mov dx, [si+ptStartSector+2] 2394 ;mov ax, [pp_StartSector] 2395 ;mov dx, [pp_StartSector+2] 2396 ; 14/03/2021 2397 000009C4 66A1[DC69] mov eax, [pp_StartSector] 2398 cpp_12: 2399 ; 18/02/2019 2400 2401 ; [wholedisk] = 0 2402 2403 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 2404 ; (DOS partition size will be changed -down- to 65535 sectors, 2405 ; if it is 65536 sectors.) 2406 2407 000009C8 E8A200 call fix_32mb_dos_psize 2408 ; bx:cx = [ppn_sectors] = partition size 2409 ; dx:ax = start sector's LBA 2410 2411 ;add ax, cx 2412 ;adc dx, bx 2413 ; 14/03/2021 2414 000009CB 6601C8 add eax, ecx 2415 2416 ; Convert LBA sector address to CHS parameters 2417 ;sub ax, 1 ; locate on to end sector of the partition 2418 ;sbb dx, 0 2419 ; 14/03/2021 2420 000009CE 6648 dec eax ; end sector of the partition 2421 2422 ; 06/03/2019 2423 000009D0 803E[B26D]59 cmp byte [cylinder_boundary],'Y' 2424 ;jne short cpp_15 2425 000009D5 7545 jne short cpp_14 2426 2427 ;mov cx, ax 2428 ;mov al, [heads] 2429 ;mul byte [sectors] 2430 ;mov di, ax ; [heads]*[sectors] 2431 ;xchg ax, cx 2432 ; ; cx = heads*spt 2433 ; 2434 ;call div32 2435 ; ; dx = 0 2436 ; ; ax = end cylinder 2437 ; ; bx = remainder 2438 ; 14/03/2021 2439 000009D7 6631D2 xor edx, edx 2440 000009DA 66F736[086A] div dword [hs] ; heads*spt 2441 ; eax = end cylinder 2442 ; dx = remainder 2443 2444 ;and bx, bx 2445 ;jz short cpp_13 2446 ;inc ax 2447 ;cpp_13: 2448 ;cmp ax, [cylinders] 2449 ;jb short cpp_14 2450 ;dec ax 2451 ;cpp_14: 2452 2453 ; 26/10/2020 2454 ;cmp ax, 1023 2455 ;jna short cpp_20 2456 ; 14/03/2021 2457 000009DF 663DFF030000 cmp eax, 1023 2458 000009E5 760E jna short cpp_20 2459 2460 000009E7 C64405FE mov byte [si+ptEndHead], 0FEh 2461 000009EB C64406FF mov byte [si+ptEndSector], 0FFh 2462 000009EF C64407FF mov byte [si+ptEndCylinder], 0FFh 2463 000009F3 EB16 jmp short cpp_21 2464 cpp_20: 2465 ;mov bx, [heads] 2466 000009F5 8A1E[BC3C] mov bl, [heads] 2467 000009F9 FECB dec bl 2468 000009FB 885C05 mov [si+ptEndHead], bl 2469 ;;mov cx, [sectors] 2470 ;mov cl, [sectors] 2471 ;mov dl, ah 2472 ;shl dl, 6 2473 ;or dl, cl 2474 ;mov [si+ptEndSector], dl 2475 ; 14/03/2021 2476 000009FE C0E406 shl ah, 6 2477 00000A01 0A26[BA3C] or ah, [sectors] 2478 00000A05 886406 mov [si+ptEndSector], ah 2479 00000A08 884407 mov [si+ptEndCylinder], al 2480 ;mul di ; [cylinders]*[heads]*[sectors] 2481 ;;sub di, cx ; ([heads] - 1) * [sectors] 2482 ;add ax, di 2483 ;adc dx, 0 2484 ;;add ax, cx 2485 ;;adc dx, 0 2486 cpp_21: 2487 ;inc ax 2488 ;mul di ; result = start LBA of next cylinder 2489 ;; dx:ax = end sector LBA + 1 (as cyl. boundary aligned) 2490 ; 14/03/2021 2491 00000A0B 6640 inc eax ; end sector address + 1 2492 00000A0D 66F726[086A] mul dword [hs] ; heads*spt 2493 2494 ;sub ax, [pp_StartSector] 2495 ;sbb dx, [pp_StartSector+2] 2496 ; 14/03/2021 2497 00000A12 662B06[DC69] sub eax, [pp_StartSector] 2498 2499 ;mov cx, ax 2500 ;mov bx, dx 2501 ;;jmp short cpp_16 2502 ; 14/03/2021 2503 00000A17 6689C1 mov ecx, eax ; partition size 2504 2505 00000A1A EB40 jmp short cpp_15 2506 ;cpp_15: 2507 cpp_14: 2508 ; 14/03/2021 2509 ; eax = end sector 2510 2511 ;mov cx, [sectors] 2512 ;call div32 2513 ;; BX = Sector number - 1 2514 ;inc bl ; sector number (1 based) 2515 ;mov [si+ptEndSector], bl 2516 ;; DX_AX = cylinders * heads + head 2517 ; 14/03/2021 2518 ;xor edx, edx 2519 00000A1C 31D2 xor dx, dx 2520 00000A1E 660FB61E[BA3C] movzx ebx, byte [sectors] 2521 00000A24 66F7F3 div ebx 2522 ; dl = sector number - 1 2523 00000A27 FEC2 inc dl ; sector number 2524 00000A29 885406 mov [si+ptEndSector], dl 2525 2526 ;mov cx, [heads] 2527 ;call div32 2528 ;; BX = Head number 2529 ;mov [si+ptEndHead], bl 2530 ;; AX = Cylinder number 2531 ;;and ax, 1023 2532 ; 14/03/2021 2533 ;xor dx, dx 2534 00000A2C 30D2 xor dl, dl 2535 00000A2E 8A1E[BC3C] mov bl, [heads] 2536 00000A32 66F7F3 div ebx 2537 ; eax = cylinder number 2538 ; dl = head number 2539 00000A35 885405 mov [si+ptEndHead], dl 2540 2541 ; 26/10/2020 2542 ;cmp ax, 1023 2543 ;jna short cpp_22 2544 ; 14/03/2021 2545 00000A38 663DFF030000 cmp eax, 1023 2546 00000A3E 760E jna short cpp_22 2547 2548 00000A40 C64405FE mov byte [si+ptEndHead], 0FEh 2549 00000A44 C64406FF mov byte [si+ptEndSector], 0FFh 2550 00000A48 C64407FF mov byte [si+ptEndCylinder], 0FFh 2551 00000A4C EB09 jmp short cpp_23 2552 cpp_22: 2553 00000A4E 884407 mov [si+ptEndCylinder], al 2554 ; 18/02/2019 2555 00000A51 C0E406 shl ah, 6 2556 00000A54 086406 or [si+ptEndSector], ah 2557 cpp_23: 2558 ;mov cx, [ppn_Sectors] 2559 ;mov bx, [ppn_Sectors+2] 2560 ; 14/03/2021 2561 00000A57 668B0E[146A] mov ecx, [ppn_Sectors] 2562 ;cpp_16: 2563 cpp_15: 2564 ;mov [si+ptSectors], cx 2565 ;mov [si+ptSectors+2], bx 2566 ; 14/03/2021 2567 00000A5C 66894C0C mov [si+ptSectors], ecx 2568 2569 ; set partition ID after checking DOS FAT limits 2570 00000A60 E8E500 call set_partition_id 2571 ; al = partition ID 2572 2573 ; 14/03/2021 2574 ; clear -specially- high word of ecx 2575 00000A63 6631C9 xor ecx, ecx ; (this may not be needed!?) 2576 2577 00000A66 A2[E569] mov [pp_type], al 2578 2579 00000A69 884404 mov [si+ptFileSystemID], al 2580 2581 00000A6C C3 retn 2582 2583 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2584 ; decrease DOS partition size when it is (exact) 65536 sectors 2585 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2586 ; 07/11/2020 (fdisk4) 2587 ; 18/02/2019 2588 2589 fix_32mb_dos_psize: ; call this if [wholedisk] = 0 2590 2591 ; Purpose: 2592 ; If a DOS partition's size is 65536 sectors 2593 ; MSDOS 3.3 can not use it. (FAT 16 partition ID = 06h) 2594 ; Decreasing partition size to 65535 sectors will ensure 2595 ; MSDOS 3.3 compatibility (FAT 16 partition ID will be 04h). 2596 2597 ; INPUT: 2598 ; BX:CX = partition size in sectors 2599 ; [pp_type] = partition type dos, non-dos, user input 2600 ; 2601 ; OUTPUT: 2602 ; Partition size will be changed to 65535 sectors, if 2603 ; - partition size is 65536 sectors and 2604 ; - [pp_type] is 1 (DOS) 2605 ; 2606 ; [ppn_Sectors] = 65535 (if it will be changed) 2607 ; 2608 ; (Modified registers: cx, bx) 2609 2610 ;mov cx, [ppn_Sectors] 2611 ;mov bx, [ppn_Sectors+2] 2612 2613 00000A6D 803E[E569]01 cmp byte [pp_type], 1 ; DOS partition 2614 00000A72 7514 jne short psfx_0 ; non-dos partition or user input 2615 ; nothing to do ! 2616 ; 07/11/2020 2617 ;or cx, cx 2618 00000A74 7512 jnz short psfx_0 ; <> 65536 sectors 2619 ;cmp bx, 1 2620 00000A76 7510 jne short psfx_0 2621 ;dec bx 2622 ;;mov [wholedisk], bx ; 0 2623 ;dec cx ; bx:cx = 65535 2624 ;mov [ppn_Sectors], cx 2625 ;mov [ppn_Sectors+2], bx 2626 2627 ; 07/11/2020 (fdisk4) 2628 00000A78 6681F900000100 cmp ecx, 65536 2629 00000A7F 7507 jne short psfx_0 2630 00000A81 6649 dec ecx ; 65535 2631 00000A83 66890E[146A] mov [ppn_Sectors], ecx 2632 psfx_0: 2633 00000A88 C3 retn 2634 2635 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2636 ; create extended dos partition 2637 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2638 ; 24/10/2020 (fdisk3.s) 2639 2640 ; 16/02/2019 (hdimage.s) 2641 ; (This procedure must be called after 'find_part_free_space') 2642 2643 ; 15/03/2021 (fdisk4.s) 2644 create_extended_partition: 2645 ; 15/02/2019 2646 2647 ; INPUT: 2648 ; none 2649 ; (CHS parameters and free space calculation result will be used.) 2650 ; 2651 ; OUTPUT: 2652 ; Partition table in MBR buffer will be updated. 2653 ; 2654 ; (Modified registers: ax, bx, cx, dx, si, di) 2655 2656 ; Create extended dos partition, make partition table entry 2657 ; (Extended partition will be created on cylinder bounds.) 2658 2659 ; 16/02/2019 2660 00000A89 E8E01A call get_first_free_pte 2661 ; CX = First free PTE number, 0 to 3 2662 ; (CX = 3 if there is not a free PTE, and CF = 1) 2663 ; ((But CF = 1 is not possible here because pcount < 4)) 2664 ; SI = PTE addres/offset in MBR buffer 2665 2666 ;mov si, MasterBootBuff+pTableOffset 2667 ;shl cl, 4 ; * 16 2668 ;add si, cx 2669 2670 ;mov bx, [c_fspc_offset] 2671 ; 15/03/2021 2672 00000A8C 8B3E[B06D] mov di, [c_fspc_offset] 2673 2674 ;mov ax, [bx+free_space.start] 2675 ; 15/03/2021 2676 00000A90 668B85[466D] mov eax, [di+free_space.start] 2677 2678 ; 24/10/2020 2679 ;mov di, ax ; 15/03/2021 2680 2681 ;mov cx, 1 2682 00000A95 B101 mov cl, 1 ; head (ch) = 0, sector (cl) = 1 2683 2684 ; 15/03/2021 2685 00000A97 6689C3 mov ebx, eax 2686 2687 ;cmp ax, 1023 2688 ;jna short cep_4 2689 ; 15/03/2021 2690 00000A9A 663DFF030000 cmp eax, 1023 2691 00000AA0 7609 jna short cep_4 2692 2693 ; partition start > CHS limit 2694 ;mov ax, 1023 2695 ; 15/03/2021 2696 00000AA2 66B8FF030000 mov eax, 1023 2697 2698 ;mov ch, 254 2699 ;mov cl, 63 2700 00000AA8 B93FFE mov cx, 0FE3Fh 2701 cep_4: 2702 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 2703 ;mov [si], ch ; 0 ; not bootable/active partition 2704 ; 26/10/2020 2705 00000AAB C60400 mov byte [si], 0 2706 00000AAE 886C01 mov [si+ptBeginHead], ch 2707 00000AB1 C0E406 shl ah, 6 2708 00000AB4 08E1 or cl, ah 2709 00000AB6 884C02 mov [si+ptBeginSector], cl ; Sector 1 2710 00000AB9 884403 mov [si+ptBeginCylinder], al 2711 2712 ;mov al, [heads] 2713 ;mul byte [sectors] 2714 ; ; ax = heads*sectors 2715 ;mul di ; AX * cylinder count before start cylinder 2716 ; ; DX:AX = LBA of cylinder DI, head 0, sector 1 2717 ; 15/03/2021 2718 ; eax = start cylinder 2719 00000ABC 6689D8 mov eax, ebx 2720 00000ABF 66F726[086A] mul dword [hs] ; heads * sectors 2721 ; eax = start sector, edx = 0 2722 2723 ;mov [si+ptStartSector], ax 2724 ;mov [si+ptStartSector+2], dx 2725 ; 15/03/2021 2726 00000AC4 66894408 mov [si+ptStartSector], eax 2727 2728 ; This is not needed for extended partition. 2729 ; 16/02/2019 2730 ;mov [pp_StartSector], ax 2731 ;mov [pp_StartSector+2], dx 2732 ; 15/03/2021 2733 ;mov [pp_StartSector], eax 2734 2735 ; 16/02/2019 2736 00000AC8 803E[E469]00 cmp byte [wholedisk], 0 2737 00000ACD 7719 ja short cep_2 ; all of free space will be used 2738 ; ([bx+free_space.end] will be end cyl) 2739 2740 ; calculate cylinder count (from partition size input) 2741 ;mov al, [heads] 2742 ;mul byte [sectors] 2743 ;mov cx, ax 2744 ;mov ax, [ppn_Sectors] 2745 ;mov dx, [ppn_Sectors+2] 2746 ;call div32 2747 ; ; ax = cylinders 2748 ; ; bx = remainder 2749 ;and bx, bx 2750 ;jz short cep_1 2751 ;inc ax ; round up 2752 ; 15/03/2021 2753 ; edx = 0 2754 00000ACF 66A1[146A] mov eax, [ppn_Sectors] 2755 00000AD3 66F736[086A] div dword [hs] ; heads * spt 2756 ; eax = cylinders, dx = remainder 2757 00000AD8 21D2 and dx, dx 2758 00000ADA 7402 jz short cep_1 2759 00000ADC 6640 inc eax ; round up 2760 cep_1: 2761 ; 15/03/2021 2762 ; EBX = extended partition's start cylinder 2763 ; 16/02/2019 2764 ; DI = extended partition's start cylinder 2765 ;mov dx, ax ; cylinder count 2766 ;add dx, di ; result is end cyl + 1 2767 ;dec dx ; decrease number for current end cylinder 2768 ;mov bx, [c_fspc_offset] 2769 ;cmp dx, [bx+free_space.end] 2770 ;jna short cep_3 2771 ; 24/10/2020 2772 ;;dec ax ; decrease cylinder count down to the limit 2773 ;dec dx ; decrease end cylinder down to the limit 2774 ; 15/03/2021 2775 00000ADE 6689C2 mov edx, eax ; cylinder count 2776 00000AE1 6601DA add edx, ebx ; result is end cyl + 1 2777 00000AE4 664A dec edx ; end cylinder 2778 ;mov di, [c_fspc_offset] 2779 2780 00000AE6 EB05 jmp short cep_3 2781 cep_2: 2782 ; 15/03/2021 2783 ; DI = [c_fspc_offset] 2784 2785 ;mov dx, [bx+free_space.end] 2786 ;;mov ax, [bx+free_space.space] 2787 ; 15/03/2021 2788 00000AE8 668B97[4A6D] mov edx, [bx+free_space.end] 2789 cep_3: 2790 ; 15/03/2021 2791 00000AED 6631DB xor ebx, ebx 2792 2793 ; 24/10/2020 2794 ;mov ax, dx ; end cylinder 2795 ;mov bl, 05h ; Extended Partition ID (CHS) 2796 ;cmp ax, 1023 2797 ;jna short cep_5 2798 ; 15/03/2021 2799 00000AF0 6689D0 mov eax, edx ; end cylinder 2800 00000AF3 B305 mov bl, 05h ; Extended Partition ID (CHS) 2801 00000AF5 663DFF030000 cmp eax, 1023 2802 00000AFB 760D jna short cep_5 2803 2804 ; partition end > CHS limit 2805 ;mov ax, 1023 2806 ; 15/03/2021 2807 00000AFD 66B8FF030000 mov eax, 1023 2808 2809 ;mov ch, 254 2810 ;mov cl, 63 2811 00000B03 B93FFE mov cx, 0FE3Fh 2812 00000B06 B30F mov bl, 0Fh ; Extended Partition ID (LBA) 2813 00000B08 EB0A jmp short cep_6 2814 cep_5: 2815 00000B0A 8A2E[BC3C] mov ch, [heads] 2816 00000B0E FECD dec ch 2817 00000B10 8A0E[BA3C] mov cl, [sectors] 2818 cep_6: 2819 00000B14 886C05 mov [si+ptEndHead], ch 2820 ; 24/10/2020 2821 ; ax = (chs limit compatible) end cylinder (<= 1023) 2822 ; 23/02/2019 2823 ;mov bl, dh 2824 ;shl bl, 6 2825 ;or bl, cl 2826 00000B17 C0E406 shl ah, 6 2827 ;or cl, ah 2828 ;;mov [si+ptEndSector], bl 2829 ;mov [si+ptEndSector], cl 2830 ; 15/03/2021 2831 00000B1A 08CC or ah, cl 2832 00000B1C 886406 mov [si+ptEndSector], ah 2833 ;mov [si+ptEndCylinder], dl 2834 00000B1F 884407 mov [si+ptEndCylinder], al 2835 ; dx = (lba compatible) end cylinder (up to 65535) 2836 2837 ;mov al, [heads] 2838 ; 26/10/2020 2839 ;;;mul cl 2840 ;;mul byte [sectors] 2841 ;mov ch, [heads] 2842 ;mov al, [sectors] 2843 ;mul ch 2844 ;; ax = heads*sectors 2845 ;mul dx ; AX * cylinder count before end cylinder 2846 ; ; DX:AX = LBA of cylinder DX, head 0, sector 1 2847 ; 15/03/2021 2848 ; edx = end cylinder 2849 00000B22 66A1[086A] mov eax, [hs] ; [heads] * [sectors] 2850 00000B26 66F7E2 mul edx 2851 ; eax = LBA of end cylinder, head 0, sector 1 2852 ; edx = 0 2853 ;push dx 2854 ;push ax 2855 ; 15/03/2021 2856 00000B29 6650 push eax ; (end cylinder)*heads*sectors 2857 2858 00000B2B 88E8 mov al, ch 2859 00000B2D FEC8 dec al ; 26/10/2020 ; [heads] - 1 2860 ;mov cx, [sectors] ; 63 or 17 2861 ; cl = sectors ; 15/03/2021 2862 00000B2F F6E1 mul cl 2863 ; ax = (heads-1)*sectors 2864 ; 15/03/2021 2865 00000B31 89C2 mov dx, ax ; (heads-1)*sectors 2866 2867 ;pop dx 2868 ;add ax, dx 2869 ;pop dx 2870 ;adc dx, 0 2871 ; ; dx:ax = ((end cylinder)*heads)+(heads-1)*sectors 2872 ;add ax, cx 2873 ;adc dx, 0 2874 ; dx:ax = (((end cylinder)*heads)+(heads-1))*sectors) + sectors 2875 ; dx:ax = LBA of the partition's end sector + 1 2876 2877 ; 15/03/2021 2878 00000B33 30ED xor ch, ch 2879 00000B35 01CA add dx, cx ; ((heads-1)*sectors)+sectors 2880 00000B37 6658 pop eax ; ((end cylinder)*heads)*sectors 2881 00000B39 6601D0 add eax, edx 2882 ; eax = (((end cylinder)*heads)+(heads-1))*sectors)+sectors 2883 2884 ;sub ax, [si+ptStartSector] 2885 ;sbb dx, [si+ptStartSector+2] 2886 ; 15/03/2021 2887 00000B3C 662B4408 sub eax, [si+ptStartSector] 2888 2889 ;mov [si+ptSectors], ax 2890 ;mov [si+ptSectors+2], dx 2891 ; 15/03/2021 2892 00000B40 6689440C mov [si+ptSectors], eax 2893 2894 ;mov [pp_type], al 2895 2896 ;mov byte [si+ptFileSystemID], 5 2897 ; 24/10/2020 2898 00000B44 885C04 mov [si+ptFileSystemID], bl ; 05h or 0Fh 2899 2900 00000B47 C3 retn 2901 2902 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2903 ; set DOS (and non-dos) partition ID according to partition size 2904 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2905 ; 23/10/2020 2906 2907 ; 15/03/2021 2908 set_partition_id: 2909 ; 07/11/2020 (fdisk4.s, 32 bit registers) 2910 ; 23/10/2020 (fdisk3.s) 2911 ; input: 2912 ; si = partition table offset 2913 ; bx:cx = partition size 2914 2915 ; 18/02/2019 (hdimage.s) 2916 ;mov cx, [ppn_Sectors] 2917 ;mov bx, [ppn_Sectors+2] 2918 2919 00000B48 A0[E569] mov al, [pp_type] 2920 2921 ;cmp byte [pp_type], 1 2922 00000B4B 3C01 cmp al, 1 ; primary DOS (FAT12, FAT16, FAT32) 2923 00000B4D 7525 jne short spid_2 ; singlix, runix or user type 2924 2925 ;mov al, 1 ; FAT12 2926 2927 ;or bx, bx 2928 ;jnz short spid_1 2929 ; 15/03/2021 2930 00000B4F 6681F900000100 cmp ecx, 65536 ; >= 32 MB 2931 00000B56 730D jnb short spid_1 2932 2933 ;cmp cx, 32680 2934 ;;jna short spid_8 ; FAT12 file system 2935 ;jna short spid_19 ; 23/10/2020 2936 ; 07/11/2020 2937 00000B58 6681F9A87F0000 cmp ecx, 32680 2938 00000B5F 7620 jna short spid_19 2939 2940 00000B61 B004 mov al, 4 ; FAT16 (< 32MB) 2941 2942 00000B63 EB46 jmp short spid_8 ; FAT16 (CHS) file system 2943 2944 spid_1: 2945 00000B65 B00B mov al, 0Bh ; FAT32 (CHS) 2946 2947 ;cmp bx, 10h 2948 ; 07/11/2020 2949 00000B67 6681F900001000 cmp ecx, 100000h ; 512 MB 2950 00000B6E 733B jnb short spid_8 ; FAT32 (CHS) file system 2951 2952 00000B70 B006 mov al, 6 ; FAT16 (>= 32MB) 2953 2954 00000B72 EB37 jmp short spid_8 ; FAT16 big (CHS) file system 2955 2956 spid_2: 2957 ;cmp byte [pp_type], 2 ; Singlix FS 2958 00000B74 3C02 cmp al, 2 2959 00000B76 7503 jne short spid_3 2960 00000B78 B0A1 mov al, 0A1h 2961 ;jmp short spid_8 2962 00000B7A C3 retn ; 23/10/2020 2963 spid_3: 2964 ;cmp byte [pp_type], 3 ; Retro Unix FS 2965 00000B7B 3C03 cmp al, 3 2966 00000B7D 7503 jne short spid_4 2967 00000B7F B071 mov al, 71h 2968 ;jmp short spid_8 2969 spid_19: 2970 00000B81 C3 retn 2971 2972 spid_4: 2973 ; another partition type (user input) 2974 2975 ; [pp_type] = 4 2976 2977 00000B82 A0[E669] mov al, [pp_type_user] 2978 2979 ; Check FAT12 fs size validation 2980 2981 00000B85 3C01 cmp al, 1 ; FAT12 2982 00000B87 7737 ja short spid_9 2983 2984 ;and bx, bx 2985 ;jnz short spid_6 2986 2987 ;cmp cx, 32680 2988 ;;jna short spid_8 2989 ;jna short spid_19 ; 23/10/2020 2990 2991 ; 07/11/2020 2992 00000B89 6681F900000100 cmp ecx, 65536 2993 00000B90 730A jnb short spid_6 2994 00000B92 81F9A87F cmp cx, 32680 2995 00000B96 76E9 jna short spid_19 2996 spid_5: 2997 00000B98 B004 mov al, 4 ; FAT16 (<= 32MB) 2998 00000B9A EB0F jmp short spid_8 2999 spid_6: 3000 ;;cmp bx, 10h ; 512MB (16*32MB) 3001 ;cmp bx, 40h ; 2GB (64*32MB) 3002 ;jnb short spid_7 3003 ; 15/03/2021 3004 00000B9C 6681F900004000 cmp ecx, 400000h ; 2GB (64K*64 sectors) 3005 00000BA3 7304 jnb short spid_7 3006 3007 00000BA5 B006 mov al, 6 3008 00000BA7 EB02 jmp short spid_8 3009 spid_7: 3010 00000BA9 B00B mov al, 0Bh ; FAT32 (CHS) partition 3011 spid_8: 3012 ; 23/10/2020 3013 ; check the partition's end sector against CHS limit and 3014 ; convert partition ID if the partition overs CHS limit 3015 ;cmp al, 1 ; FAT12 fs 3016 ;je short spid_19 ; nothing to do (for FAT12 fs) 3017 ;add cx, [si+ptStartSector] 3018 ;adc bx, [si+ptStartSector+2] 3019 ; 15/03/2021 3020 00000BAB 66034C08 add ecx, [si+ptStartSector] 3021 3022 ;cmp bx, [chs_limit+2] 3023 ;jb short spid_19 ; partition's end sector is in CHS limit 3024 ;ja short spid_17 ; out of CHS limit 3025 ;cmp cx, [chs_limit] 3026 ;jna short spid_19 ; partition's end sector is in CHS limit 3027 ; 07/11/2020 3028 00000BAF 663B0E[4E65] cmp ecx, [chs_limit] 3029 00000BB4 76CB jna short spid_19 ; partition's end sector is in CHS limit 3030 spid_17: 3031 ; out of CHS limit, partition ID conversion is needed 3032 00000BB6 3C0B cmp al, 0Bh ; FAT32 CHS 3033 00000BB8 7203 jb short spid_18 3034 00000BBA B00C mov al, 0Ch ; FAT 32 LBA 3035 00000BBC C3 retn 3036 spid_18: 3037 00000BBD B00E mov al, 0Eh ; FAT16 LBA 3038 00000BBF C3 retn 3039 spid_9: 3040 00000BC0 3C04 cmp al, 4 ; FAT16 (< 32 MB) 3041 00000BC2 7511 jne short spid_10 3042 3043 ;or bx, bx 3044 ;jnz short spid_6 3045 ; 15/03/2021 3046 00000BC4 6681F900000100 cmp ecx, 65536 3047 00000BCB 73CF jnb short spid_6 3048 00000BCD 81F93610 cmp cx, 4150 ; 4085 + 32 + 32 + 1 3049 00000BD1 7220 jb short spid_12 3050 3051 ;retn ; FAT16 (< 32 MB) partition 3052 00000BD3 EBD6 jmp short spid_8 ; 23/10/2020 3053 3054 spid_10: 3055 00000BD5 3C06 cmp al, 6 ; FAT 16 big partition 3056 00000BD7 751D jne short spid_13 ; Extended partition or another type 3057 3058 ;and bx, bx 3059 ;jz short spid_11 3060 ; 07/11/2020 3061 00000BD9 6681F900000100 cmp ecx, 65536 3062 00000BE0 720B jb short spid_11 3063 3064 ;;cmp bx, 10h ; 512MB (16*32MB) 3065 ;cmp bx, 40h ; 2GB (64*32MB) 3066 ;jnb short spid_7 3067 ; 15/03/2021 3068 00000BE2 6681F900004000 cmp ecx, 400000h ; 2GB (64K*64 sectors) 3069 00000BE9 73BE jnb short spid_7 3070 3071 ;retn 3072 00000BEB EBBE jmp short spid_8 ; 23/10/2020 3073 3074 spid_11: 3075 ;cmp ax, 4150 ; 4085 + 32 + 32 + 1 3076 00000BED 81F93610 cmp cx, 4150 ; 14/09/2020 (BugFix) 3077 00000BF1 73A5 jnb short spid_5 3078 spid_12: 3079 00000BF3 B001 mov al, 1 ; FAT12 partition 3080 spid_16: 3081 00000BF5 C3 retn 3082 spid_13: 3083 ; 14/09/2020 3084 00000BF6 3C0B cmp al, 0Bh ; FAT 32 (CHS) partition 3085 00000BF8 7432 je short spid_15 ; FAT 32 CHS 3086 00000BFA 3C0C cmp al, 0Ch 3087 00000BFC 7515 jne short spid_14 3088 ; FAT 32 LBA 3089 ;and bx, bx ; < 33 MB 3090 ;jz short spid_11 ; force to FAT 16 CHS or FAT 12 3091 ;cmp bx, 10h ; 512 MB 3092 ;;jnb short spid_8 ; OK, FAT 32 LBA has been confirmed 3093 ;jnb short spid_16 ; 23/10/2020 3094 ; 15/03/2021 3095 00000BFE 6681F900000100 cmp ecx, 65536 3096 00000C05 72E6 jb short spid_11 ; force to FAT 16 CHS or FAT 12 3097 00000C07 6681F900001000 cmp ecx, 100000h ; 512MB 3098 00000C0E 73E5 jnb short spid_16 ; OK 3099 ; < 512MB 3100 00000C10 B00E mov al, 0Eh ; force to FAT 16 LBA 3101 00000C12 C3 retn 3102 spid_14: 3103 ; 14/09/2020 3104 00000C13 3C0E cmp al, 0Eh 3105 ;jne short spid_8 ; non-dos or extended partition 3106 00000C15 75DE jne short spid_16 ; 23/10/2020 3107 ; FAT 16 LBA 3108 ;or bx, bx 3109 ;jz short spid_11 3110 ; 15/03/2021 3111 00000C17 6681F900000100 cmp ecx, 65536 3112 00000C1E 72CD jb short spid_11 3113 ; 23/10/2020 3114 ;cmp bx, 20h ; 1 GB 3115 ;jb short spid_16 3116 ; 15/03/2021 3117 ;((this 1GB limit may be 2GB)) 3118 00000C20 6681F900002000 cmp ecx, 200000h ; 1GB 3119 00000C27 72CC jb short spid_16 3120 00000C29 B00C mov al, 0Ch ; FAT 32 LBA 3121 00000C2B C3 retn 3122 spid_15: 3123 ; Minimum size of FAT 32 FS = 65525 + 512 + 512 + 32 3124 ; >= 66581 sectors (or >= 65525 data clusters) 3125 ;cmp bx, 1 3126 ;jb short spid_11 ; invalid! (< 32 MB) 3127 ;ja short spid_8 3128 ;cmp cx, 1045 3129 ;;jb short spid_16 ; invalid! (< 33 MB) 3130 ;;retn 3131 ;;jmp short spid_8 ; 23/10/2020 3132 ;jnb short spid_8 3133 ; 15/03/2021 3134 00000C2C 6681F915040100 cmp ecx, 66581 3135 00000C33 0F8374FF jnb spid_8 ; OK (>= 33MB) 3136 00000C37 6681F900000100 cmp ecx, 65536 3137 00000C3E 72AD jb short spid_11 ; invalid! (< 32MB) 3138 ;spid_16: 3139 00000C40 B006 mov al, 6 3140 ;retn 3141 00000C42 E966FF jmp spid_8 ; 23/10/2020 3142 3143 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3144 ; 32 bit division by using 16 bit registers 3145 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3146 3147 ; 06/11/2020 (fdisk4) 3148 ; 32 bit division (80386 div instruction for 32 bit regs) 3149 ; will be used instead of div32 procedure for 16 bit regs 3150 ;div32: 3151 ;; DX_AX/CX 3152 ;; Result: DX_AX, BX (remainder) 3153 ;mov bx, ax 3154 ;;or dx, ax ; * DX_AX = 0 ? 3155 ;;jz short div32_retn ; yes, do not divide! 3156 ;mov ax, dx 3157 ;xor dx, dx 3158 ;div cx ; at first, divide DX 3159 ; ; remainder is in DX 3160 ;xchg ax, bx ; now quotient is in BX 3161 ; ; and initial AX value is in AX 3162 ;div cx ; now, DX_AX has been divided and 3163 ; ; AX has quotient 3164 ; ; DX has remainder 3165 ;xchg dx, bx ; finally, BX has remainder 3166 ;;div32_retn: 3167 ;retn 3168 3169 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3170 ; 32 bit multiplication by using 16 bit registers 3171 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3172 3173 ; 06/11/2020 (fdisk4) 3174 ; 32 bit multiplication (80386 mul instruction) 3175 ; will be used instead of mul32 procedure for 16 bit regs 3176 ;mul32: 3177 ;; DX_AX*CX 3178 ;; Result: BX_DX_AX 3179 ;push cx 3180 ;mov bx, dx 3181 ;mul cx 3182 ;xchg ax, bx 3183 ;push dx 3184 ;mul cx 3185 ;pop cx 3186 ;add ax, cx 3187 ;adc dx, 0 3188 ;xchg bx, ax 3189 ;xchg dx, bx 3190 ;pop cx 3191 ;retn 3192 3193 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3194 ; creeate new partition input menu 3195 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3196 3197 B_01: 3198 ; 06/03/2019 3199 00000C45 C606[F269]4D mov byte [pSize_unit], 'M' ; default (for 'whole' disk/space) 3200 ; 15/02/2019 3201 00000C4A E82DFB call create_partition_input 3202 B_02: 3203 00000C4D 21C0 and ax, ax 3204 ;jz _crlf_exit ; 0 = none or not a valid input 3205 00000C4F 0F8480F7 jz A_42 ; 25/02/2019 3206 3207 ;or ah, ah 3208 ;jz short B_03 3209 3210 ; 23/02/2019 3211 00000C53 80FC04 cmp ah, 4 ; user's partition type input ? 3212 00000C56 7505 jne short B_03 ; no 3213 3214 ; 29/10/2020 3215 ; (ah = 0) 3216 ;or al, al 3217 ;jz A_42 ; invalid partition type input 3218 ; ; or ESC key has been pressed 3219 3220 ; user type input 3221 00000C58 A2[E669] mov [pp_type_user], al 3222 00000C5B 88E0 mov al, ah ; mov al, 4 3223 B_03: 3224 00000C5D A2[E569] mov [pp_type], al 3225 3226 ; clear screen 3227 00000C60 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 3228 00000C63 CD10 int 10h 3229 3230 00000C65 A0[E569] mov al, [pp_type] 3231 00000C68 3C01 cmp al, 1 3232 00000C6A 7705 ja short B_04 3233 3234 00000C6C BE[1945] mov si, msg_create_dos_partition_h ; header 3235 00000C6F EB70 jmp short B_09 3236 B_04: 3237 00000C71 3C05 cmp al, 5 3238 00000C73 7269 jb short B_08 3239 ;ja short B_07 3240 00000C75 7741 ja short B_58 ; 26/10/2020 3241 3242 ; 23/02/2019 3243 00000C77 BE[0E46] mov si, msg_create_ext_partition_h 3244 00000C7A E84A0D call print_msg 3245 3246 ; 24/02/2019 3247 00000C7D 803E[E96C]00 cmp byte [epnumber], 0 3248 00000C82 7613 jna short B_05 3249 3250 00000C84 BE[E15B] mov si, msg_ext_partition_exists 3251 00000C87 E83D0D call print_msg 3252 3253 00000C8A BE[D052] mov si, msg_press_any_key 3254 00000C8D E8370D call print_msg 3255 3256 00000C90 30E4 xor ah, ah 3257 00000C92 CD16 int 16h 3258 3259 00000C94 E93CF7 jmp A_42 3260 B_05: 3261 00000C97 803E[E76C]00 cmp byte [ppcount], 0 ; primary partition count 3262 00000C9C 7746 ja short B_10 3263 3264 ; 09/02/2019 3265 00000C9E BE[954C] mov si, msg_ext_partition_error 3266 00000CA1 E8230D call print_msg 3267 B_06: 3268 00000CA4 BE[D052] mov si, msg_press_any_key 3269 00000CA7 E81D0D call print_msg 3270 3271 00000CAA 30E4 xor ah, ah 3272 00000CAC CD16 int 16h 3273 3274 00000CAE C606[E569]01 mov byte [pp_type], 1 3275 3276 00000CB3 E8EFFA call cpi_2 ; 15/02/2019 3277 00000CB6 EB95 jmp short B_02 3278 3279 B_58: 3280 ; 26/10/2020 3281 00000CB8 803E[4665]80 cmp byte [DrvNum], 80h ; hd0 ? 3282 00000CBD 7707 ja short B_59 ; Do not check primary dos partition count 3283 ; The second hard disk may contain extended partition without 3284 ; a primary dos partition 3285 00000CBF 803E[E76C]00 cmp byte [ppcount], 0 ; primary dos partition count 3286 00000CC4 760A jna short B_07 3287 B_59: 3288 00000CC6 803E[E96C]00 cmp byte [epnumber], 0 3289 ; is there an extended partition ? 3290 00000CCB 7603 jna short B_07 ; no 3291 00000CCD E9CDF7 jmp create_logical_drives 3292 B_07: 3293 00000CD0 BE[0347] mov si, msg_create_logical_drive_h 3294 00000CD3 E8F10C call print_msg 3295 3296 00000CD6 BE[D44C] mov si, msg_logical_drive_error 3297 00000CD9 E8EB0C call print_msg 3298 00000CDC EBC6 jmp short B_06 3299 3300 ; mov si, msg_use_entire_ep_space 3301 ; jmp short B_12 3302 3303 B_08: 3304 00000CDE BE[F847] mov si, msg_create_nondos_partition_h 3305 B_09: 3306 00000CE1 E8E30C call print_msg 3307 B_10: 3308 ; 15/02/2019 3309 ;cmp byte [newdisk], 0 3310 ;ja short B_11 3311 3312 00000CE4 803E[E66C]00 cmp byte [pcount], 0 ; (valid) partition count 3313 00000CE9 7605 jna short B_11 3314 3315 00000CEB BE[2D4B] mov si, msg_use_all_space 3316 00000CEE EB03 jmp short B_12 3317 B_11: 3318 00000CF0 BE[064B] mov si, msg_use_whole_disk ; partition size: whole disk 3319 B_12: 3320 00000CF3 E8D10C call print_msg 3321 B_13: 3322 00000CF6 30E4 xor ah, ah 3323 00000CF8 CD16 int 16h 3324 3325 00000CFA 3C1B cmp al, 27 ; ESCAPE key 3326 ;;je _crlf_exit 3327 00000CFC 0F84D3F6 je A_42 ; 25/02/2019 3328 00000D00 24DF and al, 0DFh 3329 00000D02 3C4E cmp al, 'N' 3330 00000D04 740D je short B_14 ;02/03/2019 3331 00000D06 3C59 cmp al, 'Y' 3332 00000D08 75EC jne short B_13 3333 3334 00000D0A FE06[E469] inc byte [wholedisk] 3335 3336 ; 02/03/2019 3337 00000D0E BE[AE59] mov si, _msg_YES 3338 ;call print_msg 3339 00000D11 EB03 jmp short B_15 3340 B_14: 3341 00000D13 BE[B459] mov si, _msg_NO 3342 B_15: ; 06/03/2019 3343 00000D16 E8AE0C call print_msg 3344 3345 ; 15/02/2019 3346 00000D19 29DB sub bx, bx 3347 ;cmp byte [newdisk], bl ; 0 3348 ;ja short B_16 ; 23/02/2019 3349 ; 19/10/2020 3350 ;cmp byte [pcount], 0 3351 ; 03/11/2020 3352 00000D1B 381E[E66C] cmp byte [pcount], bl ; 0 3353 00000D1F 7608 jna short B_16 ; [pcount] = 0 (newdisk, empty pt) 3354 00000D21 381E[E469] cmp byte [wholedisk], bl ; 0 3355 00000D25 0F87FE00 ja B_27 ; 23/02/2019 3356 B_16: 3357 ; 08/02/2019 3358 ;;sub bx, bx 3359 ;mov ax, [total_sectors] 3360 ;mov dx, [total_sectors+2] 3361 ;sub ax, [sectors] 3362 ;sbb dx, bx ; sbb dx, 0 3363 ; 3364 ;mov [pp_Sectors], ax ; = [total_sectors] - [sectors] 3365 ;mov [pp_Sectors+2], dx ; = [total_sectors+2] - carry bit 3366 ; 21/03/2021 3367 00000D29 66A1[4A65] mov eax, [total_sectors] 3368 00000D2D 660FB716[BA3C] movzx edx, word [sectors] 3369 00000D33 6629D0 sub eax, edx 3370 00000D36 66A3[E069] mov [pp_Sectors], eax ; = [total_sectors] - [sectors] 3371 B_17: 3372 00000D3A 381E[E469] cmp byte [wholedisk], bl ; 0 3373 00000D3E 0F87E900 ja B_28 ; 09/02/2019 3374 B_18: 3375 ; clear screen 3376 00000D42 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 3377 00000D45 CD10 int 10h 3378 3379 ; 04/11/2020 3380 00000D47 803E[E569]01 cmp byte [pp_type], 1 ; primary dos partition ? 3381 00000D4C 7405 je short B_61 3382 ; "Create Partition" 3383 00000D4E BE[6E42] mov si, msg_create_partition_h 3384 00000D51 EB03 jmp short B_62 3385 B_61: 3386 ; "Create DOS partition" 3387 00000D53 BE[1945] mov si, msg_create_dos_partition_h ; header 3388 B_62: 3389 00000D56 E86E0C call print_msg 3390 00000D59 BE[AA49] mov si, msg_create_trdos_partition_s ; size options 3391 00000D5C E8680C call print_msg 3392 B_19: 3393 00000D5F 30E4 xor ah, ah 3394 00000D61 CD16 int 16h 3395 3396 ; 24/02/2019 3397 00000D63 3C1B cmp al, 27 ; ESCAPE key 3398 00000D65 0F846AF6 je A_42 ; Cancel 3399 3400 00000D69 3C20 cmp al, 32 ; SPACE key 3401 00000D6B 751E jne short B_21 3402 3403 ; Entire space 3404 ;mov ax, [pp_Sectors] 3405 ;mov dx, [pp_Sectors+2] 3406 ; 15/03/2021 3407 00000D6D 66A1[E069] mov eax, [pp_Sectors] 3408 3409 00000D71 C606[E469]01 mov byte [wholedisk], 1 ; 09/02/2019 3410 00000D76 EB55 jmp short B_23 3411 3412 B_60: ; 31/10/2020 3413 00000D78 75C8 jnz short B_18 ; ESCape (return to options menu) 3414 ; partition size input is ZERO ! 3415 B_20: 3416 ; ZERO partition size message 3417 00000D7A BE[C157] mov si, msg_zero_partition_size 3418 00000D7D E8470C call print_msg 3419 3420 00000D80 30E4 xor ah, ah 3421 00000D82 CD16 int 16h 3422 00000D84 3C1B cmp al, 27 ; ESCAPE key 3423 00000D86 75BA jne short B_18 ; Retry 3424 3425 ; 19/10/2020 3426 00000D88 E9E4F9 jmp _crlf_exit ; exit 3427 3428 B_21: 3429 00000D8B C606[F269]25 mov byte [pSize_unit], '%' 3430 00000D90 3C25 cmp al, '%' 3431 00000D92 7422 je short B_22 3432 00000D94 C606[F269]53 mov byte [pSize_unit], 'S' 3433 00000D99 3C0D cmp al, 13 ; 0Dh, Carriage Return key 3434 00000D9B 7419 je short B_22 3435 00000D9D 24DF and al, 0DFh 3436 00000D9F 3C53 cmp al, 'S' 3437 00000DA1 7413 je short B_22 3438 00000DA3 A2[F269] mov [pSize_unit], al 3439 00000DA6 3C4B cmp al, 'K' 3440 00000DA8 740C je short B_22 3441 00000DAA 3C4D cmp al, 'M' 3442 00000DAC 7408 je short B_22 3443 00000DAE 3C47 cmp al, 'G' 3444 00000DB0 7404 je short B_22 3445 00000DB2 3C43 cmp al, 'C' 3446 00000DB4 75A9 jne short B_19 3447 B_22: 3448 00000DB6 C606[2761]73 mov byte [msg_sectors_crlf_s], 's' ; " sectors" 3449 3450 00000DBB E8770E call partition_size_input 3451 ;jc _crlf_exit ; exit if partition size input is 0 3452 ;jc short B_20 3453 ; 29/10/2020 3454 ;jnc short B_60 3455 ;jz short B_20 ; partition size input is ZERO ! 3456 ;jmp short B_18 ; ESCape (return to options menu) 3457 ; 31/10/2020 3458 00000DBE 72B8 jc short B_60 ; ESC or zero partition size 3459 ;B_60: 3460 ; 13/03/2021 3461 ;and bx, bx ; bx_dx_ax = partition size 3462 ;;jnz short B_29 3463 ;; 23/02/2019 3464 ;jnz short B_24 ; invalid! (use maximum available sectors) 3465 ;; 08/02/2019 3466 ;or dx, dx 3467 ;jnz short B_23 ; proper size (for now) 3468 3469 ; 13/03/2021 3470 ;or edx, edx 3471 ;jnz short B_24 ; invalid! (use maximum available sectors) 3472 3473 ;mov bx, [min_sectors] ; minimum sectors 3474 ;cmp bx, ax 3475 ;jna short B_23 ; proper size (for now) 3476 ; 13/03/2021 3477 00000DC0 668B16[086A] mov edx, [min_sectors] 3478 00000DC5 6639D0 cmp eax, edx 3479 00000DC8 7303 jnb short B_23 ; proper size (for now) 3480 3481 ; invalid! (use minimum sectors or sectors per cylinder) 3482 ;mov ax, bx 3483 ; 13/03/2021 3484 00000DCA 6689D0 mov eax, edx 3485 B_23: 3486 ; 09/02/2019 3487 ; save dx,ax 3488 ;mov [ppn_Sectors+2], dx 3489 ;mov [ppn_Sectors], ax 3490 ; 13/03/2021 3491 00000DCD 66A3[146A] mov [ppn_Sectors], eax 3492 3493 ; write partition size 3494 ;push dx 3495 ;push ax 3496 ; 06/11/2020 3497 00000DD1 BE[FF69] mov si, msg_partition_sectors + 10 ; max. 11 digits 3498 00000DD4 E8A90C call bin_to_decimal 3499 ; ds:si = beginning of decimal number text 3500 00000DD7 E8ED0B call print_msg 3501 00000DDA BE[2061] mov si, msg_sectors_crlf 3502 00000DDD E8E70B call print_msg 3503 ;pop ax 3504 ;pop dx 3505 3506 00000DE0 803E[E469]00 cmp byte [wholedisk], 0 3507 00000DE5 7748 ja short B_29 ; 09/02/2019 3508 3509 ; 15/03/2021 3510 ;sub eax, eax ; no need to clear hw of eax here 3511 3512 ; restore ax,dx 3513 ;mov ax, [ppn_Sectors] 3514 ;mov dx, [ppn_Sectors+2] 3515 3516 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3517 ; select whole disk 3518 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3519 3520 ; 15/03/2021 3521 00000DE7 66A1[146A] mov eax, [ppn_Sectors] 3522 3523 ; select whole disk 3524 ; if partition size > disk size 3525 ;cmp dx, [pp_Sectors+2] 3526 ;ja short B_24 3527 ;jb short B_29 3528 ;cmp ax, [pp_Sectors] 3529 ;jna short B_29 3530 ; 15/03/2021 3531 00000DEB 663B06[E069] cmp eax, [pp_Sectors] 3532 00000DF0 763D jna short B_29 3533 B_24: 3534 ;cmp byte [newdisk], 0 3535 ;jna short B_30 3536 ; 19/10/2020 3537 00000DF2 803E[E66C]00 cmp byte [pcount], 0 3538 00000DF7 775B ja short B_30 3539 3540 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3541 ; "use whole disk or go to back" question 3542 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3543 3544 00000DF9 BE[2B4C] mov si, msg_partition_size_overs 3545 B_25: 3546 00000DFC E8C80B call print_msg 3547 B_26: 3548 00000DFF 30E4 xor ah, ah 3549 00000E01 CD16 int 16h 3550 3551 00000E03 3C1B cmp al, 27 ; ESCAPE key 3552 ;je B_01 3553 00000E05 0F8439FF je B_18 ; 09/02/2019 3554 00000E09 3C0D cmp al, 13 ; ENTER (Carriage Return) key 3555 00000E0B 75F2 jne short B_26 3556 3557 00000E0D FE06[E469] inc byte [wholedisk] 3558 3559 ; 24/02/2019 3560 ;cmp byte [newdisk], 0 3561 ;ja short B_27 3562 00000E11 803E[E66C]00 cmp byte [pcount], 0 ; (valid) partition count 3563 00000E16 760F jna short B_27 ; no 3564 3565 00000E18 8B1E[B06D] mov bx, [c_fspc_offset] 3566 ;mov ax, [free_space.sectors_unused+bx] 3567 ;mov dx, [free_space.sectors_unused+bx+2] 3568 ;mov [pp_Sectors], ax 3569 ;mov [pp_Sectors+2], dx 3570 ; 15/03/2021 3571 00000E1C 668B87[4E6D] mov eax, [free_space.sectors_unused+bx] 3572 00000E21 66A3[E069] mov [pp_Sectors], eax 3573 3574 00000E25 EB04 jmp short B_28 3575 B_27: 3576 ; 09/02/2019 3577 ;mov dx, [pp_Sectors+2] 3578 ;mov ax, [pp_Sectors] 3579 ; 15/03/2021 3580 00000E27 66A1[E069] mov eax, [pp_Sectors] 3581 B_28: 3582 ;mov [ppn_Sectors+2], dx 3583 ;mov [ppn_Sectors], ax 3584 ; 15/03/2021 3585 00000E2B 66A3[146A] mov [ppn_Sectors], eax 3586 B_29: 3587 00000E2F 803E[E569]05 cmp byte [pp_type], 5 3588 00000E34 0F852C01 jne B_51 3589 3590 00000E38 803E[E76C]00 cmp byte [ppcount], 0 ; primary partition count 3591 00000E3D 0F87C700 ja B_45 3592 3593 00000E41 BE[954C] mov si, msg_ext_partition_error 3594 00000E44 E8800B call print_msg 3595 00000E47 BE[0E4C] mov si, msg_any_key_to_retry 3596 00000E4A E87A0B call print_msg 3597 3598 ; 09/02/2019 3599 00000E4D 30E4 xor ah, ah 3600 00000E4F CD16 int 16h 3601 3602 ;jmp B_01 3603 00000E51 E951F9 jmp cpi_2 3604 3605 B_30: 3606 ; clear screen 3607 00000E54 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 3608 00000E57 CD10 int 10h 3609 3610 00000E59 BE[1945] mov si, msg_create_dos_partition_h ; header 3611 00000E5C E8680B call print_msg 3612 3613 00000E5F BE[CD5A] mov si, msg_partition_size_limit 3614 00000E62 E8620B call print_msg 3615 3616 00000E65 8B1E[B06D] mov bx, [c_fspc_offset] 3617 3618 00000E69 803E[F269]53 cmp byte [pSize_unit], 'S' 3619 00000E6E 7415 je short B_31 3620 00000E70 803E[F269]4B cmp byte [pSize_unit], 'K' 3621 00000E75 740E je short B_31 3622 3623 00000E77 803E[F269]25 cmp byte [pSize_unit], '%' 3624 00000E7C 746D je short B_41 3625 3626 00000E7E 803E[F269]43 cmp byte [pSize_unit], 'C' 3627 00000E83 747D je B_44 3628 B_31: 3629 ; 'S', 'K' 3630 00000E85 81C3[4E6D] add bx, free_space.sectors_unused 3631 ;mov ax, [bx] 3632 ;mov dx, [bx+2] 3633 B_42: 3634 ; 15/03/2021 3635 00000E89 668B07 mov eax, [bx] 3636 00000E8C 6631D2 xor edx, edx 3637 00000E8F 6631C9 xor ecx, ecx 3638 00000E92 B10A mov cl, 10 3639 3640 ;mov cx, 10 3641 00000E94 89E5 mov bp, sp 3642 ;B_32: 3643 ;call div32 3644 ;push bx 3645 ;or dx, dx 3646 ;jnz short B_32 3647 ;cmp ax, 9 3648 ;ja short B_32 3649 B_32: 3650 ; 15/03/2021 3651 00000E96 66F7F1 div ecx 3652 00000E99 52 push dx 3653 00000E9A 6683F809 cmp eax, 9 3654 00000E9E 7604 jna short B_33 3655 00000EA0 28D2 sub dl, dl 3656 ; edx = 0 3657 00000EA2 EBF2 jmp short B_32 3658 B_33: 3659 00000EA4 BB0700 mov bx, 07h 3660 ;or ax, ax 3661 ;jnz short B_35 3662 ; 15/03/2021 3663 00000EA7 08C0 or al, al 3664 00000EA9 7501 jnz short B_35 3665 B_34: 3666 00000EAB 58 pop ax 3667 B_35: 3668 00000EAC 0430 add al, '0' 3669 B_36: 3670 00000EAE B40E mov ah, 0Eh 3671 ;mov bx, 07h 3672 00000EB0 CD10 int 10h ; write character (as tty) 3673 3674 00000EB2 39EC cmp sp, bp 3675 00000EB4 72F5 jb short B_34 3676 3677 00000EB6 803E[F269]53 cmp byte [pSize_unit], 'S' 3678 00000EBB 7422 je short B_38 3679 00000EBD 803E[F269]4B cmp byte [pSize_unit], 'K' 3680 00000EC2 741B je short B_38 3681 3682 00000EC4 803E[F269]25 cmp byte [pSize_unit], '%' 3683 00000EC9 7508 jne short B_37 3684 3685 ; 24/02/2019 3686 00000ECB 3C25 cmp al, '%' 3687 00000ECD 7416 je short B_40 3688 00000ECF B025 mov al, '%' 3689 00000ED1 EBDB jmp short B_36 3690 B_37: 3691 00000ED3 803E[F269]43 cmp byte [pSize_unit], 'C' 3692 00000ED8 7505 jne short B_38 3693 3694 00000EDA BE[695B] mov si, msg_cylinders 3695 00000EDD EB03 jmp short B_39 3696 B_38: 3697 00000EDF BE[745B] mov si, msg_sectors 3698 B_39: 3699 00000EE2 E8E20A call print_msg 3700 B_40: 3701 00000EE5 BE[1A5B] mov si, msg_partition_size_limit_r 3702 ;call print_msg 3703 3704 00000EE8 E911FF jmp B_25 3705 3706 B_41: 3707 ; '%' 3708 00000EEB 81C3[566D] add bx, free_space.percent_unused 3709 00000EEF 8B07 mov ax, [bx] 3710 ;B_42: 3711 00000EF1 89E5 mov bp, sp 3712 00000EF3 B90A00 mov cx, 10 3713 B_43: 3714 00000EF6 31D2 xor dx, dx 3715 00000EF8 F7F1 div cx 3716 00000EFA 52 push dx 3717 00000EFB 83F809 cmp ax, 9 3718 00000EFE 77F6 ja short B_43 3719 00000F00 EBA2 jmp short B_33 3720 B_44: 3721 ; 'C' 3722 00000F02 81C3[426D] add bx, free_space.space 3723 ;mov ax, [bx] 3724 ;jmp short B_42 3725 ; 15/03/2021 3726 00000F06 EB81 jmp short B_42 3727 3728 B_45: 3729 ; 23/02/2019 3730 00000F08 8B1E[B06D] mov bx, [c_fspc_offset] 3731 ;mov ax, [bx+free_space.start] 3732 ; 15/03/2021 3733 00000F0C 668B87[466D] mov eax, [bx+free_space.start] 3734 3735 ; set free space start cylinder to 1 if it is 0 3736 ;or ax, ax 3737 ;jnz short B_46 3738 ; 15/03/2021 3739 00000F11 6609C0 or eax, eax 3740 00000F14 7510 jnz short B_46 3741 3742 00000F16 B005 mov al, 5 ; Get free space for extended partition 3743 00000F18 E8F513 call find_part_free_space 3744 3745 00000F1B 891E[B06D] mov [c_fspc_offset], bx 3746 3747 ; 19/10/2020 3748 ;and cx, cx 3749 ; 15/03/2021 3750 00000F1F 6621C9 and ecx, ecx 3751 00000F22 0F8468F5 jz cp_3 ; there is not free space on disk 3752 B_46: 3753 ; 15/03/2021 3754 ;sub eax, eax ; no need to clear hw of eax here 3755 3756 ; 24/02/2019 3757 00000F26 E81100 call partition_size_fixup_x 3758 00000F29 0F8227FF jc B_30 3759 3760 ; 16/02/2019 3761 00000F2D E859FB call create_extended_partition 3762 ; must be called after 'find_part_free_space'. 3763 ; 24/02/2019 3764 00000F30 E8D80F call show_selected_partition 3765 00000F33 E9AE00 jmp C_02 3766 3767 partition_size_fixup: 3768 ; 24/02/2019 3769 00000F36 8B1E[B06D] mov bx, [c_fspc_offset] 3770 partition_size_fixup_x: 3771 ; 19/10/2020 3772 3773 ;cmp byte [newdisk], 0 3774 ;ja short B_50 3775 3776 00000F3A 803E[E66C]00 cmp byte [pcount], 0 ; (valid) partition count 3777 00000F3F 7622 jna short B_50 3778 3779 00000F41 81C3[4E6D] add bx, free_space.sectors_unused 3780 ;mov ax, [bx] 3781 ;mov dx, [bx+2] 3782 ; 15/03/2021 3783 00000F45 668B07 mov eax, [bx] 3784 3785 ;cmp dx, [ppn_Sectors+2] 3786 ;jb short B_50 ; 24/02/2019 3787 ;ja short B_47 3788 ;cmp ax, [ppn_Sectors] 3789 ;jb short B_50 ; 24/02/2019 3790 ;je short B_49 3791 ; 15/03/2021 3792 00000F48 663B06[146A] cmp eax, [ppn_Sectors] 3793 00000F4D 7214 jb short B_50 3794 00000F4F 740E je short B_49 3795 B_47: 3796 ; 19/02/2019 3797 ;mov ax, [ppn_Sectors] 3798 B_48: 3799 ;mov dx, [ppn_Sectors+2] 3800 ; 15/03/2021 3801 00000F51 66A1[146A] mov eax, [ppn_Sectors] 3802 3803 ; 18/02/2019 3804 3805 ; check for best fit 3806 ; (leave max. available space to next time if 3807 ; another space/gap fits to partition size request) 3808 3809 00000F55 E8C715 call find_enough_free_sectors 3810 ; CX = Free space index (0 to 4) 3811 ; DX:AX = First available space which fits to request 3812 ; 15/03/2021 3813 ; eax = First available space which fits to request 3814 3815 ;mov bx, cx 3816 ;shl bl, 4 ; * 16 ; * Free space structure size 3817 ;mov [c_fspc_offset], bx 3818 3819 ; 22/02/2019 3820 00000F58 C0E104 shl cl, 4 3821 00000F5B 890E[B06D] mov [c_fspc_offset], cx 3822 3823 ;add bx, free_space.sectors_unused 3824 ;mov ax, [bx] 3825 ;mov dx, [bx+2] 3826 B_49: 3827 ; Save max. available space 3828 ;mov [pp_Sectors], ax 3829 ;mov [pp_Sectors+2], dx 3830 ; 15/03/2021 3831 00000F5F 66A3[E069] mov [pp_Sectors], eax 3832 B_50: 3833 00000F63 C3 retn 3834 B_51: 3835 ; 24/02/2019 3836 00000F64 E8CFFF call partition_size_fixup 3837 00000F67 0F82E9FE jc B_30 3838 3839 ; 16/02/2019 3840 ; Force cylinder boundary alignment except 3841 ; sectors ('S') and kilobytes ('K') as sizing unit. 3842 3843 00000F6B C606[B26D]59 mov byte [cylinder_boundary], 'Y' ; Default 3844 ; sizing unit is one of 3845 ; 'cylinders','megabytes','gigabytes' 3846 ; and boundary alignment is yes for them. 3847 00000F70 A0[F269] mov al, [pSize_unit] 3848 3849 ;cmp byte [pSize_unit], 'S' ; Sectors 3850 00000F73 3C53 cmp al, 'S' 3851 00000F75 7404 je short B_52 3852 3853 ;cmp byte [pSize_unit], 'K' ; Kilobytes 3854 00000F77 3C4B cmp al, 'K' 3855 00000F79 752F jne short B_56 3856 B_52: 3857 ; Sizing unit is one of 'sectors' and/or 'kilobytes' 3858 ; and bound aligment will be applied if the answer will be yes. 3859 3860 00000F7B BE[1D4D] mov si, msg_cylinder_boundary_set 3861 00000F7E E8460A call print_msg 3862 B_53: 3863 00000F81 30E4 xor ah, ah 3864 00000F83 CD16 int 16h 3865 ; Cylinder boundary adjusting 3866 00000F85 3C0D cmp al, 13 ; ENTER key 3867 00000F87 74F2 je short B_52 3868 00000F89 3C1B cmp al, 27 ; ESCAPE key 3869 00000F8B 741A je short B_55 ; Align end of the partition only 3870 ; if start of the partition is aligned 3871 ; or it starts at cyl 0, head 1, sect 17 or 63. 3872 ; (End of the partition will be extended to 3873 ; end sector of it's last cylinder if the size 3874 ; will not over [pp_Sectors] value.) 3875 00000F8D 24DF and al, 0DFh 3876 3877 ; 22/02/2019 3878 00000F8F 3C59 cmp al, 'Y' 3879 00000F91 7508 jne short B_54 3880 3881 00000F93 BE[AE59] mov si, _msg_YES 3882 00000F96 E82E0A call print_msg 3883 3884 ;mov al, 'Y' 3885 ;jmp short B_55 3886 00000F99 EB0F jmp short B_56 3887 B_54: 3888 00000F9B 3C4E cmp al, 'N' 3889 00000F9D 75E2 jne short B_53 3890 3891 00000F9F BE[B459] mov si, _msg_NO 3892 00000FA2 E8220A call print_msg 3893 3894 00000FA5 B04E mov al, 'N' 3895 ; do not align partition to cylinder boundary 3896 B_55: 3897 00000FA7 A2[B26D] mov [cylinder_boundary], al 3898 B_56: 3899 00000FAA E84CF8 call create_primary_partition 3900 3901 ; 18/02/2019 3902 ;cmp byte [newdisk], 0 3903 ;jna short B_57 3904 3905 ; 19/10/2020 3906 00000FAD 803E[E66C]00 cmp byte [pcount], 0 3907 00000FB2 770D ja short B_57 3908 3909 ;xor ax, ax ; 0 3910 ;xor dx, dx ; 0 3911 ; 09/03/2021 3912 00000FB4 6631C0 xor eax, eax 3913 3914 ; DX_AX = Masterboot Sector = 0 3915 3916 00000FB7 BB[F052] mov bx, MasterBootBuff 3917 3918 ; ES:BX = Sector Buffer 3919 ; 09/03/2021 3920 ; EAX = Masterboot Sector = 0 3921 3922 00000FBA E8680A call write_hd_sector 3923 00000FBD 0F8298F7 jc print_error_code ; 18/10/2020 3924 B_57: 3925 ; DS:SI = Partition Table Entry address 3926 ; 25/02/2019 3927 00000FC1 8936[DC6D] mov [pte_address], si ; save PTE address 3928 00000FC5 E8430F call show_selected_partition 3929 3930 ;jmp C_01 3931 3932 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3933 ; format question 3934 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3935 3936 C_01: 3937 ;mov si, CRLF 3938 ;call print_msg 3939 3940 00000FC8 C606[016A]01 mov byte [format_q], 1 3941 3942 00000FCD A0[E569] mov al, [pp_type] 3943 00000FD0 3C01 cmp al, 1 ; FAT12 (CHS) 3944 00000FD2 741D je short C_03 3945 00000FD4 3C04 cmp al, 4 ; FAT16 CHS 3946 00000FD6 7419 je short C_03 3947 00000FD8 3C06 cmp al, 6 ; FAT16 BIG CHS 3948 00000FDA 7415 je short C_03 3949 00000FDC 3C0B cmp al, 0Bh ; FAT32 CHS 3950 00000FDE 7411 je short C_03 3951 00000FE0 3CA1 cmp al, 0A1h ; SINGLIX FS1 3952 00000FE2 740D je short C_03 3953 3954 ;cmp al, 71h 3955 ;je short C_03 ; RETRO UNIX 386 3956 3957 ;dec byte [format_q] ; 0 3958 C_02: 3959 00000FE4 C606[016A]00 mov byte [format_q], 0 ; 24/02/2019 3960 3961 ; NON-DOS partition! 3962 ; Ask for editing PT or exit (continue without formatting) 3963 00000FE9 BE[A350] mov si, msg_edit_or_exit 3964 00000FEC E8D809 call print_msg 3965 00000FEF EB06 jmp short C_04 3966 C_03: 3967 ; Ask for formatting, editing PT or exit 3968 00000FF1 BE[3450] mov si, msg_format_stage 3969 00000FF4 E8D009 call print_msg 3970 C_04: 3971 00000FF7 BE[7450] mov si, msg_partition_edit 3972 00000FFA E8CA09 call print_msg 3973 C_05: 3974 00000FFD 28E4 sub ah, ah 3975 00000FFF CD16 int 16h 3976 3977 00001001 3C0D cmp al, 13 3978 00001003 7434 je short C_08 3979 3980 ;; 07/03/2019 3981 00001005 3C20 cmp al, 20h ; SPACE 3982 ;je A_21 ; edit partition table option is selected 3983 00001007 7503 jne short C_06 3984 ; 19/10/2020 3985 00001009 E9F1F1 jmp A_21 3986 C_06: 3987 0000100C 3C1B cmp al, 27 ; ESCAPE 3988 0000100E 75ED jne short C_05 3989 3990 ; 19/010/2020 3991 00001010 E962F7 jmp _exit 3992 3993 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3994 ; save MBR then exit 3995 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3996 3997 save_mbr_exit: 3998 ; 24/02/2019 3999 00001013 E8D710 call init_partition_table 4000 ; 12/03/2021 4001 ;xor eax, eax 4002 00001016 E8A715 call display_partition_table 4003 4004 00001019 BE[7452] mov si, CRLF 4005 0000101C E8A809 call print_msg 4006 4007 0000101F BE[2851] mov si, msg_writing_mbr 4008 00001022 E8A209 call print_msg 4009 4010 ;xor ax, ax ; 0 4011 ;xor dx, dx ; 0 4012 ; 09/03/2021 4013 00001025 6631C0 xor eax, eax 4014 4015 ; DX_AX = Masterboot Sector = 0 4016 4017 00001028 BB[F052] mov bx, MasterBootBuff 4018 4019 ; ES:BX = Sector Buffer 4020 ; 09/03/2021 4021 ; EAX = Masterboot Sector = 0 4022 4023 0000102B E8F709 call write_hd_sector 4024 0000102E 7303 jnc short C_07 4025 00001030 E926F7 jmp print_error_code ; 18/10/2020 4026 4027 C_07: 4028 00001033 BE[7052] mov si, Msg_OK 4029 ;call print_msg 4030 ; 19/10/2020 4031 ;jmp _exit 4032 00001036 E939F7 jmp _p_exit 4033 4034 C_08: 4035 00001039 803E[016A]01 cmp byte [format_q], 1 4036 0000103E 72D3 jb short save_mbr_exit 4037 4038 ; 25/02/2019 4039 ; Write MBR without writing message 4040 4041 ; NOTE: This may be second time of MBR writing... 4042 ; but, if partition table is modified, 4043 ; we need to write MBR to disk, here. 4044 ; 4045 ; (Otherwise.. the last created partition would not be recorded.) 4046 4047 ;xor ax, ax ; 0 4048 ;xor dx, dx ; 0 4049 ; 09/03/2021 4050 00001040 6631C0 xor eax, eax 4051 4052 ; DX_AX = Masterboot Sector = 0 4053 4054 00001043 BB[F052] mov bx, MasterBootBuff 4055 4056 ; ES:BX = Sector Buffer 4057 ; 09/03/2021 4058 ; EAX = Masterboot Sector = 0 4059 4060 00001046 E8DC09 call write_hd_sector 4061 00001049 0F820CF7 jc print_error_code ; 18/10/2020 4062 4063 ;; clear screen 4064 ;mov ax, 3 ; set video mode to 03h (80x25 text) 4065 ;int 10h 4066 4067 ; 25/02/2019 4068 0000104D 8B36[DC6D] mov si, [pte_address] 4069 4070 ; 18/02/2019 4071 00001051 E8B70E call show_selected_partition 4072 4073 00001054 A0[5B50] mov al, [partition_num_chr] 4074 00001057 A2[1B51] mov [partition_num_txt], al 4075 4076 0000105A BE[F950] mov si, msg_format_question 4077 0000105D E86709 call print_msg 4078 C_09: 4079 00001060 30E4 xor ah, ah 4080 00001062 CD16 int 16h 4081 4082 00001064 3C1B cmp al, 1Bh ; ESCAPE 4083 00001066 74A4 je short C_06 4084 4085 00001068 24DF and al, 0DFh ; capitalization 4086 0000106A 3C59 cmp al, 'Y' 4087 0000106C 740C je short C_10 4088 0000106E 3C4E cmp al, 'N' 4089 00001070 75EE jne short C_09 4090 00001072 BE[B459] mov si, _msg_NO 4091 00001075 E84F09 call print_msg 4092 ;jmp short C_06 4093 ; 24/02/2019 4094 00001078 EB99 jmp short save_mbr_exit 4095 C_10: 4096 0000107A BE[AE59] mov si, _msg_YES 4097 0000107D E84709 call print_msg 4098 4099 ; [pp_StartSector] = partition's start sector 4100 ; [pp_Sectors] = partition size including start & end sector 4101 ; [partition_num_chr] = partition number + '0' 4102 ; [pp_type] = partition type (for TRDOS 386 boot sector) 4103 4104 00001080 8926[5465] mov [old_sp], sp 4105 4106 ; 16/03/2021 4107 00001084 6631D2 xor edx, edx ; (this may not be necessary) 4108 00001087 6631DB xor ebx, ebx ; (this may not be necessary) 4109 0000108A 6631C9 xor ecx, ecx ; (this may not be necessary) 4110 4111 0000108D 8A16[E569] mov dl, [pp_type] 4112 ; DL = partition type (file system ID) 4113 ;dec dl 4114 ;jz FAT12_hd_format 4115 00001091 80FA01 cmp dl, 1 ; 14/09/2020 (BugFix) 4116 00001094 0F863405 jna FAT12_hd_format 4117 ;cmp dl, 4 4118 ;je FAT16_hd_format 4119 ;cmp dl, 6 4120 ;je FAT16_hd_format 4121 00001098 80FA0B cmp dl, 0Bh 4122 0000109B 0F826B03 jb FAT16_hd_format 4123 ;je short FAT32_hd_format 4124 ;cmp dl, 0Ch ; 14/09/2020 4125 0000109F 0F879F06 ja SINGLIX_hd_format 4126 4127 ;cmp dl, 0A1h 4128 ;je SINGLIX_hd_format 4129 ;jb RUNIX386_hd_format ; dl = 071h 4130 4131 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4132 ; FAT32 FORMATTING 4133 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4134 4135 ; 16/03/2021 (fdisk4.s) 4136 ; 08/02/2019 (Modified for -only- FAT32 CHS partitions) 4137 FAT32_hd_format: 4138 ; 29/01/2026 4139 000010A3 B80C00 mov ax, 000Ch ; db 0Ch, 00h ; 'or al, 0' 4140 000010A6 38C2 cmp dl, al ; 0Ch 4141 000010A8 7403 je short FAT32_lba_format 4142 000010AA B80BC0 mov ax, 0C00Bh ; db 0Bh, 0C0h ; 'or ax, ax' 4143 FAT32_lba_format: 4144 ; Put TRDOS 386 FAT32 partition magic word 4145 ; at offset 5Ah, in TRDOS386 FAT32 boot sector 0. 4146 000010AD BD[A730] mov bp, TRDOS_FAT32_hd_bs 4147 000010B0 8D7E03 lea di, [bp+3] 4148 000010B3 BE[2C61] mov si, bs_oem_name 4149 000010B6 B90400 mov cx, 4 4150 000010B9 F3A5 rep movsw 4151 ; 29/01/2026 4152 000010BB 89465A mov [bp+5Ah], ax ; [loc_5A] 4153 ;mov word [bp+5Ah], 0C00Bh ; 08/02/2019 4154 000010BE A1[BA3C] mov ax, [sectors] 4155 000010C1 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4156 000010C4 A1[BC3C] mov ax, [heads] 4157 000010C7 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4158 ; 16/03/2021 4159 ;mov ax, [pp_StartSector] 4160 ;mov [bp+1Ch], ax ; [BPB_HiddSec] 4161 ;mov ax, [pp_StartSector+2] 4162 ;mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4163 000010CA 66A1[DC69] mov eax, [pp_StartSector] 4164 000010CE 6689461C mov [bp+1Ch], eax ; [BPB_HiddSec] 4165 ;;mov ax, [pp_Sectors] 4166 ;mov ax, [ppn_Sectors] ; 16/02/2019 4167 ;mov [bp+20h], ax ; [BPB_TotSec32] 4168 ;;mov dx, [pp_Sectors+2] 4169 ;mov dx, [ppn_Sectors+2] ; 16/02/2019 4170 ;mov [bp+22h], dx ; [BPB_TotSec32+2] 4171 000010D2 66A1[146A] mov eax, [ppn_Sectors] 4172 000010D6 66894620 mov [bp+20h], eax ; [BPB_TotSec32] 4173 4174 ; Sectors per cluster calculation 4175 ; (According to MS FAT32 FS specification.) 4176 000010DA B108 mov cl, 8 ; 8 sectors per cluster 4177 ;cmp dx, 8 ; >= 532480 sectors 4178 ;ja short FAT32_f_2 ; 8 sectors per cluster 4179 ;jb short FAT32_f_1 ; 1 sector per cluster 4180 ;cmp ax, 2000h ; dx_ax = (8*65536)+8192 4181 ;jnb short FAT32_f_2 ; 12/09/2020 (BugFix) 4182 ; 16/03/2021 4183 000010DC 663D00200800 cmp eax, 532480 4184 000010E2 7302 jnb short FAT32_f_2 4185 FAT32_f_1: 4186 000010E4 B101 mov cl, 1 ; 1 sector per cluster 4187 FAT32_f_2: 4188 000010E6 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 4189 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 4190 ;mov word [bp+0Eh], 32 ; [BPB_RsvdSecCnt] 4191 4192 ; Calculating FAT size in sectors 4193 ; (According to MS FAT32 FS Specification, 2000) 4194 4195 ; DX_AX = partition (volume) size in sectors 4196 ;sub ax, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 4197 ;sbb dx, 0 4198 ; ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 4199 ; ; RootDirsectors) 4200 ; ; RootDirSectors = 0 (for FAT32 FS) 4201 ; 16/03/2021 4202 ;xor edx, edx 4203 000010E9 8B560E mov dx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 2 bytes 4204 000010EC 6629D0 sub eax, edx ; sub eax, 32 4205 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 4206 ; RootDirsectors) 4207 ; RootDirSectors = 0 (for FAT32 FS) 4208 4209 ;mov bx, cx ; ch = 0 4210 ;shl bx, 8 ; * 256 4211 ;mov cl, [bp+10h] ; [BPB_NumFATs] 4212 ;add bx, cx 4213 ; ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 4214 ;shr bx, 1 4215 ; ; TmpVal2 = TmpVal2/2 4216 ;mov cx, bx 4217 ;dec bx ; TmpVal2-1 4218 ;add ax, bx 4219 ;adc dx, 0 4220 ;call div32 4221 ; ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 4222 ; DX_AX = FAT size in sectors 4223 ; 16/03/2021 4224 000010EF 88CE mov dh, cl ; * 256 4225 000010F1 8A5610 mov dl, [bp+10h] ; [BPB_NumFATs] 4226 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 4227 000010F4 D1EA shr dx, 1 4228 ; TmpVal2 = TmpVal2/2 4229 000010F6 6689D1 mov ecx, edx 4230 000010F9 4A dec dx ; TmpVal2-1 4231 000010FA 6601D0 add eax, edx 4232 ;xor edx, edx 4233 000010FD 31D2 xor dx, dx 4234 000010FF 66F7F1 div ecx 4235 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 4236 ; EAX = FAT size in sectors 4237 4238 ;mov [bp+24h], ax ; [BPB_FATSz32] 4239 ;mov [bp+26h], dx ; [BPB_FATSz32+2] 4240 ;; * 2 4241 ;mov bx, dx 4242 ;add ax, ax 4243 ;adc bx, dx 4244 ;; BX_AX = [BPB_NumFATs] * [BPB_FATSz32] 4245 ;mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 4246 ;add cx, ax 4247 ;adc bx, 0 4248 ;; BX_CX = [BPB_RsvdSecCnt]+[BPB_NumFATs]*[BPB_FATSz32] 4249 ;mov ax, [bp+20h] ; [BPB_TotSec32] 4250 ;mov dx, [bp+22h] ; [BPB_TotSec32+2] 4251 ;sub ax, cx 4252 ;sbb dx, bx 4253 ;mov [data_start], cx 4254 ;mov [data_start+2], bx 4255 ;; DX_AX = Data sectors 4256 ;mov [data_sectors], ax 4257 ;mov [data_sectors+2], dx 4258 ;mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4259 ;xor ch, ch 4260 ;call div32 ; DX_AX/CX 4261 ;; DX_AX = Count of clusters (rounded down) 4262 ;mov [cluster_count], ax 4263 ;mov [cluster_count+2], dx 4264 ; 16/03/2021 4265 00001102 66894624 mov [bp+24h], eax ; [BPB_FATSz32] 4266 ; * 2 4267 00001106 66D1E0 shl eax, 1 4268 ;add eax, eax 4269 ;EAX = [BPB_NumFATs] * [BPB_FATSz32] ; 2 * FATsz 4270 00001109 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 4271 0000110C 6601C1 add ecx, eax 4272 ;ECX = [BPB_RsvdSecCnt]+[BPB_NumFATs]*[BPB_FATSz32] 4273 0000110F 668B4620 mov eax, [bp+20h] ; [BPB_TotSec32] 4274 00001113 6629C8 sub eax, ecx 4275 00001116 66890E[5667] mov [data_start], ecx 4276 ;EAX = Data sectors 4277 0000111B 66A3[5A67] mov [data_sectors], eax 4278 0000111F 660FB64E0D movzx ecx, byte [bp+0Dh] ; [BPB_SecPerClus] 4279 00001124 6629D2 sub edx, edx 4280 00001127 66F7F1 div ecx 4281 ;EAX = Count of clusters (rounded down) 4282 0000112A 66A3[5E67] mov [cluster_count], eax 4283 0000112E 30D2 xor dl, dl 4284 4285 00001130 8D7E47 lea di, [bp+71] ; [BS_VolLab] 4286 00001133 E84B01 call write_volume_name 4287 00001136 8D7643 lea si, [bp+67] ; [BS_VolID] 4288 00001139 E8A401 call write_volume_serial 4289 0000113C E8B802 call write_cluster_count 4290 4291 0000113F E82502 call write_formatting_msg 4292 00001142 B000 mov al, 0 4293 00001144 E88202 call write_format_percent_x 4294 4295 ;mov ax, [bp+1Ch] ; [BPB_HiddSec] 4296 ;mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 4297 ;add [data_start], ax 4298 ;adc [data_start+2], dx 4299 ; 16/03/2021 4300 00001147 668B461C mov eax, [bp+1Ch] ; [BPB_HiddSec] 4301 0000114B 660106[5667] add [data_start], eax 4302 FAT32_f_3: 4303 ;; DX_AX = FAT32 Boot Sector address 4304 ; 16/03/2021 4305 ; EAX = FAT32 Boot Sector address 4306 00001150 BB[A730] mov bx, TRDOS_FAT32_hd_bs 4307 ; ES:BX = Boot Sector 1 Buffer 4308 00001153 E8CF08 call write_hd_sector 4309 00001156 0F828502 jc formatting_error 4310 0000115A E83202 call write_format_percent 4311 ;add ax, 1 4312 ;adc dx, 0 4313 ; 16/03/2021 4314 0000115D 6640 inc eax 4315 0000115F BB[4263] mov bx, HDFORMAT_FSINFO_BUFF 4316 ; ES:BX = FS INFO Sector Buffer (= BS+1) 4317 00001162 E8C008 call write_hd_sector 4318 00001165 0F827602 jc formatting_error 4319 00001169 E82302 call write_format_percent 4320 ;add ax, 1 4321 ;adc dx, 0 4322 ; 16/03/2021 4323 0000116C 6640 inc eax 4324 0000116E BB[A732] mov bx, TRDOS_FAT32_hd_bs + 512 4325 ; ES:BX = Boot Sector 2 Buffer 4326 00001171 E8B108 call write_hd_sector 4327 00001174 0F826702 jc formatting_error 4328 00001178 E81402 call write_format_percent 4329 0000117B B90300 mov cx, 3 4330 FAT32_f_4: 4331 0000117E 51 push cx 4332 ;add ax, 1 4333 ;adc dx, 0 4334 ; 16/03/2021 4335 0000117F 6640 inc eax 4336 00001181 BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 4337 00001184 E89E08 call write_hd_sector 4338 00001187 0F825402 jc formatting_error 4339 0000118B E80102 call write_format_percent 4340 0000118E 59 pop cx 4341 0000118F FEC9 dec cl 4342 00001191 75EB jnz short FAT32_f_4 4343 ;add ax, 1 4344 ;adc dx, 0 4345 ; 16/03/2021 4346 00001193 6640 inc eax 4347 ;mov cx, [bp+1Ch] ; [BPB_HiddSec] 4348 ;mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4349 ;add cx, 12 4350 ;adc bx, 0 4351 ; 16/03/2021 4352 00001195 668B561C mov edx, [bp+1Ch] ; [BPB_HiddSec] 4353 00001199 6683C20C add edx, 12 4354 ; write BACKUP sectors 4355 ; (6,7,8 boot+fsi and 9,10,11 empty sectors) 4356 ;cmp dx, bx 4357 ;jb short FAT32_f_3 4358 ;cmp ax, cx 4359 ;jb short FAT32_f_3 4360 ; 16/03/2021 4361 0000119D 6639D0 cmp eax, edx 4362 000011A0 72AE jb short FAT32_f_3 4363 4364 ; write remain part of reserved sectors 4365 000011A2 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 4366 000011A5 83E90C sub cx, 12 4367 000011A8 7614 jna short FAT32_f_6 4368 FAT32_f_5: 4369 000011AA 51 push cx 4370 000011AB BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 4371 000011AE E87408 call write_hd_sector 4372 000011B1 0F822A02 jc formatting_error 4373 000011B5 E8D701 call write_format_percent 4374 ;add ax, 1 4375 ;adc dx, 0 4376 ; 16/03/2021 4377 000011B8 6640 inc eax 4378 000011BA 59 pop cx 4379 000011BB 49 dec cx 4380 000011BC 75EC jnz short FAT32_f_5 4381 FAT32_f_6: 4382 ; write FAT sectors 4383 ;mov cx, [data_start] ; lba/abs addr 4384 ;mov bx, [data_start+2] ; lba/abs addr 4385 ;push bx 4386 ;push cx 4387 ; 16/03/2021 4388 000011BE 668B16[5667] mov edx, [data_start] 4389 ;push edx ; * 4390 ; eax = sector address 4391 000011C3 BB[5665] mov bx, HDFORMAT_FATBUFFER 4392 ; ES:BX = FAT Sector Buffer 4393 000011C6 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 4394 000011C9 B5FF mov ch, 0FFh 4395 000011CB 890F mov [bx], cx 4396 000011CD 88E9 mov cl, ch ; cx = 0FFFFh 4397 000011CF 894F02 mov [bx+2], cx 4398 000011D2 894F04 mov [bx+4], cx 4399 000011D5 894F06 mov [bx+6], cx 4400 ; Root dir cluster number = 2 4401 ; 0FFFFFFFh = end of cluster chain 4402 000011D8 894F08 mov [bx+8], cx ; 0FFFFh 4403 000011DB 80E50F and ch, 0Fh 4404 000011DE 894F0A mov [bx+10], cx ; 0FFFh 4405 ;inc cx 4406 000011E1 E84108 call write_hd_sector 4407 000011E4 0F82F701 jc formatting_error 4408 000011E8 E8A401 call write_format_percent 4409 ;mov bx, HDFORMAT_FATBUFFER 4410 000011EB B90000 mov cx, 0 4411 000011EE 890F mov [bx], cx 4412 000011F0 894F02 mov [bx+2], cx 4413 000011F3 894F04 mov [bx+4], cx 4414 000011F6 894F06 mov [bx+6], cx 4415 000011F9 894F08 mov [bx+8], cx 4416 000011FC 894F0A mov [bx+10], cx 4417 000011FF EB0D jmp short FAT32_f_8 4418 FAT32_f_7: 4419 ;push bx 4420 ;push cx 4421 ; 16/03/2021 4422 ;push edx ; * 4423 00001201 BB[5665] mov bx, HDFORMAT_FATBUFFER 4424 00001204 E81E08 call write_hd_sector 4425 00001207 0F82D401 jc formatting_error 4426 0000120B E88101 call write_format_percent 4427 FAT32_f_8: 4428 ;pop cx 4429 ;pop bx 4430 ;add ax, 1 4431 ;adc dx, 0 4432 ;cmp dx, bx 4433 ;jb short FAT32_f_7 4434 ;cmp ax, cx 4435 ;jb short FAT32_f_7 4436 ; 16/03/2021 4437 ;pop edx ; * 4438 0000120E 6640 inc eax ; next sector 4439 00001210 6639D0 cmp eax, edx 4440 00001213 72EC jb short FAT32_f_7 4441 4442 ; write root directory (1st cluster) 4443 ; as empty sectors 4444 00001215 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4445 00001218 30ED xor ch, ch 4446 0000121A 290E[5A67] sub [data_sectors], cx 4447 0000121E 831E[5C67]00 sbb word [data_sectors+2], 0 4448 FAT32_f_9: 4449 00001223 51 push cx 4450 00001224 BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 4451 00001227 E8FB07 call write_hd_sector 4452 0000122A 0F82B101 jc formatting_error 4453 0000122E E85E01 call write_format_percent 4454 ;add ax, 1 4455 ;adc dx, 0 4456 ; 16/03/2021 4457 00001231 6640 inc eax 4458 00001233 59 pop cx 4459 00001234 FEC9 dec cl 4460 00001236 75EB jnz short FAT32_f_9 4461 4462 ; write DATA sectors 4463 ; (after root directory 1st cluster) 4464 ;mov cx, [data_sectors] 4465 ;mov bx, [data_sectors+2] 4466 ; ; NOTE: Partition size must be >= 512 MB 4467 ; ; for FAT32 FS ((BX >= 15)) 4468 ; 16/03/2021 4469 00001238 668B16[5A67] mov edx, [data_sectors] 4470 FAT32_f_10: 4471 ;push bx 4472 ;push cx 4473 ; 16/03/2021 4474 ;push edx 4475 0000123D BB[4261] mov bx, HDFORMAT_SECBUFFER 4476 00001240 E8E207 call write_hd_sector 4477 00001243 0F829801 jc formatting_error 4478 00001247 E84501 call write_format_percent 4479 ;pop edx 4480 ;pop cx 4481 ;pop bx 4482 ;add ax, 1 4483 ;adc dx, 0 4484 0000124A 6640 inc eax 4485 ;dec cx 4486 ;jnz short FAT32_f_10 4487 ;dec bx 4488 ;jnz short FAT32_f_10 4489 ; 16/03/2021 4490 0000124C 664A dec edx 4491 0000124E 75ED jnz short FAT32_f_10 4492 4493 ; If there are, format remain sectors which are 4494 ; at beyond of data clusters, with zero bytes. 4495 4496 ;mov cx, [bp+1Ch] ; [BPB_HiddSec] 4497 ;mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4498 ; 16/03/2021 4499 00001250 668B561C mov edx, [bp+1Ch] ; [BPB_HiddSec] 4500 FAT16_f_18: 4501 ;add cx, [bp+20h] ; [BPB_TotSec32] 4502 ;adc bx, [bp+22h] ; [BPB_TotSec32+2] 4503 ; 16/03/2021 4504 00001254 66035620 add edx, [bp+20h] ; [BPB_TotSec32] 4505 FAT16_f_19: 4506 FAT12_f_8: 4507 ; are there remain sectors (in partition) ? 4508 ;sub cx, ax 4509 ;sbb bx, dx 4510 ; 11/02/2019 4511 ; BX must be 0 (Because, 1 cluster <= 32KB. So, 4512 ; remain sectors must not be more than 32K) 4513 ;jnz short FAT32_f_12 ; There is a wrong thing !!! 4514 ; ; If BX is not zero, 4515 ; ; it is better to skip this stage...) 4516 ;or cx, cx 4517 ;jz short FAT32_f_12 ; no.. 4518 ; ; (good! FAT contains all data sectors) 4519 ; 16/03/2021 4520 00001258 6629C2 sub edx, eax 4521 0000125B 7612 jna short FAT32_f_12 4522 FAT32_f_11: 4523 ;push cx 4524 ; 16/03/2021 4525 ;push dx ; edx <= 32K 4526 0000125D BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 4527 00001260 E8C207 call write_hd_sector 4528 00001263 0F827801 jc formatting_error 4529 00001267 E82501 call write_format_percent 4530 ; 16/03/2021 4531 ;pop dx ; edx <= 32K 4532 ;pop cx 4533 ;add ax, 1 4534 ;adc dx, 0 4535 ; 16/03/2021 4536 0000126A 6640 inc eax 4537 ;dec cx 4538 0000126C 4A dec dx 4539 0000126D 75EE jnz short FAT32_f_11 4540 4541 FAT32_f_12: 4542 SINGLIX_fs1_f_12: 4543 ; End of FAT format routine... 4544 end_of_formatting: 4545 0000126F B064 mov al, 100 4546 00001271 E85501 call write_format_percent_x 4547 ;mov si, CRLF 4548 ;call print_msg 4549 00001274 BE[7052] mov si, Msg_OK 4550 ;call print_msg 4551 ;jmp _exit 4552 ; 19/10/2020 4553 00001277 E9F8F4 jmp _p_exit 4554 4555 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4556 ; set & write volume name 4557 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4558 4559 write_fs_volume_name: 4560 0000127A C606[2B61]40 mov byte [vname_length], 64 4561 0000127F EB05 jmp short svn_fs 4562 4563 write_volume_name: 4564 00001281 C606[2B61]0B mov byte [vname_length], 11 4565 svn_fs: 4566 ; DI = (BS) Volume Label address 4567 00001286 BE[1252] mov si, Msg_Volume_Name 4568 00001289 E83B07 call print_msg 4569 4570 ; get cursor position 4571 ; bh = 0 ; video page 4572 0000128C B403 mov ah, 3 ; get cursor pos 4573 0000128E CD10 int 10h 4574 00001290 8916[B851] mov [Cursor_Pos], dx 4575 4576 00001294 E81B08 call rw_char 4577 00001297 7207 jc short svn_1 4578 svn_0: 4579 00001299 AC lodsb 4580 0000129A 3C20 cmp al, 20h 4581 0000129C 7706 ja short svn_2 4582 0000129E 74F9 je short svn_0 4583 svn_1: 4584 000012A0 BE[3661] mov si, no_name 4585 000012A3 AC lodsb 4586 svn_2: 4587 ;mov di, [bp+47h) ; [BS_VolLab] ; FAT32 4588 ;mov di, [bp+2Bh) ; [BS_VolLab] ; FAT16 (&FAT12) 4589 000012A4 89FB mov bx, di ; * 4590 000012A6 30ED xor ch, ch 4591 000012A8 8A0E[2B61] mov cl, [vname_length] ; 11 4592 000012AC EB05 jmp short svn_4 4593 svn_3: 4594 000012AE AC lodsb 4595 000012AF 3C20 cmp al, 20h 4596 000012B1 7226 jb short svn_6 4597 svn_4: 4598 000012B3 AA stosb 4599 000012B4 E2F8 loop svn_3 4600 svn_5: 4601 000012B6 8A0E[2B61] mov cl, [vname_length] ; 11 4602 000012BA 89DE mov si, bx ; * 4603 000012BC BF[D151] mov di, StrVolumeName 4604 000012BF F3A4 rep movsb 4605 ;mov byte [di], 0 4606 4607 000012C1 8B16[B851] mov dx, [Cursor_Pos] 4608 000012C5 BB0700 mov bx, 7 4609 000012C8 B402 mov ah, 2 4610 000012CA CD10 int 10h ; Set Cursor Position 4611 4612 000012CC BE[D151] mov si, StrVolumeName 4613 000012CF E8F506 call print_msg 4614 000012D2 BE[7452] mov si, CRLF 4615 000012D5 E8EF06 call print_msg 4616 000012D8 C3 retn 4617 svn_6: 4618 000012D9 B020 mov al, 20h 4619 svn_7: 4620 000012DB AA stosb 4621 000012DC E2FD loop svn_7 4622 000012DE EBD6 jmp short svn_5 4623 4624 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4625 ; set & write volume serial number (volume ID) 4626 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4627 4628 write_volume_serial: 4629 ; SI = (BS) Volume Serial Number (binary) address 4630 4631 ;xor ax, ax 4632 ;int 1Ah ; get time of day 4633 4634 ;mov [si], dx 4635 ;mov [si+2], cx ; set unique volume ID 4636 4637 ;mov ah, 02h ; Return Current Time 4638 ;int 1Ah 4639 ;xchg ch, cl 4640 ;xchg dh, dl 4641 4642 ;add cx, dx 4643 ;add [si+2], cx 4644 4645 ;mov ah, 04h ; Return Current Date 4646 ;int 1Ah 4647 4648 ;xchg ch,cl 4649 ;xchg dh,dl 4650 4651 ;add cx, dx 4652 ;add [si+2], cx 4653 4654 ; According to Microsoft DOS 6.0 serial number 4655 ; production method... 4656 ; < Create unique 32 bit serial number > 4657 4658 ; Create_Serial_ID (MSDOS 6.0 Source code, MSFOR.ASM) 4659 ; (20/04/1987) 4660 ; 4661 ; Get date (INT 21h, AH=2Bh) 4662 ; Get time (INT 21h, AH=2Ch) 4663 ; Serial_ID+0 = DX reg date + DX reg time 4664 ; Serial_ID+2 = CX reg date + CX reg time 4665 ; Serial_Num_Low = Serial_ID+2 4666 ; Serial_Num_High = Serial_ID+0 4667 4668 000012E0 B404 mov ah, 04h ; Return Current Date 4669 000012E2 CD1A int 1Ah 4670 4671 ; DL = Day (BCD) (20h) 4672 ; DH = Month (BCD) (12h) 4673 ; CH = Century (BCD) (20h) 4674 ; CL = Year (BCD) (17h) 4675 4676 000012E4 88D0 mov al, dl 4677 000012E6 E87100 call bcd_to_bin 4678 000012E9 88C2 mov dl, al 4679 000012EB 88F0 mov al, dh 4680 000012ED E86A00 call bcd_to_bin 4681 000012F0 88C6 mov dh, al 4682 000012F2 88C8 mov al, cl 4683 000012F4 E86300 call bcd_to_bin 4684 000012F7 88C1 mov cl, al 4685 000012F9 88E8 mov al, ch 4686 000012FB E85C00 call bcd_to_bin 4687 000012FE 88C5 mov ch, al 4688 4689 ; DH = Month (1-10) 4690 ; DL = Day (1-31) 4691 ; CX = Year (1900-2099) 4692 4693 00001300 52 push dx 4694 00001301 51 push cx 4695 4696 00001302 B402 mov ah, 02h ; Return Current Time 4697 00001304 CD1A int 1Ah 4698 4699 ; DH = Seconds (BCD) (59h) 4700 ; CL = Minutes (BCD) (59h) 4701 ; CH = Hours (BCD) (23h) 4702 ; DL = Daylight savings time option (1=yes) 4703 4704 00001306 88F0 mov al, dh 4705 00001308 E84F00 call bcd_to_bin 4706 0000130B 88C6 mov dh, al 4707 0000130D 88C8 mov al, cl 4708 0000130F E84800 call bcd_to_bin 4709 00001312 88C1 mov cl, al 4710 00001314 88E8 mov al, ch 4711 00001316 E84100 call bcd_to_bin 4712 00001319 88C5 mov ch, al 4713 4714 ; CH = Hour (0-23) 4715 ; CL = Minutes (0-59) 4716 ; DH = Seconds (0-59) 4717 ; ((DL = Hundredths (0-99) - MSDOS!)) 4718 ; DL = 0 or 1 (here!) 4719 4720 0000131B 89C8 mov ax, cx 4721 0000131D 59 pop cx 4722 0000131E 01C8 add ax, cx 4723 4724 00001320 894402 mov [si+2], ax 4725 4726 00001323 89D0 mov ax, dx 4727 00001325 5A pop dx 4728 00001326 01D0 add ax, dx 4729 4730 00001328 8904 mov [si], ax 4731 4732 0000132A 30E4 xor ah, ah ; Read time counter 4733 0000132C CD1A int 1Ah 4734 4735 ; CX = High word of clock count 4736 ; DX = Low word of clock count 4737 ; AL = 0 if 24 hours has not passed, else 1 4738 4739 ; NOTES: 4740 ; (Ref: vitaly_filatov.tripod.com/ng/asm/asm_029.1.html) 4741 ; 4742 ; Following formulas convert the clock count to 4743 ; the time of day: 4744 ; Hour = Clock / 65543 (1007h) 4745 ; Remainder = Clock MOD 65543 4746 ; 4747 ; Minutes = Remainder / 1092 (444h) 4748 ; Remainder = Remainder MOD 1092 4749 ; 4750 ; Second = Remainder / 18.21 4751 ; Remainder = Remainder MOD 18.21 4752 ; 4753 ; Hundredths = CINT(Remainder * 100) 4754 4755 0000132E 0014 add [si], dl 4756 4757 ; SI = Volume serial number address (4 bytes) 4758 00001330 8A04 mov al, [si] 4759 00001332 E86607 call bin_to_hex 4760 00001335 A3[3D52] mov [Vol_Serial2+2], ax 4761 00001338 8A4401 mov al, [si+1] 4762 0000133B E85D07 call bin_to_hex 4763 0000133E A3[3B52] mov [Vol_Serial2], ax 4764 00001341 8A4402 mov al, [si+2] 4765 00001344 E85407 call bin_to_hex 4766 00001347 A3[3852] mov [Vol_Serial1+2], ax 4767 0000134A 8A4403 mov al, [si+3] 4768 0000134D E84B07 call bin_to_hex 4769 00001350 A3[3652] mov [Vol_Serial1], ax 4770 4771 00001353 BE[2452] mov si, Msg_Volume_Serial 4772 00001356 E86E06 call print_msg 4773 4774 00001359 C3 retn 4775 4776 bcd_to_bin: 4777 0000135A 53 push bx 4778 0000135B D410 db 0D4h, 10h ; Undocumented inst. AAM 4779 ; AH = AL / 10h 4780 ; AL = AL MOD 10h 4781 0000135D 88C3 mov bl, al 4782 0000135F B00A mov al, 10 4783 00001361 F6E4 mul ah 4784 00001363 00D8 add al, bl 4785 00001365 5B pop bx 4786 00001366 C3 retn 4787 4788 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4789 ; write formatting percentage 4790 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4791 4792 ; 16/03/2021 (fdisk4.s) 4793 write_formatting_msg: 4794 ;;mov ax, [pp_Sectors] 4795 ;;mov dx, [pp_Sectors+2] 4796 ;; 16/02/2019 4797 ;mov ax, [ppn_Sectors] 4798 ;mov dx, [ppn_Sectors+2] 4799 ; 16/03/2021 4800 00001367 66A1[146A] mov eax, [ppn_Sectors] 4801 4802 ;; DX_AX = Total sectors for percentage 4803 ;mov cx, 100 4804 ;call div32 4805 ;mov [format_percent], ax 4806 ; 16/03/2021 4807 0000136B 6631D2 xor edx, edx 4808 0000136E 66B964000000 mov ecx, 100 4809 00001374 66F7F1 div ecx 4810 00001377 66A3[6467] mov [format_percent], eax 4811 4812 0000137B BE[5C52] mov si, msg_formatting 4813 0000137E E84606 call print_msg 4814 4815 ; get cursor position 4816 ; bh = 0 ; video page 4817 00001381 B403 mov ah, 3 ; get cursor pos 4818 00001383 CD10 int 10h 4819 00001385 8916[B851] mov [Cursor_Pos], dx 4820 4821 00001389 C606[6867]FF mov byte [prev_percent], 255 4822 4823 0000138E C3 retn 4824 4825 ; 16/03/2021 (fdisk4.s) 4826 write_format_percent: 4827 ; DX_AX = Current sector (which has been written) 4828 4829 ; 16/03/2021 4830 ; EAX = current sector (which has been written) 4831 4832 ;push ax 4833 ;push dx 4834 ; 16/03/2021 4835 0000138F 6650 push eax 4836 00001391 6652 push edx 4837 00001393 53 push bx 4838 00001394 51 push cx 4839 00001395 56 push si 4840 4841 ;sub ax, [bp+1Ch] ; [BPB_HiddSec] 4842 ;sbb dx, [bp+1Eh] ; [BPB_HiddSec+2] 4843 ; 16/03/2021 4844 00001396 662B461C sub eax, [bp+1Ch] ; [BPB_HiddSec] 4845 wpc_t: 4846 ;mov cx, [format_percent] 4847 ;call div32 4848 ; 16/03/2021 4849 0000139A 6629D2 sub edx, edx 4850 0000139D 66F736[6467] div dword [format_percent] 4851 ; AL = percentage value between 1 to 100 4852 wpc_x: 4853 000013A2 3A06[6867] cmp al, [prev_percent] 4854 000013A6 7419 je short wpc_y 4855 000013A8 A2[6867] mov [prev_percent], al 4856 000013AB 8B16[B851] mov dx, [Cursor_Pos] 4857 000013AF BB0700 mov bx, 7 4858 000013B2 B402 mov ah, 2 4859 000013B4 CD10 int 10h ; Set Cursor Position 4860 ;;xor dx, dx 4861 ;xor edx, edx ; 16/03/2021 4862 000013B6 30E4 xor ah, ah 4863 ;mov al, [prev_percent] 4864 000013B8 BE[6A52] mov si, format_percent_str + 2 4865 000013BB E8C206 call bin_to_decimal 4866 000013BE E80606 call print_msg 4867 wpc_y: 4868 000013C1 5E pop si 4869 000013C2 59 pop cx 4870 000013C3 5B pop bx 4871 ; 16/03/2021 4872 000013C4 665A pop edx 4873 000013C6 6658 pop eax 4874 ;pop dx 4875 ;pop ax 4876 000013C8 C3 retn 4877 4878 write_format_percent_x: 4879 ; AL = % number 4880 4881 ;push ax 4882 ;push dx 4883 ; 16/03/2021 4884 000013C9 6650 push eax 4885 000013CB 6652 push edx 4886 000013CD 53 push bx 4887 000013CE 51 push cx 4888 000013CF 56 push si 4889 4890 000013D0 EBD0 jmp short wpc_x 4891 4892 write_fs_format_percent: 4893 ; DX_AX = Current sector (which has been written) 4894 ; 16/03/2021 4895 ; EAX = Current sector 4896 4897 ;push ax 4898 ;push dx 4899 ; 16/03/2021 4900 000013D2 6650 push eax 4901 000013D4 6652 push edx 4902 000013D6 53 push bx 4903 000013D7 51 push cx 4904 000013D8 56 push si 4905 4906 ;sub ax, [bp+0Ch] ; [bsBeginSector] 4907 ;sbb dx, [bp+0Eh] ; [bsBeginSector+2] 4908 ; 16/03/2021 4909 000013D9 662B460C sub eax, [bp+0Ch] ; [bsBeginSector] 4910 4911 000013DD EBBB jmp short wpc_t 4912 4913 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4914 ; format error 4915 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4916 4917 formatting_error: 4918 000013DF 8B26[5465] mov sp, [old_sp] 4919 4920 000013E3 88E0 mov al, ah ; error code 4921 000013E5 E8B306 call bin_to_hex 4922 000013E8 A3[8252] mov [error_code], ax 4923 4924 000013EB BE[7452] mov si, CRLF 4925 000013EE E8D605 call print_msg 4926 4927 000013F1 BE[7752] mov si, Msg_Error 4928 ;call print_msg 4929 ;jmp _exit 4930 ; 19/10/2020 4931 000013F4 E97BF3 jmp _p_exit 4932 4933 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4934 ; write cluster count 4935 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4936 4937 write_cluster_count: 4938 000013F7 BE[4252] mov si, msg_cluster_count 4939 000013FA E8CA05 call print_msg 4940 ;mov ax, [cluster_count] 4941 ;mov dx, [cluster_count+2] 4942 ; 16/03/2021 4943 000013FD 66A1[5E67] mov eax, [cluster_count] 4944 00001401 BE[5852] mov si, cluster_count_str+6 4945 00001404 E87906 call bin_to_decimal 4946 ;call print_msg 4947 ;retn 4948 ; 19/10/2020 4949 00001407 E9BD05 jmp print_msg 4950 4951 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4952 ; FAT16 FORMATTING 4953 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4954 4955 ; 17/03/2021 (fdisk4.s) 4956 ; 08/02/2019 (Modified for -only- FAT16 CHS partitions) 4957 FAT16_hd_format: 4958 ; 04/05/2024 (Retro DOS v5 modification) 4959 ; DL = Partition (FS) ID 4960 ; mov ax, 0706h ; db 06h, 07h ; 'push es, pop es' 4961 ; cmp dl, al ; 06h ; Big CHS partition (>= 32MB) 4962 ; je short FAT16_big_chs_format 4963 ; ;mov ax, 070Eh ; db 0Eh, 07h ; 'push cs, pop es' 4964 ; ;cmp dl, al ; 0Eh ; LBA partition 4965 ; ;je short FAT16_lba_format 4966 ;FAT16_chs_format: 4967 ; ; Partition Type: 04h, CHS (<32 MB) partition 4968 ; mov ax, 0004h ; db 04h, 00h ; 'add al, 0' 4969 ;FAT16_big_chs_format: 4970 ;;; 4971 ;;FAT16_lba_format: 4972 ; Put TRDOS 386 FAT16 partition magic word 4973 ; at offset 3Eh, in TRDOS386 FAT16 boot sector. 4974 0000140A BD[A734] mov bp, TRDOS_FAT16_hd_bs 4975 0000140D 8D7E03 lea di, [bp+3] 4976 00001410 BE[2C61] mov si, bs_oem_name 4977 00001413 B90400 mov cx, 4 4978 00001416 F3A5 rep movsw 4979 4980 ;mov [bp+3Eh], ax ; [loc_3E] 4981 ; 04/05/2024 (Retro DOS v5 modification) 4982 00001418 80FA06 cmp dl, 6 4983 0000141B 7404 je short FAT16_f_x ; skip ; db 'RDv5 FAT16 06h', 0 4984 ; dl = 04h or 0Eh 4985 0000141D 8896CE01 mov [bp+1CEh], dl ; Retro DOS v5 boot sect off 1CEh 4986 ; (see: 'rd5hdbs.txt' for 1CEh) 4987 FAT16_f_x: 4988 00001421 A1[BA3C] mov ax, [sectors] 4989 00001424 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4990 00001427 A1[BC3C] mov ax, [heads] 4991 0000142A 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4992 0000142D A1[DC69] mov ax, [pp_StartSector] 4993 00001430 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 4994 00001433 A1[DE69] mov ax, [pp_StartSector+2] 4995 00001436 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4996 4997 ;;mov ax, [pp_Sectors] 4998 ;mov ax, [ppn_Sectors] ; 16/02/2019 4999 ;;mov dx, [pp_Sectors+2] 5000 ;mov dx, [ppn_Sectors+2] ; 16/02/2019 5001 ;and dx, dx 5002 ;jnz short FAT16_f_0 5003 ; 17/03/2021 5004 00001439 66A1[146A] mov eax, [ppn_Sectors] 5005 0000143D 663D00000100 cmp eax, 65536 5006 00001443 7305 jnb short FAT16_f_0 5007 5008 00001445 894613 mov [bp+13h], ax ; [BPB_TotSec16] 5009 ; CX = 0 5010 ;mov [bp+20h], cx ; [BPB_TotSec32] = 0 5011 ;mov [bp+22h], cx ; [BPB_TotSec32+2] = 0 5012 00001448 EB04 jmp short FAT16_f_1 5013 FAT16_f_0: 5014 ;mov [bp+20h], ax ; [BPB_TotSec32] 5015 ;;;mov dx, [pp_Sectors+2] 5016 ;;mov dx, [ppn_Sectors+2] ; 16/02/2019 5017 ;mov [bp+22h], dx ; [BPB_TotSec32+2] 5018 ;; CX = 0 5019 ;;mov [bp+13h], cx ; [BPB_TotSec16] = 0 5020 ; 17/03/2021 5021 0000144A 66894620 mov [bp+20h], eax ; [BPB_TotSec32] 5022 FAT16_f_1: 5023 ; Sectors per cluster calculation 5024 ; (According to MS FAT32 FS specification.) 5025 0000144E B102 mov cl, 2 ; 2 sectors per cluster 5026 ; 17/03/2021 5027 00001450 6689C2 mov edx, eax 5028 00001453 66C1EA10 shr edx, 16 5029 00001457 7507 jnz short FAT16_f_2 ; >2 sectors (>16MB) 5030 ;or dx, dx 5031 ;jnz short FAT16_f_2 ; >2 sectors (>16MB) 5032 00001459 3DA87F cmp ax, 32680 5033 0000145C 763C jna short FAT16_f_10 ; 2 sectors, <=16MB 5034 ; > 16MB 5035 0000145E EB38 jmp short FAT16_f_9 ; 4 sectors per cluster 5036 FAT16_f_2: 5037 00001460 83FA04 cmp dx, 4 ; >= 262144 sectors ; >=128MB 5038 00001463 7708 ja short FAT16_f_3 ; >4 sectors per cluster 5039 00001465 7231 jb short FAT16_f_9 ; 4 sectors per cluster 5040 00001467 09C0 or ax, ax ; dx_ax = (4*65536)+0 5041 00001469 742D jz short FAT16_f_9 ; 4 sectors per cluster 5042 0000146B EB29 jmp short FAT16_f_8 ; 8 sectors per cluster 5043 FAT16_f_3: 5044 0000146D 83FA08 cmp dx, 8 ; >= 524288 sectors ; >=256MB 5045 00001470 7708 ja short FAT16_f_4 ; >8 sectors per cluster 5046 00001472 7222 jb short FAT16_f_8 ; 8 sectors per cluster 5047 00001474 21C0 and ax, ax ; dx_ax = (8*65536)+0 5048 00001476 741E jz short FAT16_f_8 ; 8 sectors per cluster 5049 00001478 EB1A jmp short FAT16_f_7 ; 16 sectors per cluster 5050 FAT16_f_4: 5051 0000147A 83FA10 cmp dx, 16 ; >= 1048576 sectors ; >=512MB 5052 0000147D 7708 ja short FAT16_f_5 ; >16 sectors per cluster 5053 0000147F 7213 jb short FAT16_f_7 ; 16 sectors per cluster 5054 00001481 21C0 and ax, ax ; dx_ax = (16*65536)+0 5055 00001483 740F jz short FAT16_f_7 ; 16 sectors per cluster 5056 00001485 EB0B jmp short FAT16_f_6 ; 32 sectors per cluster 5057 FAT16_f_5: 5058 00001487 83FA20 cmp dx, 32 ; >= 2097152 sectors ; >=1GB 5059 0000148A 7206 jb short FAT16_f_6 ; 32 sectors per cluster 5060 0000148C 09C0 or ax, ax ; dx_ax = (32*65536)+0 5061 0000148E 7402 jz short FAT16_f_6 ; 32 sectors per cluster 5062 ; >1GB (<=2GB) 5063 ; 64 sectors per cluster 5064 00001490 D0E1 shl cl, 1 5065 FAT16_f_6: 5066 ; 32 sectors per cluster (for <= 2GB volumes) 5067 00001492 D0E1 shl cl, 1 5068 FAT16_f_7: 5069 ; 16 sectors per cluster (for <= 1GB volumes) 5070 00001494 D0E1 shl cl, 1 5071 FAT16_f_8: 5072 ; 8 sectors per cluster (for <= 512MB volumes) 5073 00001496 D0E1 shl cl, 1 5074 FAT16_f_9: 5075 ; 4 sectors per cluster (for <= 256MB volumes) 5076 00001498 D0E1 shl cl, 1 5077 FAT16_f_10: 5078 ; 2 sectors per cluster (for <= 128MB volumes) 5079 0000149A 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 5080 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 5081 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 5082 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 5083 5084 ; Calculating FAT size in sectors 5085 ; (According to MS FAT32 FS Specification, 2000) 5086 5087 ; DX_AX = partition (volume) size in sectors 5088 ;mov bx, [bp+11h] ; [BPB_RootEntCnt] = 512 5089 ;add bx, 15 ; bx = 527 5090 ;shr bx, 4 ; /16 = 527/16 = 32 5091 ; ; ((32*BX)+511)/512 5092 ;mov [root_dir_secs], bx 5093 ;add bx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5094 ;sub ax, bx 5095 ;sbb dx, 0 5096 ; ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 5097 ; ; RootDirsectors) 5098 ; 17/03/2021 5099 0000149D 8B5611 mov dx, [bp+11h] ; [BPB_RootEntCnt] = 512 5100 000014A0 83C20F add dx, 15 ; DX = 527 5101 000014A3 C1EA04 shr dx, 4 ; /16 = 527/16 = 32 5102 ; ((32*DX)+511)/512 5103 000014A6 8916[6267] mov [root_dir_secs], dx 5104 000014AA 03560E add dx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5105 000014AD 6629D0 sub eax, edx 5106 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 5107 ; RootDirsectors) 5108 5109 ;;mov bx, cx ; ch = 0 5110 ;;shl bx, 8 ; * 256 5111 ;; 11/02/2019 5112 ;mov bh, cl 5113 ;xor bl, bl 5114 ;mov cl, 2 ; [BPB_NumFATs] 5115 ;add bx, cx 5116 ; ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 5117 ;mov cx, bx 5118 ;dec bx ; TmpVal2-1 5119 ;add ax, bx 5120 ;adc dx, 0 5121 ;call div32 5122 ; ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 5123 ;; AX = FAT size in sectors 5124 ;; DX = 0 5125 ;mov [bp+16h], ax ; [BPB_FATSz16] 5126 ; 17/03/2021 5127 000014B0 88CE mov dh, cl ; * 256 5128 ;mov dl, [bp+10h] ; [BPB_NumFATs] 5129 000014B2 B202 mov dl, 2 ; [BPB_NumFATs] 5130 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 5131 000014B4 6689D3 mov ebx, edx 5132 000014B7 4A dec dx ; TmpVal2-1 5133 000014B8 6601D0 add eax, edx 5134 000014BB 31D2 xor dx, dx 5135 000014BD 66F7F3 div ebx 5136 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 5137 ; EAX = FAT size in sectors (<= 256) 5138 ; * 2 5139 000014C0 D1E0 shl ax, 1 5140 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 5141 ;mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5142 ;add cx, ax 5143 ; 17/03/2021 5144 000014C2 8B560E mov dx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5145 000014C5 01C2 add dx, ax 5146 5147 ; 15/07/2024 (bugfix) 5148 000014C7 895642 mov [bp+42h], dx ; bsRootDirStart 5149 000014CA A1[6267] mov ax, [root_dir_secs] 5150 000014CD 894644 mov [bp+44h], ax ; bsRootDirSects 5151 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 5152 5153 ; EDX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5154 ;; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5155 ;add cx, [root_dir_secs] ; + RootDirsectors 5156 ;sub bx, bx ; BX = 0 5157 ; 15/07/2024 5158 ;add dx, [root_dir_secs] ; + RootDirsectors 5159 000014D0 01C2 add dx, ax 5160 5161 ; 15/07/2024 (bugfix) 5162 000014D2 895640 mov [bp+40h], dx ; bsDataStart 5163 5164 ; EDX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5165 ; + RootDirSectors 5166 ;; BX_CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5167 ; + RootDirSectors 5168 000014D5 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 5169 ;sub dx, dx 5170 ; DX = 0 5171 000014D8 21C0 and ax, ax 5172 000014DA 7504 jnz short FAT16_f_11 5173 ;mov ax, [bp+20h] ; [BPB_TotSec32] 5174 ;mov dx, [bp+22h] ; [BPB_TotSec32+2] 5175 000014DC 668B4620 mov eax, [bp+20h] ; [BPB_TotSec32] 5176 FAT16_f_11: 5177 ;sub ax, cx 5178 ;sbb dx, bx 5179 ; 17/03/2021 5180 ; EAX = Total Sectors 5181 ; EDX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5182 ; + RootDirSectors 5183 000014E0 6629D0 sub eax, edx 5184 ;mov [data_start], cx 5185 ;mov [data_start+2], bx 5186 000014E3 668916[5667] mov [data_start], edx 5187 ; DX_AX = Data sectors 5188 ;mov [data_sectors], ax 5189 ;mov [data_sectors+2], dx 5190 000014E8 66A3[5A67] mov [data_sectors], eax 5191 000014EC 31D2 xor dx, dx 5192 ;mov cl, [bp+0Dh] ; [BPB_SecPerClus] 5193 ;xor ch, ch 5194 ;call div32 ; DX_AX/CX 5195 ;; AX = Count of clusters (rounded down) 5196 ;; DX = 0 5197 000014EE 8A5E0D mov bl, [bp+0Dh] ; [BPB_SecPerClus] 5198 000014F1 30FF xor bh, bh 5199 000014F3 66F7F3 div ebx 5200 ; AX = Count of clusters (rounded down) 5201 ; (eax <= 65528) 5202 5203 ;mov [cluster_count], ax 5204 ;mov [cluster_count+2], dx 5205 000014F6 66A3[5E67] mov [cluster_count], eax 5206 5207 000014FA 8D7E2B lea di, [bp+43] ; [BS_VolLab] 5208 000014FD E881FD call write_volume_name 5209 00001500 8D7627 lea si, [bp+39] ; [BS_VolID] 5210 00001503 E8DAFD call write_volume_serial 5211 00001506 E8EEFE call write_cluster_count 5212 5213 00001509 E85BFE call write_formatting_msg 5214 0000150C B000 mov al, 0 5215 0000150E E8B8FE call write_format_percent_x 5216 5217 ;mov ax, [bp+1Ch] ; [BPB_HiddSec] 5218 ;mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 5219 00001511 668B461C mov eax, [bp+1Ch] ; [BPB_HiddSec] 5220 5221 ;add [data_start], ax 5222 ;adc [data_start+2], dx 5223 00001515 660106[5667] add [data_start], eax 5224 ;sub dx, dx ; edx = 0 5225 5226 ; DX_AX = FAT16 Boot Sector address 5227 0000151A BB[A734] mov bx, TRDOS_FAT16_hd_bs 5228 ; ES:BX = Boot Sector Buffer 5229 0000151D E80505 call write_hd_sector 5230 00001520 0F82BBFE jc formatting_error 5231 00001524 E868FE call write_format_percent 5232 ;add ax, 1 5233 ;adc dx, 0 5234 ; 17/03/2021 5235 00001527 6640 inc eax 5236 ; write remain part of reserved sectors 5237 00001529 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 5238 ;sub cx, 1 5239 ;jna short FAT16_f_13 5240 ; 11/02/2019 5241 0000152C 49 dec cx 5242 0000152D 7414 jz short FAT16_f_13 5243 FAT16_f_12: 5244 0000152F 51 push cx 5245 00001530 BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 5246 00001533 E8EF04 call write_hd_sector 5247 00001536 0F82A5FE jc formatting_error 5248 0000153A E852FE call write_format_percent 5249 ;add ax, 1 5250 ;adc dx, 0 5251 ; 17/03/2021 5252 0000153D 6640 inc eax 5253 0000153F 59 pop cx 5254 00001540 49 dec cx ; dec cl 5255 00001541 75EC jnz short FAT16_f_12 5256 FAT16_f_13: 5257 ; write FAT sectors 5258 ;mov cx, [data_start] ; lba/abs addr 5259 ;mov bx, [data_start+2] ; lba/abs addr 5260 ; 17/03/2021 5261 00001543 668B16[5667] mov edx, [data_start] 5262 5263 ; 11/02/2019 5264 ;sub cx, [root_dir_secs] 5265 ;sbb bx, 0 5266 ; 17/03/2021 5267 00001548 8B1E[6267] mov bx, [root_dir_secs] 5268 0000154C 6629DA sub edx, ebx 5269 ;push edx ; * 5270 5271 ;push bx 5272 ;push cx 5273 0000154F BB[5665] mov bx, HDFORMAT_FATBUFFER 5274 ; ES:BX = FAT Sector Buffer 5275 00001552 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 5276 00001555 B5FF mov ch, 0FFh 5277 00001557 890F mov [bx], cx ; 0FFF8h 5278 00001559 88E9 mov cl, ch ; cx = 0FFFFh 5279 0000155B 894F02 mov [bx+2], cx 5280 ;inc cx 5281 0000155E E8C404 call write_hd_sector 5282 00001561 0F827AFE jc formatting_error 5283 00001565 E827FE call write_format_percent 5284 ;mov bx, HDFORMAT_FATBUFFER 5285 00001568 B90000 mov cx, 0 5286 0000156B 890F mov [bx], cx 5287 0000156D 894F02 mov [bx+2], cx 5288 00001570 EB0D jmp short FAT16_f_15 5289 FAT16_f_14: 5290 ;push bx 5291 ;push cx 5292 ; 17/03/2021 5293 ; push edx ; * 5294 00001572 BB[5665] mov bx, HDFORMAT_FATBUFFER 5295 00001575 E8AD04 call write_hd_sector 5296 00001578 0F8263FE jc formatting_error 5297 0000157C E810FE call write_format_percent 5298 FAT16_f_15: 5299 ;pop cx 5300 ;pop bx 5301 ; 17/03/2021 5302 ;pop edx ; * 5303 ;add ax, 1 5304 ;adc dx, 0 5305 0000157F 6640 inc eax 5306 ;cmp dx, bx 5307 ;jb short FAT16_f_14 5308 ;cmp ax, cx 5309 ;jb short FAT16_f_14 5310 00001581 6639D0 cmp eax, edx 5311 00001584 72EC jb short FAT16_f_14 5312 5313 ; write root directory sectors 5314 ; as empty sectors 5315 00001586 8B0E[6267] mov cx, [root_dir_secs] 5316 FAT16_f_16: 5317 0000158A 51 push cx 5318 0000158B BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 5319 0000158E E89404 call write_hd_sector 5320 00001591 0F824AFE jc formatting_error 5321 00001595 E8F7FD call write_format_percent 5322 ;add ax, 1 5323 ;adc dx, 0 5324 ; 17/03/2021 5325 00001598 6640 inc eax 5326 0000159A 59 pop cx 5327 0000159B 49 dec cx 5328 0000159C 75EC jnz short FAT16_f_16 5329 5330 ; write DATA sectors 5331 ; (after root directory sectors) 5332 ;mov cx, [data_sectors] 5333 ;mov bx, [data_sectors+2] 5334 ; 17/03/2021 5335 0000159E 668B16[5A67] mov edx, [data_sectors] 5336 ; 11/02/2019 5337 000015A3 43 inc bx ; 0 -> 1, 1-> 2 5338 FAT16_f_17: 5339 ;push bx 5340 ;push cx 5341 ; 17/03/2021 5342 ;push edx ; ** 5343 000015A4 BB[4261] mov bx, HDFORMAT_SECBUFFER 5344 000015A7 E87B04 call write_hd_sector 5345 000015AA 0F8231FE jc formatting_error 5346 000015AE E8DEFD call write_format_percent 5347 ; 17/03/2021 5348 000015B1 665A pop edx ;** 5349 ;pop cx 5350 ;pop bx 5351 ;add ax, 1 5352 ;adc dx, 0 5353 000015B3 6640 inc eax 5354 ;dec cx 5355 ;jnz short FAT16_f_17 5356 ;dec bx 5357 ;jnz short FAT16_f_17 5358 ; 17/03/2021 5359 000015B5 664A dec edx 5360 000015B7 75EB jnz short FAT16_f_17 5361 5362 ; If there are, format remain sectors which are 5363 ; at beyond of data clusters, with zero bytes. 5364 5365 ;mov cx, [bp+1Ch] ; [BPB_HiddSec] 5366 ;mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 5367 ; 17/03/2021 5368 000015B9 668B561C mov edx, [bp+1Ch] ; [BPB_HiddSec] 5369 ;movzx ebx, word [bp+13h] ; [BPB_TotSec16] 5370 000015BD 8B5E13 mov bx, [bp+13h] ; [BPB_TotSec16] 5371 5372 ;cmp word [bp+13h], 0 ; [BPB_TotSec16] 5373 000015C0 09DB or bx, bx ; 17/03/2021 5374 000015C2 0F848EFC jz FAT16_f_18 5375 ;add cx, [bp+13h] ; [BPB_TotSec16] 5376 ;adc bx, 0 5377 ; 17/03/2021 5378 000015C6 6601DA add edx, ebx 5379 000015C9 E98CFC jmp FAT16_f_19 5380 5381 ; 17/03/2021 (fdisk4.s) 5382 FAT12_hd_format: 5383 000015CC BD[A736] mov bp, TRDOS_FAT12_hd_bs 5384 000015CF 8D7E03 lea di, [bp+3] 5385 000015D2 BE[2C61] mov si, bs_oem_name 5386 000015D5 B90400 mov cx, 4 5387 000015D8 F3A5 rep movsw 5388 000015DA A1[BA3C] mov ax, [sectors] 5389 000015DD 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 5390 000015E0 A1[BC3C] mov ax, [heads] 5391 000015E3 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 5392 5393 ;mov ax, [pp_StartSector] 5394 ;mov [bp+1Ch], ax ; [BPB_HiddSec] 5395 ;mov ax, [pp_StartSector+2] 5396 ;mov [bp+1Eh], ax ; [BPB_HiddSec+2] 5397 ; 17/03/2021 5398 000015E6 66A1[DC69] mov eax, [pp_StartSector] 5399 000015EA 6689461C mov [bp+1Ch], eax ; [BPB_HiddSec] 5400 5401 ;mov ax, [pp_Sectors] 5402 000015EE A1[146A] mov ax, [ppn_Sectors] ; 16/02/2019 5403 000015F1 894613 mov [bp+13h], ax ; [BPB_TotSec16] 5404 5405 ; 11/02/2019 5406 000015F4 31F6 xor si, si ; reset (FAT size fix) flag 5407 000015F6 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5408 000015F9 8B5611 mov dx, [bp+11h] ; [BPB_RootEntCnt] = 512 5409 000015FC 83C20F add dx, 15 ; (16-1) (512-1) 5410 000015FF C1EA04 shr dx, 4 ; /16 (*32/512) 5411 ; AX = Root dir sectors 5412 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5413 00001602 01D1 add cx, dx ; + RootDirsectors ; + 32 5414 00001604 890E[6267] mov [root_dir_secs], cx ; = 33 5415 5416 ; 11/02/2019 5417 ;sub ax, 33 ; 1 reserved sector, 32 root dir sectors 5418 ; .. now AX has number of data sectors 5419 ; + 2* (FAT sectors) 5420 00001608 29C8 sub ax, cx 5421 FAT12_f_10: ; 11/02/2019 5422 ; Sectors per cluster calculation 5423 ; (According to MS FAT32 FS specification.) 5424 ;mov cx, 1 ; 1 sector per cluster 5425 0000160A B101 mov cl, 1 ; CH = 0 5426 FAT12_f_0: 5427 0000160C 3DF50F cmp ax, 4085 ; Max. cluster count for FAT12 5428 0000160F 7206 jb short FAT12_f_1 5429 00001611 D0E1 shl cl, 1 ; *2 5430 00001613 D1E8 shr ax, 1 ; /2 5431 00001615 EBF5 jmp short FAT12_f_0 5432 FAT12_f_1: 5433 00001617 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 5434 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 5435 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 5436 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 5437 5438 ; Calculating FAT size in sectors 5439 ; AX = partition (volume) size in sectors 5440 ; CX = sectors per clusters 5441 0000161A 31D2 xor dx, dx 5442 0000161C F7F1 div cx 5443 ; AX = cluster count (only for FAT size calc) 5444 ; DX = 0 5445 0000161E 83C002 add ax, 2 ; cluster 2 to ... 5446 00001621 89C2 mov dx, ax 5447 00001623 D1E2 shl dx, 1 5448 00001625 01D0 add ax, dx ; *3 5449 00001627 D1E8 shr ax, 1 ; /2 5450 00001629 83D000 adc ax, 0 ; +0.5 -> +1 5451 5452 ; AX = FAT bytes for 12 bit cluster numbers 5453 5454 0000162C B90002 mov cx, 512 ; [BPB_BytesPerSec] 5455 0000162F 01C8 add ax, cx 5456 00001631 48 dec ax ; [BPB_BytesPerSec] - 1 5457 00001632 29D2 sub dx, dx 5458 00001634 F7F1 div cx 5459 00001636 894616 mov [bp+16h], ax ; [BPB_FATSz16] 5460 ; * 2 5461 00001639 D1E0 shl ax, 1 5462 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 5463 5464 ;mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5465 ;add cx, ax 5466 ;mov ax, [bp+11h] ; [BPB_RootEntCnt] = 512 5467 ;add ax, 15 ; (16-1) (512-1) 5468 ;shr ax, 4 ; /16 (*32/512) 5469 ;; AX = Root dir sectors 5470 ;; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5471 ;add cx, ax ; + RootDirsectors 5472 ;mov [root_dir_secs], ax 5473 5474 ; 11/02/2019 5475 ;mov cx, 33 5476 0000163B 8B0E[6267] mov cx, [root_dir_secs] 5477 5478 ; 15/07/2024 (bugfix) 5479 ; ax = 2 * FAT size (in sectors) 5480 0000163F 03460E add ax, [bp+0Eh] ; total FAT sectors + reserved sectors 5481 00001642 894642 mov [bp+42h], ax ; bsRootDirStart 5482 00001645 894E44 mov [bp+44h], cx ; bsRootDirSects 5483 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 5484 5485 ; 15/07/2024 5486 ;add cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 5487 ; cx = root directory sectors + reserved sectors 5488 00001648 01C1 add cx, ax 5489 5490 ; 15/07/2024 (bugfix) 5491 0000164A 894E40 mov [bp+40h], cx ; bsDataStart 5492 5493 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 5494 ; + RootDirSectors 5495 5496 ; 17/03/2021 5497 0000164D 6631C0 xor eax, eax 5498 5499 00001650 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 5500 00001653 29C8 sub ax, cx 5501 ; AX = data sectors 5502 ; cH = 0 5503 5504 ; 11/02/2019 - fix FAT size (better method) 5505 00001655 09F6 or si, si 5506 00001657 7504 jnz short FAT12_f_9 5507 5508 00001659 89C6 mov si, ax ; ax = data sectors 5509 0000165B EBAD jmp short FAT12_f_10 5510 5511 FAT12_f_9: 5512 0000165D 31D2 xor dx, dx 5513 0000165F 890E[5667] mov [data_start], cx 5514 00001663 8916[5867] mov [data_start+2], dx ; 0 5515 ; DX_AX = Data sectors 5516 ;mov [data_sectors], ax 5517 ;mov [data_sectors+2], dx ; 0 5518 ; 17/03/2021 5519 00001667 66A3[5A67] mov [data_sectors], eax 5520 0000166B 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 5521 0000166E 28ED sub ch, ch 5522 00001670 F7F1 div cx 5523 ; AX = Count of clusters (rounded down) 5524 00001672 29D2 sub dx, dx ; 0 5525 00001674 A3[5E67] mov [cluster_count], ax 5526 00001677 8916[6067] mov [cluster_count+2], dx ; 0 5527 5528 0000167B 8D7E2B lea di, [bp+43] ; [BS_VolLab] 5529 0000167E E800FC call write_volume_name 5530 00001681 8D7627 lea si, [bp+39] ; [BS_VolID] 5531 00001684 E859FC call write_volume_serial 5532 00001687 E86DFD call write_cluster_count 5533 5534 0000168A E8DAFC call write_formatting_msg 5535 0000168D B000 mov al, 0 5536 0000168F E837FD call write_format_percent_x 5537 5538 ;mov ax, [bp+1Ch] ; [BPB_HiddSec] 5539 ;mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 5540 ; 17/03/2021 5541 00001692 668B461C mov eax, [bp+1Ch] ; [BPB_HiddSec] 5542 5543 ;add [data_start], ax 5544 ;adc [data_start+2], dx 5545 ; 17/03/2021 5546 00001696 660106[5667] add [data_start], eax 5547 5548 ; DX_AX = FAT12 Boot Sector address 5549 0000169B BB[A736] mov bx, TRDOS_FAT12_hd_bs 5550 ; ES:BX = Boot Sector Buffer 5551 0000169E E88403 call write_hd_sector 5552 000016A1 0F823AFD jc formatting_error 5553 000016A5 E8E7FC call write_format_percent 5554 ;add ax, 1 5555 ;adc dx, 0 5556 ; 17/03/2021 5557 000016A8 6640 inc eax 5558 ; write remain part of reserved sectors 5559 000016AA 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 5560 ;sub cx, 1 5561 ;jna short FAT12_f_3 5562 ; 11/02/2019 5563 000016AD 49 dec cx 5564 000016AE 7414 jz short FAT12_f_3 5565 FAT12_f_2: 5566 000016B0 51 push cx 5567 000016B1 BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 5568 000016B4 E86E03 call write_hd_sector 5569 000016B7 0F8224FD jc formatting_error 5570 000016BB E8D1FC call write_format_percent 5571 ;add ax, 1 5572 ;adc dx, 0 5573 ; 17/03/2021 5574 000016BE 6640 inc eax ; next sector 5575 000016C0 59 pop cx 5576 000016C1 49 dec cx ; dec cl 5577 000016C2 75EC jnz short FAT12_f_2 5578 FAT12_f_3: 5579 ; write FAT sectors 5580 ;mov cx, [data_start] ; lba/abs addr 5581 ;mov bx, [data_start+2] ; lba/abs addr 5582 ; 17/03/2021 5583 000016C4 668B16[5667] mov edx, [data_start] ; lba/abs addr 5584 5585 ; 11/02/2019 5586 ;sub cx, [root_dir_secs] 5587 ;sbb bx, 0 5588 ; 17/03/2021 5589 ;movzx ebx, word [root_dir_secs] 5590 000016C9 8B1E[6267] mov bx, [root_dir_secs] 5591 000016CD 6629DA sub edx, ebx 5592 ;push edx ; *** 5593 5594 ;push bx 5595 ;push cx 5596 000016D0 BB[5665] mov bx, HDFORMAT_FATBUFFER 5597 ; ES:BX = FAT Sector Buffer 5598 000016D3 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 5599 000016D6 B5FF mov ch, 0FFh 5600 000016D8 890F mov [bx], cx ; 0FFF8h 5601 000016DA 886F02 mov [bx+2], ch ; 0FFFFF8h 5602 ;xor cx, cx 5603 000016DD E84503 call write_hd_sector 5604 000016E0 0F82FBFC jc formatting_error 5605 000016E4 E8A8FC call write_format_percent 5606 ;mov bx, HDFORMAT_FATBUFFER 5607 000016E7 B90000 mov cx, 0 5608 000016EA 890F mov [bx], cx 5609 000016EC 884F02 mov [bx+2], cl 5610 000016EF EB0D jmp short FAT12_f_5 5611 FAT12_f_4: 5612 ;push bx 5613 ;push cx 5614 ; 17/03/2021 5615 ;push edx ; *** 5616 000016F1 BB[5665] mov bx, HDFORMAT_FATBUFFER 5617 000016F4 E82E03 call write_hd_sector 5618 000016F7 0F82E4FC jc formatting_error 5619 000016FB E891FC call write_format_percent 5620 FAT12_f_5: 5621 ;pop cx 5622 ;pop bx 5623 ; 17/03/2021 5624 ;pop edx ; *** 5625 ; 5626 ;add ax, 1 5627 ;adc dx, 0 5628 ; 17/03/2021 5629 000016FE 6640 inc eax 5630 ;cmp dx, bx 5631 ;jb short FAT12_f_4 5632 ;cmp ax, cx 5633 ;jb short FAT12_f_4 5634 00001700 6639D0 cmp eax, edx 5635 00001703 72EC jb short FAT12_f_4 5636 5637 ; write root directory sectors 5638 ; as empty sectors 5639 00001705 8B0E[6267] mov cx, [root_dir_secs] 5640 FAT12_f_6: 5641 00001709 51 push cx 5642 0000170A BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 5643 0000170D E81503 call write_hd_sector 5644 00001710 0F82CBFC jc formatting_error 5645 00001714 E878FC call write_format_percent 5646 ;add ax, 1 5647 ;adc dx, 0 5648 ; 17/03/2021 5649 00001717 6640 inc eax 5650 00001719 59 pop cx 5651 0000171A 49 dec cx ; dec cl 5652 0000171B 75EC jnz short FAT12_f_6 5653 5654 ; write DATA sectors 5655 ; (after root directory sectors) 5656 0000171D 8B0E[5A67] mov cx, [data_sectors] 5657 ;mov bx, [data_sectors+2] 5658 ;inc bx ; 11/02/2019 5659 FAT12_f_7: 5660 ;push bx 5661 00001721 51 push cx 5662 00001722 BB[4261] mov bx, HDFORMAT_SECBUFFER 5663 00001725 E8FD02 call write_hd_sector 5664 00001728 0F82B3FC jc formatting_error 5665 0000172C E860FC call write_format_percent 5666 0000172F 59 pop cx 5667 ;pop bx 5668 ;add ax, 1 5669 ;adc dx, 0 5670 ; 17/03/2021 5671 00001730 6640 inc eax 5672 00001732 49 dec cx 5673 00001733 75EC jnz short FAT12_f_7 5674 ;dec bx 5675 ;jnz short FAT12_f_7 5676 5677 ; If there are, format remain sectors which are 5678 ; at beyond of data clusters, with zero bytes. 5679 5680 ;mov cx, [bp+1Ch] ; [BPB_HiddSec] 5681 ;mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 5682 ; 17/03/2021 5683 00001735 668B561C mov edx, [bp+1Ch] ; [BPB_HiddSec] 5684 5685 ;add cx, [bp+13h] ; [BPB_TotSec16] 5686 ;adc bx, 0 5687 ; 17/03/2021 5688 ;movzx ebx, word [bp+13h] ; [BPB_TotSec16] 5689 00001739 8B5E13 mov bx, [bp+13h] ; [BPB_TotSec16] 5690 0000173C 6601DA add edx, ebx 5691 5692 0000173F E916FB jmp FAT12_f_8 5693 5694 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5695 ; SINGLIX FS FORMATTING 5696 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5697 5698 ; 20/03/2021 5699 ; 19/03/2021 (fdisk4.s) 5700 SINGLIX_hd_format: 5701 ; 06/01/2018 5702 ; 05/01/2018 5703 ; If Sectors/Track = 17, use CHS+LBA type boot sector 5704 00001742 8B1E[BA3C] mov bx, [sectors] 5705 00001746 83FB11 cmp bx, 17 5706 00001749 7711 ja short SINGLIX_fs1_f_1 5707 SINGLIX_fs1_f_0: 5708 0000174B BD[A738] mov bp, TRDOS_TRFS1_chs_bs 5709 0000174E 887E2D mov [bp+45], bh ; 0 ; [bs_LBA_Ready] = 0 5710 00001751 885E2E mov [bp+46], bl ; [bs_Disk_SecPerTrack] 5711 00001754 A0[BC3C] mov al, [heads] 5712 00001757 88462F mov [bp+47], al ; [bs_Disk_Heads] 5713 0000175A EB1C jmp short SINGLIX_fs1_f_3 5714 SINGLIX_fs1_f_1: 5715 ; Sectors per Track = 63 5716 ; If disk capacity >= 63*16*1024 use LBA type boot sector 5717 ; 19/03/2021 (32bit cylinder count <=267349) 5718 0000175C 803E[C03C]00 cmp byte [cylinders+2], 0 5719 00001761 7712 ja short SINGLIX_fs1_f_2 5720 00001763 8B0E[BC3C] mov cx, [heads] 5721 00001767 A1[BE3C] mov ax, [cylinders] 5722 0000176A F7E1 mul cx 5723 0000176C 21D2 and dx, dx 5724 0000176E 7505 jnz short SINGLIX_fs1_f_2 5725 00001770 3D0040 cmp ax, 16384 5726 00001773 72D6 jb short SINGLIX_fs1_f_0 5727 SINGLIX_fs1_f_2: 5728 00001775 BD[A73A] mov bp, TRDOS_TRFS1_lba_bs 5729 ;mov byte [bp+45], 1 ; [bs_LBA_Ready] = 1 5730 SINGLIX_fs1_f_3: 5731 ;mov ax, [pp_Sectors] 5732 ;mov dx, [pp_Sectors+2] 5733 ; 16/02/2019 5734 ;mov ax, [ppn_Sectors] 5735 ;mov dx, [ppn_Sectors+2] 5736 5737 ; 19/03/2021 5738 00001778 66A1[146A] mov eax, [ppn_Sectors] 5739 ;mov [bp+16], ax ; [bsVolumeSize] 5740 ;mov [bp+18], dx ; [bsVolumeSize+2] 5741 0000177C 66894610 mov [bp+16], eax ; [bsVolumeSize] 5742 ;mov cx, [pp_StartSector] 5743 ;mov bx, [pp_StartSector+2] 5744 00001780 668B16[DC69] mov edx, [pp_StartSector] 5745 ;mov [bp+12], cx ; [bsBeginSector] 5746 ;mov [bp+14], bx ; [bsBeginSector+2] 5747 00001785 6689560C mov [bp+12], edx ; [bsBeginSector] 5748 5749 00001789 C6462C80 mov byte [bp+44], 80h ; [bsDriveNumber] ; hd0 5750 5751 ; Prepare MAT 5752 ;mov [MAT_VolumeSize], ax ; Total Sectors of the FS 5753 ;mov [MAT_VolumeSize+2], dx 5754 ; 19/03/2021 5755 0000178D 66A3[BC67] mov [MAT_VolumeSize], eax ; Total Sectors of the FS 5756 ;mov [MAT_BeginSector], cx ; Beginning Sector of the FS 5757 ;mov [MAT_BeginSector+2], bx 5758 00001791 668916[C067] mov [MAT_BeginSector], edx ; Beginning Sector of the FS 5759 5760 ;mov cx, [bp+24] ; [bsMATLocation] 5761 ;mov bx, [bp+26] ; [bsMATLocation+2] 5762 ;add cx, 1 5763 ;adc bx, 0 5764 ; Note: (as Default) MAT Address = 1, DAT Address = 2 5765 ;mov cx, 2 5766 ; 19/03/2021 5767 00001796 6631D2 xor edx, edx 5768 00001799 B202 mov dl, 2 5769 5770 ;xor bx, bx ; 0 5771 ;mov [bp+24], cx ; [bsMATLocation] 5772 ;mov [bp+26], bx ; [bsMATLocation+2] 5773 ;mov [DAT_Address], cx 5774 ;;mov [DAT_Address+2], bx 5775 ; 19/03/2021 5776 ;mov [DAT_Address], dx 5777 0000179B 8816[C467] mov [DAT_Address], dl 5778 5779 ; DX_AX = FS1 Volume Size 5780 ;add ax, 7 ; 7 bits more (for round up) 5781 ;adc dx, 0 5782 ; 19/03/2021 5783 ; EAX = FS1 Volume Size 5784 0000179F 6683C007 add eax, 7 ; 7 bits more (for round up) 5785 000017A3 30D2 xor dl, dl ; edx = 0 5786 ;mov cx, 8 ; 1 DAT byte == 8 sectors 5787 ;call div32 5788 ; DX_AX = DAT bytes 5789 ; 19/03/2021 5790 000017A5 6631C9 xor ecx, ecx 5791 000017A8 B108 mov cl, 8 5792 000017AA 66F7F1 div ecx 5793 ; eax = DAT bytes 5794 5795 000017AD B9FF01 mov cx, 511 5796 ;add ax, cx 5797 ;adc dx, 0 5798 ; 19/03/2021 5799 000017B0 6601C8 add eax, ecx 5800 5801 ;inc cx ; 512 5802 ;call div32 5803 ; DX_AX = DAT sectors (DX must be 0 for volume sizes < 128GB) 5804 ; 19/03/2021 5805 000017B3 41 inc cx ; ecx = 512 5806 000017B4 66F7F1 div ecx 5807 5808 ;mov [DAT_SectorCount], ax 5809 ;mov [DAT_SectorCount+2], dx ; 0 5810 ; 20/03/2021 5811 000017B7 66A3[C867] mov [DAT_SectorCount], eax 5812 5813 ;add ax, 2 ; BS + MAT 5814 ;adc dx, 0 5815 ;mov [bp+28], ax ; [bsRootDirDT] ; RDT address (offset) 5816 ;mov [bp+30], dx 5817 ; 20/03/2021 5818 000017BB 6683C002 add eax, 2 5819 000017BF 6689461C mov [bp+28], eax ; [bsRootDirDT] ; RDT address (offset) 5820 5821 ; Free Sectors = Total Sectors - (BS+MAT+DATsects+RDT+4) 5822 ;add ax, 5 ; DATsects + (BS+MAT+RDT+4) 5823 ;;mov dx, ax ; ? ; 5824 ;adc dx, 0 5825 ; 20/03/2021 5826 000017C3 6683C005 add eax, 5 5827 ;mov cx, [MAT_VolumeSize] 5828 ;mov bx, [MAT_VolumeSize+2] 5829 ;sub cx, ax 5830 ;sbb bx, 0 5831 ;mov [MAT_FreeSectors], cx 5832 ;mov [MAT_FreeSectors+2], bx 5833 ;mov [MAT_FirstFreeSector], ax 5834 ;mov [MAT_FirstFreesector+2], dx 5835 ; 20/03/2021 5836 000017C7 668B16[BC67] mov edx, [MAT_VolumeSize] 5837 000017CC 6629C2 sub edx, eax 5838 000017CF 668916[CC67] mov [MAT_FreeSectors], edx 5839 000017D4 66A3[D067] mov [MAT_FirstFreeSector], eax 5840 5841 000017D8 BF[6C67] mov di, fs_volume_name 5842 000017DB E89CFA call write_fs_volume_name 5843 000017DE BE[AC67] mov si, fs_volume_serial 5844 000017E1 E8FCFA call write_volume_serial 5845 5846 ; Modify FS volume name 5847 ; (Convert 20h tail bytes to 0) 5848 000017E4 B94000 mov cx, 64 5849 000017E7 BE[6C67] mov si, fs_volume_name 5850 000017EA 31DB xor bx, bx 5851 000017EC B0FF mov al, 0FFh 5852 modify_fs_vname_1: 5853 000017EE 88C4 mov ah, al 5854 000017F0 AC lodsb 5855 000017F1 3C20 cmp al, 20h 5856 000017F3 7708 ja short modify_fs_vname_2 5857 000017F5 80FC20 cmp ah, 20h 5858 000017F8 7603 jna short modify_fs_vname_2 5859 000017FA 89F3 mov bx, si 5860 000017FC 4B dec bx 5861 modify_fs_vname_2: 5862 000017FD E2EF loop modify_fs_vname_1 5863 000017FF 09DB or bx, bx 5864 00001801 740B jz short modify_fs_vname_3 5865 00001803 89DF mov di, bx 5866 00001805 B9[AC67] mov cx, fs_volume_name+64 5867 00001808 29D9 sub cx, bx 5868 0000180A 30C0 xor al, al 5869 0000180C F3AA rep stosb 5870 5871 modify_fs_vname_3: 5872 0000180E E856FB call write_formatting_msg 5873 00001811 B000 mov al, 0 5874 00001813 E8B3FB call write_format_percent_x 5875 5876 ;mov ax, [bp+12] ; [bsBeginSector] 5877 ;mov dx, [bp+14] ; [bsBeginSector+2] 5878 ; 20/03/2021 5879 00001816 668B460C mov eax, [bp+12] ; [bsBeginSector] 5880 5881 ; DX_AX = TRFS1 Boot Sector address 5882 0000181A 89EB mov bx, bp 5883 ; ES:BX = Boot Sector Buffer 5884 0000181C E80602 call write_hd_sector 5885 0000181F 0F82BCFB jc formatting_error 5886 5887 ;add ax, 1 5888 ;adc dx, 0 5889 ; 20/03/2021 5890 00001823 6640 inc eax 5891 5892 ; DX_AX = MAT (DAT header) sector address 5893 00001825 BB[B867] mov bx, FS_MAT_Buffer 5894 ; 16/02/2019 5895 00001828 C7074D41 mov word [bx],'MA' 5896 0000182C C6470254 mov byte [bx+2],'T' 5897 00001830 E8F201 call write_hd_sector 5898 00001833 0F82A8FB jc formatting_error 5899 00001837 E898FB call write_fs_format_percent 5900 5901 ; Calculate DAT bits 5902 ; NOTE: 4096 bits per DAT sector 5903 ;mov ax, [MAT_FirstFreeSector] 5904 ;mov dx, [MAT_FirstFreeSector+2] 5905 ;;xor dx, dx 5906 ; 20/03/2021 5907 0000183A 66A1[D067] mov eax, [MAT_FirstFreeSector] 5908 0000183E 6631D2 xor edx, edx 5909 5910 ;push dx 5911 ;push ax 5912 ; 20/03/2021 5913 00001841 6650 push eax 5914 00001843 B90010 mov cx, 4096 5915 ;call div32 5916 ;20/03/2021 5917 00001846 66F7F1 div ecx 5918 ;mov [DAT_FFBit], bx 5919 ;mov [DAT_FFSector], ax 5920 ;mov [DAT_FFSector+2], dx 5921 ; 20/03/2021 5922 00001849 8916[B067] mov [DAT_FFBit], dx 5923 0000184D 66A3[B267] mov [DAT_FFSector], eax 5924 ;pop ax 5925 ;pop dx 5926 ;sub ax, 1 5927 ;sbb dx, 0 5928 ; 20/03/2021 5929 00001851 6658 pop eax 5930 00001853 6648 dec eax 5931 5932 ;add ax, [MAT_FreeSectors] 5933 ;adc dx, [MAT_FreeSectors+2] 5934 ;call div32 5935 ;mov [DAT_LFBit], bx 5936 ;mov [DAT_LFSector], ax 5937 ; 20/03/2021 5938 00001855 31D2 xor dx, dx 5939 00001857 660306[CC67] add eax, [MAT_FreeSectors] 5940 0000185C 66F7F1 div ecx 5941 0000185F 8916[B467] mov [DAT_LFBit], dx 5942 00001863 66A3[B667] mov [DAT_LFSector], eax 5943 5944 ;xor si, si ; 0 5945 ; 20/03/2021 5946 00001867 6631F6 xor esi, esi ; 0 5947 SINGLIX_fs1_f_4: 5948 ; calculate free bits for current DAT sector 5949 ; (to be written) 5950 0000186A BF[D467] mov di, FS_DAT_Buffer 5951 5952 ; 20/03/2021 5953 ;cmp si, [DAT_FFSector] 5954 0000186D 663B36[B267] cmp esi, [DAT_FFSector] 5955 00001872 7433 je short SINGLIX_fs1_f_7 5956 00001874 724F jb short SINGLIX_fs1_f_9 5957 5958 ;cmp si, [DAT_LFSector] 5959 00001876 663B36[B667] cmp esi, [DAT_LFSector] 5960 0000187B 7225 jb short SINGLIX_fs1_f_6 5961 0000187D 7746 ja short SINGLIX_fs1_f_9 5962 5963 ; 20/03/2021 5964 0000187F 8B0E[B467] mov cx, [DAT_LFBit] 5965 00001883 88CC mov ah, cl 5966 00001885 C1E903 shr cx, 3 ; bit count to byte count 5967 00001888 7404 jz short SINGLIX_fs1_f_5 5968 ;Example: 5969 ;last free sector = 47 -> byte 5, bit 7 5970 ;last free sector = 48 -> byte 6, bit 0 5971 ; (also previous sectors are free sectors) 5972 0000188A B0FF mov al, 0FFh ; 20/03/2021 5973 ;mov cx, bx 5974 0000188C F3AA rep stosb 5975 ; 20/03/2021 5976 ;mov di, FS_DAT_Buffer 5977 ;add di, bx 5978 SINGLIX_fs1_f_5: 5979 0000188E 80E407 and ah, 7 5980 ;mov cl, ah 5981 ;shl al, cl 5982 ;not al 5983 ; 20/03/2021 5984 00001891 30C0 xor al, al 5985 SINGLIX_fs1_f_13: 5986 ; 20/03/2021 5987 ; 0 -> 00000001b (last free bit is bit 0) 5988 ; 1 -> 00000011b (last free bit is bit 1) 5989 ; 7 -> 11111111b (last free bit is bit 7) 5990 00001893 0C01 or al, 1 5991 00001895 08E4 or ah, ah 5992 00001897 7406 jz short SINGLIX_fs1_f_14 5993 00001899 D0E0 shl al, 1 5994 0000189B FECC dec ah 5995 0000189D EBF4 jmp short SINGLIX_fs1_f_13 5996 SINGLIX_fs1_f_14: 5997 0000189F AA stosb 5998 ;mov cx, 511 5999 ;sub cx, bx 6000 ;jna short SINGLIX_fs1_f_9 6001 ;mov al, 0 ; out of volume bits (=0) 6002 ;rep stosb 6003 000018A0 EB23 jmp short SINGLIX_fs1_f_9 6004 SINGLIX_fs1_f_6: 6005 000018A2 B90002 mov cx, 512 6006 000018A5 EB1A jmp short SINGLIX_fs1_f_8 6007 SINGLIX_fs1_f_7: 6008 ; 20/03/2021 6009 ;Example: 6010 ;first free sector = 23 -> byte 2, bit 7 6011 ;first free sector = 24 -> byte 3, bit 0 6012 ; (previous sectors are allocated sectors) 6013 000018A7 8B1E[B067] mov bx, [DAT_FFBit] 6014 000018AB 88D9 mov cl, bl 6015 000018AD 80E107 and cl, 7 6016 000018B0 C1EB03 shr bx, 3 ; from bits to bytes 6017 000018B3 01DF add di, bx 6018 000018B5 B0FF mov al, 0FFh 6019 000018B7 D2E0 shl al, cl 6020 000018B9 AA stosb 6021 000018BA B9FF01 mov cx, 511 6022 000018BD 29D9 sub cx, bx 6023 000018BF 7604 jna short SINGLIX_fs1_f_9 6024 SINGLIX_fs1_f_8: 6025 000018C1 B0FF mov al, 0FFh ; Free sector bits (=1) 6026 000018C3 F3AA rep stosb 6027 SINGLIX_fs1_f_9: 6028 ;mov ax, [MAT_BeginSector] 6029 ;mov dx, [MAT_BeginSector+2] 6030 ;;add ax, [DAT_Address] ; = 2 6031 ;;adc dx, [DAT_Address+2] 6032 ;add ax, 2 6033 ;adc dx, 0 6034 ;add ax, si 6035 ;adc dx, 0 6036 ; 20/03/2021 6037 000018C5 66A1[C067] mov eax, [MAT_BeginSector] 6038 000018C9 6683C002 add eax, 2 ; [DAT_Address] = 2 6039 000018CD 6601F0 add eax, esi 6040 6041 ; Write DAT sector(s) 6042 ;; DX_AX = Disk Allocation Table sector address 6043 ; EAX = Disk Allocation Table sector address 6044 000018D0 BB[D467] mov bx, FS_DAT_Buffer 6045 000018D3 E84F01 call write_hd_sector 6046 000018D6 0F8205FB jc formatting_error 6047 000018DA E8F5FA call write_fs_format_percent 6048 ; Clear DAT buffer again (for next stage) 6049 000018DD B90001 mov cx, 256 6050 000018E0 BF[D467] mov di, FS_DAT_Buffer 6051 000018E3 29C0 sub ax, ax 6052 000018E5 F3AB rep stosw 6053 6054 ;inc si 6055 ; 6056 ;cmp si, [DAT_SectorCount] 6057 ;jna SINGLIX_fs1_f_4 6058 6059 ; 20/03/2021 6060 000018E7 6646 inc esi 6061 000018E9 663B36[C867] cmp esi, [DAT_SectorCount] 6062 000018EE 0F8678FF jna SINGLIX_fs1_f_4 6063 6064 ; 20/03/2021 6065 000018F2 6631F6 xor esi, esi 6066 6067 ; ;;; 6068 6069 ; DAT sectors has been written.. 6070 ; Now, Root Directory Description Table is in order 6071 6072 000018F5 BF[D467] mov di, FS_RDT_Buffer 6073 000018F8 B84444 mov ax, 'DD' 6074 000018FB AB stosw 6075 000018FC 30E4 xor ah, ah 6076 000018FE B054 mov al, 'T' 6077 00001900 AB stosw 6078 00001901 B80002 mov ax, 512 ; Sector size (Bytes per sector) 6079 00001904 AB stosw 6080 00001905 31C0 xor ax, ax ; RDT sequence number (= 0, section 1) 6081 00001907 AB stosw 6082 ; RDT address 6083 ;mov ax, [DAT_SectorCount] 6084 ;mov dx, [DAT_SectorCount+2] 6085 ;add ax, 2 ; BS + MAT 6086 ;adc dx, 0 6087 ;stosw 6088 ;mov ax, dx 6089 ;stosw 6090 ; 20/03/2021 6091 00001908 66A1[C867] mov eax, [DAT_SectorCount] 6092 0000190C 6683C002 add eax, 2 ; BS + MAT 6093 00001910 66AB stosd 6094 6095 ;sub ax, ax ; Next RDT number 6096 ;stosw 6097 ;stosw 6098 ; 20/03/2021 6099 00001912 6629C0 sub eax, eax 6100 00001915 66AB stosd 6101 6102 ;mov ax, 4 ; Sector count of this section 6103 ; ; (4*512)/4 = 512 root dir entries 6104 ;stosw 6105 ; 20/03/2021 6106 00001917 B004 mov al, 4 6107 ;stosw 6108 ;xor al, al 6109 ;stosw 6110 00001919 66AB stosd 6111 6112 ; Volume beginning sector 6113 ;mov ax, [bp+12] ; [bsBeginSector] 6114 ;mov dx, [bp+14] ; [bsBeginSector+2] 6115 ;stosw 6116 ;mov ax, dx 6117 ;stosw 6118 ; 20/03/2021 6119 0000191B 668B460C mov eax, [bp+12] ; [bsBeginSector] 6120 0000191F 66AB stosd 6121 6122 ;xor ax, ax 6123 ;dec ax ; 0FFFFh 6124 ;; Parent Dir Serial (= FFFFFFFFh for root dir) 6125 ;stosw 6126 ;stosw 6127 ; 20/03/2021 6128 00001921 6631C0 xor eax, eax ; 0 6129 00001924 6648 dec eax ; 0FFFFFFFFh 6130 ; Parent Dir Serial (= FFFFFFFFh for root dir) 6131 00001926 66AB stosd 6132 00001928 6640 inc eax 6133 ; eax = 0 6134 set_fs_volume_serial_number: 6135 0000192A BE[AC67] mov si, fs_volume_serial 6136 0000192D A5 movsw 6137 0000192E A5 movsw 6138 6139 ; 20/03/2021 6140 ;sub ax, ax 6141 ;stosb ; sub directory level = 0 6142 ;stosb ; 0, reserved 6143 0000192F AB stosw 6144 00001930 B004 mov al, 00000100b ; (DOS) System attribute 6145 00001932 AA stosb ; (DOS) Basic attributes 6146 00001933 28C0 sub al, al ; Extended attributes (0 for TRDOS 386) 6147 00001935 AA stosb 6148 ; 20/03/2021 6149 ;sub ax, ax ; reserved (8) bytes for TR-MULTIX 6150 00001936 AB stosw 6151 00001937 AB stosw 6152 00001938 AB stosw 6153 00001939 AB stosw 6154 0000193A B85254 mov ax, 'RT' ; TRFS Root directory signature 6155 0000193D AB stosw 6156 0000193E 31C0 xor ax, ax ; Country (language, date, text format) 6157 ; (0 = Default, 1 = USA, 90 = Turkiye) 6158 ;stosb 6159 ;stosb ; Time Zone (0 = GMT = default ; -11 to +12) 6160 00001940 AB stosw 6161 6162 00001941 89FE mov si, di 6163 ; get the date (from RTC) 6164 00001943 B404 mov ah, 4 6165 00001945 CD1A int 1Ah 6166 ; Creating Date (of root directory) 6167 00001947 86E9 xchg ch, cl ; 07/01/2018 6168 00001949 89C8 mov ax, cx ; cl = century (BCD), ch = year (BCD) 6169 0000194B AB stosw 6170 0000194C 88F0 mov al, dh ; month (BCD) 6171 0000194E AA stosb 6172 0000194F 88D0 mov al, dl ; day (BCD) 6173 00001951 AA stosb 6174 ; get the time (from RTC) 6175 00001952 B402 mov ah, 2 6176 00001954 CD1A int 1Ah 6177 ; Creating Time (of root directory) 6178 00001956 86CD xchg cl, ch ; ch = hour (BCD), cl = minute (BSD) 6179 00001958 89C8 mov ax, cx ; al = hour, ah = minute 6180 0000195A AB stosw 6181 0000195B 88F0 mov al, dh ; seconds (BCD) 6182 0000195D AA stosb 6183 0000195E 88D0 mov al, dl ; daylight savings time option 6184 00001960 AA stosb 6185 ; Set Last Modification Date&Time 6186 00001961 B90400 mov cx, 4 6187 00001964 F3A5 rep movsw ; copy creating date&time values to 6188 ; last modification date time values 6189 ; (last modif date&time = creating date&time) 6190 6191 set_fs_volume_name: 6192 00001966 BE[6C67] mov si, fs_volume_name 6193 00001969 B120 mov cl, 32 6194 0000196B F3A5 rep movsw 6195 6196 ; Fill remain bytes (of this RDT) with zero 6197 0000196D B9C000 mov cx, (128+256)/2 6198 00001970 31C0 xor ax, ax 6199 00001972 F3AB rep stosw 6200 6201 ; RDT is ready here... 6202 6203 ;mov ax, [bp+28] ; [bsRootDirDT] 6204 ;mov dx, [bp+30] ; [bsRootDirDT+2] 6205 ;;xor dx, dx 6206 ;add ax, [bp+12] ; [bsBeginSector] 6207 ;adc dx, [bp+14] ; [bsBeginSector+2] 6208 ; 20/03/2021 6209 00001974 668B461C mov eax, [bp+28] ; [bsRootDirDT] 6210 00001978 6603460C add eax, [bp+12] ; [bsBeginSector] 6211 6212 ; Write RDT sector 6213 ;; DX_AX = Root Directory Description Table address 6214 ; EAX = Root Directory Description Table address 6215 0000197C BB[D467] mov bx, FS_RDT_Buffer 6216 0000197F E8A300 call write_hd_sector 6217 00001982 0F8259FA jc formatting_error 6218 00001986 E849FA call write_fs_format_percent 6219 6220 ;add ax, 1 6221 ;adc dx, 0 6222 ; 20/03/2021 6223 00001989 6640 inc eax 6224 6225 ; write root directory data sectors 6226 ;mov cx, 4 6227 ; 20/03/2021 6228 0000198B B104 mov cl, 4 6229 SINGLIX_fs1_f_10: 6230 0000198D 51 push cx 6231 ; Write root directory sector(s) 6232 ; DX_AX = Root Directory Sector address 6233 0000198E BB[5665] mov bx, HDFORMAT_EMPTY_BUFF 6234 00001991 E89100 call write_hd_sector 6235 00001994 0F8247FA jc formatting_error 6236 00001998 E837FA call write_fs_format_percent 6237 ;add ax, 1 6238 ;adc dx, 0 6239 ; 20/03/2021 6240 0000199B 6640 inc eax 6241 0000199D 59 pop cx 6242 0000199E FEC9 dec cl 6243 000019A0 75EB jnz short SINGLIX_fs1_f_10 6244 6245 ; Fill remain sectors with 'F6h' bytes 6246 ;mov cx, [bp+16] ; [bsVolumeSize] 6247 ;mov bx, [bp+18] ; [bsVolumeSize+2] 6248 ;add cx, [bp+12] ; [bsBeginSector] 6249 ;adc bx, [bp+14] ; [bsBeginSector+2] 6250 ; 20/03/2021 6251 000019A2 668B5610 mov edx, [bp+16] ; [bsVolumeSize] 6252 000019A6 6603560C add edx, [bp+12] ; [bsBeginSector] 6253 6254 ; write DATA sectors 6255 ; (after root directory sectors) 6256 SINGLIX_fs1_f_11: 6257 ;push bx 6258 ;push cx 6259 ; 20/03/2021 6260 ;push edx ; * 6261 000019AA BB[4261] mov bx, HDFORMAT_SECBUFFER 6262 000019AD E87500 call write_hd_sector 6263 000019B0 0F822BFA jc formatting_error 6264 000019B4 E8D8F9 call write_format_percent 6265 ;pop cx 6266 ;pop bx 6267 ; 20/03/2021 6268 ;pop edx ; * 6269 6270 ;add ax, 1 6271 ;adc dx, 0 6272 ; 20/03/2021 6273 000019B7 6640 inc eax 6274 6275 ;cmp dx, bx 6276 ;jb short SINGLIX_fs1_f_11 6277 ;ja SINGLIX_fs1_f_12 6278 ;cmp ax, cx 6279 ;jb short SINGLIX_fs1_f_11 6280 ; 20/03/2021 6281 000019B9 6639D0 cmp eax, edx 6282 000019BC 72EC jb short SINGLIX_fs1_f_11 6283 6284 ; 20/03/2021 6285 ; (this may not be needed) 6286 ; (but cleaering hw of 32 bit regs may be useful)) 6287 000019BE 6631D2 xor edx, edx 6288 000019C1 6631C0 xor eax, eax 6289 6290 000019C4 E9A8F8 jmp SINGLIX_fs1_f_12 6291 6292 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6293 ; print messages 6294 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6295 6296 print_msg: 6297 6298 print_msg_LOOP: 6299 000019C7 AC lodsb ; Load byte at DS:SI to AL 6300 000019C8 20C0 and al, al 6301 000019CA 7409 jz short print_msg_OK 6302 000019CC B40E mov ah, 0Eh 6303 000019CE BB0700 mov bx, 07h 6304 000019D1 CD10 int 10h ; BIOS Service func ( ah ) = 0Eh 6305 ; Write char as TTY 6306 ; AL-char BH-page BL-color 6307 000019D3 EBF2 jmp short print_msg_LOOP 6308 6309 print_msg_OK: 6310 000019D5 C3 retn 6311 6312 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6313 ; reading a block (sector) on hard disk 6314 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6315 ; 17/10/2020 6316 6317 ; 09/03/2021 (fdisk4.s) 6318 read_hd_sector: 6319 6320 ; INPUT -> DX_AX = Logical Block Address 6321 ; ES:BX = Sector Buffer 6322 ; OUTPUT -> 6323 ; cf = 0 -> DX_AX = Logical Block Adress 6324 ; ES:BX = Sector Buffer 6325 ; cf = 1 -> AH = Error Number 6326 6327 ; 09/03/2021 6328 ; INPUT -> EAX = Logical Block Address 6329 ; ES:BX = Sector buffer 6330 6331 ;cmp dx, [chs_limit+2] 6332 ;ja short read_lba_sector 6333 ;jb short read_chs_sector 6334 ;cmp ax, [chs_limit] 6335 ;ja short read_lba_sector 6336 ;;jmp short read_chs_sector 6337 6338 ; 09/03/2021 6339 000019D6 663B06[4E65] cmp eax, [chs_limit] 6340 000019DB 7707 ja short read_lba_sector 6341 6342 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6343 ; reading a block (sector) by using CHS read (ROMBIOS) function 6344 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6345 ; 17/10/2020 6346 6347 read_chs_sector: 6348 ; hdformat.s (25/09/2020) 6349 000019DD C606[4865]02 mov byte [rw], 2 ; read 6350 000019E2 EB4D jmp short chs_rw 6351 6352 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6353 ; reading a block (sector) by using LBA read (ROMBIOS) function 6354 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6355 ; 17/10/2020 6356 6357 read_lba_sector: 6358 ; hdformat.s (25/09/2020) 6359 000019E4 C606[4865]42 mov byte [rw], 42h 6360 000019E9 EB05 jmp short lba_rw 6361 6362 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6363 ; writing a block (sector) by using LBA write (ROMBIOS) function 6364 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6365 ; 17/10/2020 6366 6367 ; 18/10/2020 6368 write_lba_sector: 6369 ; hdformat.s (25/09/2020) 6370 000019EB C606[4865]43 mov byte [rw], 43h 6371 ;jmp short lba_rw 6372 lba_rw: 6373 ;mov di, 5 6374 ; 18/10/2020 6375 000019F0 C606[4965]05 mov byte [rcnt], 5 ; Retry count 6376 lba_rw_1: 6377 ;pusha ; db 60h 6378 000019F5 60 db 60h 6379 ;push 0 ; db 6Ah, 00h 6380 000019F6 6A00 db 6Ah, 0 6381 ;push 0 ; db 6Ah, 00h 6382 000019F8 6A00 db 6Ah, 0 6383 ;push dx 6384 ;push ax 6385 ; 09/03/2021 6386 000019FA 6650 push eax 6387 000019FC 06 push es 6388 000019FD 53 push bx 6389 ;push 1 ; db 6Ah, 01h 6390 000019FE 6A01 db 6Ah, 01h 6391 ;push 10h ; db 6Ah, 10h 6392 00001A00 6A10 db 6Ah, 10h 6393 6394 00001A02 89E6 mov si, sp 6395 00001A04 8A16[4665] mov dl, [DrvNum] 6396 00001A08 30C0 xor al, al ; verify off 6397 lba_rw_2: 6398 00001A0A 8A26[4865] mov ah, [rw] ; 42h = LBA read, 43h = LBA write 6399 ;xor al, al ; verify off 6400 00001A0E CD13 int 13h 6401 6402 ;mov [error], ah 6403 00001A10 7310 jnc short lba_rw_3 6404 6405 ;dec di 6406 ; 18/10/2020 6407 00001A12 FE0E[4965] dec byte [rcnt] 6408 00001A16 740A jz short lba_rw_3 6409 6410 00001A18 30E4 xor ah, ah 6411 ;mov dl, [DrvNum] 6412 00001A1A CD13 int 13h ; BIOS Service func (ah) = 0 6413 ; Reset disk system 6414 6415 ;mov word [si+2], 1 ; set r/w count to 1 again 6416 00001A1C C6440201 mov byte [si+2], 1 6417 6418 00001A20 EBE8 jmp short lba_rw_2 6419 6420 lba_rw_3: 6421 ;popa 6422 00001A22 61 db 61h 6423 ;popa 6424 00001A23 61 db 61h 6425 00001A24 C3 retn 6426 6427 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6428 ; writing a block (sector) on hard disk 6429 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6430 ; 17/10/2020 6431 6432 ; 09/03/2021 (fdisk4.s) 6433 write_hd_sector: 6434 6435 ; INPUT -> DX_AX = Logical Block Address 6436 ; ES:BX = Sector Buffer 6437 ; OUTPUT -> 6438 ; cf = 0 -> DX_AX = Logical Block Adress 6439 ; ES:BX = Sector Buffer 6440 ; cf = 1 -> AH = Error Number 6441 6442 ; 09/03/2021 6443 ; INPUT -> EAX = Logical Block Address 6444 ; ES:BX = Sector buffer 6445 6446 ;cmp dx, [chs_limit+2] 6447 ;ja short write_lba_sector 6448 ;jb short write_chs_sector 6449 ;cmp ax, [chs_limit] 6450 ;ja short write_lba_sector 6451 ;;jmp short write_chs_sector 6452 6453 ; 09/03/2021 6454 00001A25 663B06[4E65] cmp eax, [chs_limit] 6455 00001A2A 77B8 ja short read_lba_sector 6456 6457 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6458 ; writing a block (sector) by using CHS write (ROMBIOS) function 6459 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6460 ; 17/10/2020 6461 6462 ; 18/10/2020 6463 write_chs_sector: 6464 ; hdformat.s (25/09/2020) 6465 00001A2C C606[4865]03 mov byte [rw], 3 ; write 6466 ;jmp short chs_rw 6467 6468 ; 09/03/2021 6469 chs_rw: 6470 00001A31 56 push si 6471 ;push cx 6472 ; 09/03/2021 6473 00001A32 6651 push ecx 6474 chs_rw_0: 6475 ;mov di, 5 6476 ; 18/10/2020 6477 00001A34 C606[4965]05 mov byte [rcnt], 5 ; Retry count 6478 chs_rw_1: 6479 ;push dx ; Linear sector # 6480 ;push ax ; DX_AX = Linear address (sectors) 6481 ;mov cx, [sectors] 6482 ;push bx 6483 ; 6484 ;call div32 ; 32 bit divide 6485 6486 ; 09/03/2021 6487 00001A39 6652 push edx 6488 00001A3B 6650 push eax 6489 00001A3D 6631D2 xor edx, edx 6490 00001A40 6631C9 xor ecx, ecx 6491 00001A43 8B0E[BA3C] mov cx, [sectors] 6492 00001A47 66F7F1 div ecx 6493 00001A4A 42 inc dx 6494 00001A4B 52 push dx ; sector (1 based) 6495 00001A4C 8B0E[BC3C] mov cx, [heads] 6496 00001A50 66F7F1 div ecx 6497 00001A53 88D6 mov dh, dl ; head 6498 00001A55 59 pop cx 6499 6500 ;mov cx, bx ; Sector (zero based) 6501 ;inc cx ; To make it 1 based 6502 ;push cx 6503 ;mov cx, [heads] 6504 ;call div32 ; Convert track to head & cyl 6505 ;mov dh, bl ; BX = Head (max. FFh) 6506 ;pop cx ; AX=Cyl, DH=Head, CX=Sector 6507 ;pop bx ; ES:BX = Buffer 6508 6509 00001A56 8A16[4665] mov dl, [DrvNum] 6510 00001A5A 88C5 mov ch, al 6511 00001A5C D0CC ror ah, 1 ; Rotate right 6512 00001A5E D0CC ror ah, 1 6513 00001A60 08E1 or cl, ah 6514 chs_rw_2: 6515 00001A62 8A26[4865] mov ah, [rw] ; 02h = read, 03h = write 6516 00001A66 B001 mov al, 01h 6517 00001A68 CD13 int 13h ; BIOS Service func (ah) = 2/3 6518 ; Read/Write disk sectors 6519 ; AL-sec num CH-track CL-sec 6520 ; DH-head DL-drive ES:BX-buffer 6521 ; CF-flag AH-status AL-sectors written/read 6522 ; If CF = 1 then AH = Error code (>0) 6523 6524 00001A6A 730C jnc short chs_rw_3 6525 ;dec di 6526 00001A6C FE0E[4965] dec byte [rcnt] ; 18/10/2020 6527 00001A70 7406 jz short chs_rw_3 6528 6529 00001A72 30E4 xor ah, ah 6530 ;mov dl, [DrvNum] 6531 00001A74 CD13 int 13h ; BIOS Service func (ah) = 0 6532 ; Reset disk system 6533 00001A76 EBEA jmp short chs_rw_2 6534 6535 chs_rw_3: 6536 ;pop ax 6537 ;pop dx 6538 ;pop cx 6539 ; 09/03/2021 6540 00001A78 6658 pop eax 6541 00001A7A 665A pop edx 6542 00001A7C 6659 pop ecx 6543 00001A7E 5E pop si 6544 00001A7F C3 retn 6545 6546 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6547 ; convert byte to decimal number 6548 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6549 6550 ; 16/03/2021 (fdisk4.s) 6551 bin_to_decimal: 6552 ; INPUT: DS:SI = Target location 6553 ; DX_AX = Binary Number (Integer) 6554 ; OUTPUT: Decimal char at DS:SI 6555 ; SI decremented after every division 6556 ; till AX<10. 6557 ; CX, DX, BX will be changed. 6558 6559 ; 16/03/2021 6560 ; INPUT: 6561 ; DS:SI = Target location 6562 ; EAX = Binary number 6563 ; OUTPUT: Decimal char at DS:SI 6564 ; SI decremented after every division 6565 ; till EAX<10. 6566 ; 6567 ; Modified regaisters: ecx (=10), edx (<10) 6568 6569 ;mov cx, 10 6570 ; 16/03/2021 6571 00001A80 6631C9 xor ecx, ecx 6572 00001A83 B10A mov cl, 10 6573 00001A85 6631D2 xor edx, edx 6574 btd_0: 6575 ;; DX_AX = Dividend 6576 ;; CX = Divisor 6577 ;call div32 6578 ;; DX_AX = Quotient 6579 ;; BX = remainder 6580 ;add bl, '0' 6581 ;mov [si], bl 6582 ;and dx, dx 6583 ;jz short btd_2 6584 ; 16/03/2021 6585 00001A88 66F7F1 div ecx 6586 ; eax = quotient 6587 ; dl = remainder 6588 00001A8B 80C230 add dl, '0' 6589 00001A8E 8814 mov [si], dl 6590 00001A90 6621C0 and eax, eax 6591 00001A93 7405 jz short btd_1 6592 ;btd_1: 6593 00001A95 4E dec si 6594 00001A96 30D2 xor dl, dl ; 16/03/2021 6595 00001A98 EBEE jmp short btd_0 6596 ;btd_2: 6597 ;or ax, ax 6598 ;jnz short btd_1 6599 btd_1: 6600 00001A9A C3 retn 6601 6602 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6603 ; convert byte to hexadecimal number 6604 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6605 6606 byte_to_hex: ; 04/02/2019 6607 bin_to_hex: 6608 ; INPUT -> 6609 ; AL = byte (binary number) 6610 ; OUTPUT -> 6611 ; AX = hexadecimal string 6612 ; 6613 00001A9B 53 push bx 6614 00001A9C 31DB xor bx, bx 6615 00001A9E 88C3 mov bl, al 6616 00001AA0 C0EB04 shr bl, 4 6617 00001AA3 8A9F[A83C] mov bl, [bx+hexchrs] 6618 00001AA7 86D8 xchg bl, al 6619 00001AA9 80E30F and bl, 0Fh 6620 00001AAC 8AA7[A83C] mov ah, [bx+hexchrs] 6621 00001AB0 5B pop bx 6622 00001AB1 C3 retn 6623 6624 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6625 ; read & write characters 6626 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6627 6628 rw_char: 6629 ; OUTPUT -> DS:SI = Entered String (ASCIIZ) 6630 00001AB2 BE[D151] mov si, StrVolumeName 6631 00001AB5 BB0700 mov bx, 7 6632 00001AB8 B403 mov ah, 3 6633 00001ABA CD10 int 10h 6634 00001ABC 8916[B851] mov [Cursor_Pos], dx 6635 read_next_char: 6636 00001AC0 30E4 xor ah, ah 6637 00001AC2 CD16 int 16h 6638 00001AC4 20C0 and al, al 6639 00001AC6 7439 jz short loc_arrow 6640 00001AC8 3CE0 cmp al, 0E0h 6641 00001ACA 7435 je short loc_arrow 6642 00001ACC 3C08 cmp al, 8 6643 00001ACE 753D jne short char_return 6644 loc_back: 6645 00001AD0 B403 mov ah, 3 6646 00001AD2 CD10 int 10h 6647 00001AD4 3A16[B851] cmp dl, byte [Cursor_Pos] 6648 00001AD8 761F jna short loc_beep 6649 prev_column: 6650 00001ADA FECA dec dl 6651 set_cursor_pos: 6652 00001ADC B402 mov ah, 2 6653 00001ADE CD10 int 10h 6654 00001AE0 88D3 mov bl, dl 6655 00001AE2 2A1E[B851] sub bl, byte [Cursor_Pos] 6656 00001AE6 B90100 mov cx, 1 6657 00001AE9 B409 mov ah, 9 6658 00001AEB B020 mov al, 20h 6659 00001AED 8800 mov [si+bx], al 6660 loc_write_it: 6661 00001AEF B307 mov bl, 7 6662 00001AF1 CD10 int 10h 6663 00001AF3 8B16[B851] mov dx, [Cursor_Pos] 6664 00001AF7 EBC7 jmp short read_next_char 6665 loc_beep: 6666 00001AF9 B40E mov ah, 0Eh 6667 00001AFB B007 mov al, 7 6668 00001AFD CD10 int 10h 6669 00001AFF EBBF jmp short read_next_char 6670 loc_arrow: 6671 00001B01 80FC4B cmp ah, 4Bh 6672 00001B04 74CA je short loc_back 6673 00001B06 80FC53 cmp ah, 53h 6674 00001B09 74C5 je short loc_back 6675 00001B0B EBB3 jmp short read_next_char 6676 char_return: 6677 00001B0D B403 mov ah, 3 6678 00001B0F CD10 int 10h 6679 check_char_type: 6680 00001B11 3C20 cmp al, 20h 6681 00001B13 7229 jb short loc_escape 6682 00001B15 88D4 mov ah, dl 6683 00001B17 2A26[B851] sub ah, byte [Cursor_Pos] 6684 ;cmp ah, 10 6685 ;ja short loc_beep 6686 00001B1B 3A26[2B61] cmp ah, [vname_length] ; 05/01/2018 6687 00001B1F 73D8 jnb short loc_beep 6688 00001B21 3C7A cmp al, 'z' 6689 00001B23 779B ja short read_next_char 6690 00001B25 3C61 cmp al, 'a' 6691 00001B27 7202 jb short pass_capitalize 6692 00001B29 24DF and al, 0DFh 6693 pass_capitalize: 6694 00001B2B 88E3 mov bl, ah 6695 00001B2D 30E4 xor ah, ah 6696 00001B2F 8900 mov [si+bx], ax 6697 00001B31 B307 mov bl, 7 6698 00001B33 B40E mov ah, 0Eh 6699 00001B35 CD10 int 10h 6700 00001B37 EB87 jmp short read_next_char 6701 pass_escape: 6702 00001B39 3C0D cmp al, 0Dh ; 13 ; ENTER 6703 00001B3B 7583 jne short read_next_char 6704 ;mov ah, 0Eh 6705 ;int 10h 6706 ;mov al, 0Ah 6707 ;int 10h 6708 00001B3D C3 retn 6709 loc_escape: 6710 00001B3E 3C1B cmp al, 1Bh ; 27 ; ESC 6711 00001B40 75F7 jne short pass_escape 6712 00001B42 F9 stc 6713 00001B43 C3 retn 6714 6715 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6716 ; display CHS table 6717 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6718 6719 ; 09/03/2021 (fdisk4.s) 6720 display_chs_table: 6721 6722 ; 16/10/2020 6723 ; 12/10/2020 (fdisk3) 6724 ; 11/02/2019 (hdimage) 6725 6726 00001B44 06 push es 6727 00001B45 BF00B8 mov di, 0B800h 6728 00001B48 8EC7 mov es, di 6729 00001B4A BFA000 mov di, 160 ; row 1 6730 00001B4D B407 mov ah, 07h 6731 00001B4F B044 mov al, 'D' 6732 00001B51 AB stosw 6733 00001B52 B069 mov al, 'i' 6734 00001B54 AB stosw 6735 00001B55 B073 mov al, 's' 6736 00001B57 AB stosw 6737 00001B58 B06B mov al, 'k' 6738 00001B5A AB stosw 6739 00001B5B B03A mov al, ':' 6740 00001B5D AB stosw 6741 00001B5E B020 mov al, ' ' 6742 00001B60 AB stosw 6743 00001B61 B068 mov al, 'h' 6744 00001B63 AB stosw 6745 00001B64 B064 mov al, 'd' 6746 00001B66 AB stosw 6747 00001B67 A0[4665] mov al, [DrvNum] 6748 00001B6A 2C50 sub al, 80h-'0' 6749 00001B6C AB stosw 6750 00001B6D BF4001 mov di, 320 ; row 2 6751 00001B70 B95000 mov cx, 80 6752 00001B73 B82007 mov ax, 0720h 6753 00001B76 F3AB rep stosw 6754 00001B78 B150 mov cl, 80 ; row 3 6755 00001B7A B02D mov al, "-" 6756 00001B7C F3AB rep stosw 6757 ;mov cl, 19 6758 00001B7E B112 mov cl, 18 ; 16/10/2020 ; row 4 6759 00001B80 B020 mov al, 20h 6760 00001B82 F3AB rep stosw 6761 00001B84 B043 mov al, 'C' 6762 00001B86 AB stosw 6763 00001B87 B079 mov al, 'y' 6764 00001B89 AB stosw 6765 00001B8A B06C mov al, 'l' 6766 00001B8C AB stosw 6767 00001B8D B069 mov al, 'i' 6768 00001B8F AB stosw 6769 00001B90 B06E mov al, 'n' 6770 00001B92 AB stosw 6771 00001B93 B064 mov al, 'd' 6772 00001B95 AB stosw 6773 00001B96 B065 mov al, 'e' 6774 00001B98 AB stosw 6775 00001B99 B072 mov al, 'r' 6776 00001B9B AB stosw 6777 00001B9C B073 mov al, 's' 6778 00001B9E AB stosw 6779 00001B9F B03A mov al, ':' 6780 00001BA1 AB stosw 6781 00001BA2 B020 mov al, 20h 6782 00001BA4 AB stosw 6783 ;mov [cylnumpos], di 6784 6785 ; 09/03/2021 6786 ;mov ax, [cylinders] 6787 ;mov dx, [cylinders+2] ; 16/10/2020 6788 00001BA5 66A1[BE3C] mov eax, [cylinders] 6789 6790 ;mov cl, 4 6791 ;mov ch, 07h ; color 6792 00001BA9 E86600 call write_number 6793 6794 ;mov ax, 0720h 6795 00001BAC B020 mov al, 20h ; 16/10/2020 6796 00001BAE AB stosw 6797 00001BAF AB stosw 6798 00001BB0 B048 mov al, 'H' 6799 00001BB2 AB stosw 6800 00001BB3 B065 mov al, 'e' 6801 00001BB5 AB stosw 6802 00001BB6 B061 mov al, 'a' 6803 00001BB8 AB stosw 6804 00001BB9 B064 mov al, 'd' 6805 00001BBB AB stosw 6806 00001BBC B073 mov al, 's' 6807 00001BBE AB stosw 6808 00001BBF B03A mov al, ':' 6809 00001BC1 AB stosw 6810 00001BC2 B020 mov al, 20h 6811 00001BC4 AB stosw 6812 ;mov [hednumpos], di 6813 6814 ; 09/03/2021 6815 ;mov ax, [heads] 6816 ;xor dx, dx ; 16/10/2020 6817 ; 6818 ;movzx eax, word [heads] 6819 ; eax < 65536 6820 00001BC5 A1[BC3C] mov ax, [heads] 6821 6822 ;mov cl, 2 6823 ;mov ch, 07h ; color 6824 00001BC8 E84700 call write_number 6825 6826 ;mov ax, 0720h 6827 00001BCB B020 mov al, 20h ; 16/10/2020 6828 00001BCD AB stosw 6829 00001BCE AB stosw 6830 00001BCF B053 mov al, 'S' 6831 00001BD1 AB stosw 6832 00001BD2 B065 mov al, 'e' 6833 00001BD4 AB stosw 6834 00001BD5 B063 mov al, 'c' 6835 00001BD7 AB stosw 6836 00001BD8 B074 mov al, 't' 6837 00001BDA AB stosw 6838 00001BDB B06F mov al, 'o' 6839 00001BDD AB stosw 6840 00001BDE B072 mov al, 'r' 6841 00001BE0 AB stosw 6842 00001BE1 B073 mov al, 's' 6843 00001BE3 AB stosw 6844 00001BE4 B03A mov al, ':' 6845 00001BE6 AB stosw 6846 00001BE7 B020 mov al, 20h 6847 00001BE9 AB stosw 6848 ;mov [secnumpos], di 6849 6850 ; 09/03/2021 6851 ;mov ax, [sectors] 6852 ;sub dx, dx ; 16/10/2020 6853 ; 6854 ;movzx eax, [sectors] 6855 ; eax < 65536 6856 00001BEA A1[BA3C] mov ax, [sectors] 6857 6858 ;mov cl, 2 6859 ;mov ch, 07h ; color 6860 00001BED E82200 call write_number 6861 6862 00001BF0 B92003 mov cx, 800 ; 16/10/2020 ; row 5 6863 00001BF3 29F9 sub cx, di 6864 00001BF5 D0E9 shr cl, 1 6865 ;mov cl, 22 6866 ;mov ax, 0720h 6867 00001BF7 B020 mov al, 20h ; 16/10/2020 6868 00001BF9 F3AB rep stosw 6869 6870 00001BFB B150 mov cl, 80 ; row 6 6871 00001BFD B02D mov al, "-" 6872 00001BFF F3AB rep stosw 6873 6874 00001C01 B150 mov cl, 80 ; row 7 6875 ;mov cl, 160 ; row 7, 8 6876 00001C03 B020 mov al, 20h 6877 00001C05 F3AB rep stosw 6878 6879 00001C07 BA0006 mov dx, 0600h ; DH = row, DL = 0 column 6880 00001C0A 31DB xor bx, bx ; BH = video page (0) 6881 00001C0C B402 mov ah, 02h ; set cursor position 6882 00001C0E CD10 int 10h 6883 6884 00001C10 07 pop es 6885 00001C11 C3 retn 6886 6887 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6888 ; write decimal number 6889 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6890 6891 ;write_number: 6892 ; ; 12/10/2020 6893 ; mov bx, 10 6894 ; mov si, cx 6895 ;wnum_1: 6896 ; xor dx, dx 6897 ; div bx 6898 ; push dx 6899 ; dec cl 6900 ; jnz short wnum_1 6901 ; mov cx, si 6902 ; mov ah, ch ; color (07h or 0Fh) 6903 ; xor ch, ch 6904 ;wnum_2: 6905 ; pop dx 6906 ; mov al, dl 6907 ; add al, '0' 6908 ; stosw 6909 ; loop wnum_2 6910 ; retn 6911 6912 ;write_number: 6913 ; ; 16/10/2020 6914 ; ; dx:ax = binary number 6915 ; ; di = decimal number/string location 6916 ; ; modified registers: ax, bx, cx, dx, bp, di 6917 ; mov cx, 10 6918 ; mov bp, sp 6919 ;wnum_1: 6920 ; call div32 6921 ; push bx 6922 ; and dx, dx 6923 ; jnz short wnum_1 6924 ; or ax, ax 6925 ; jnz short wnum_1 6926 ;wnum_2: 6927 ; pop ax 6928 ; add al, '0' 6929 ; mov ah, 07h ; color 6930 ; stosw 6931 ; cmp bp, sp 6932 ; ja short wnum_2 6933 ; retn 6934 6935 write_number: 6936 ; 21/03/2021 6937 ; 09/03/2021 (fdisk4.s) 6938 ; eax = binary number (must be <= 6939 ; di = decimal number/string location 6940 ; modified registers: eax, ecx, edx, bp, di 6941 00001C12 66B90A000000 mov ecx, 10 6942 00001C18 6631D2 xor edx, edx 6943 00001C1B 89E5 mov bp, sp 6944 wnum_1: 6945 00001C1D 66F7F1 div ecx 6946 00001C20 52 push dx ; <= 9 6947 ; 21/03/2021 6948 00001C21 6609C0 or eax, eax 6949 00001C24 7404 jz short wnum_2 6950 00001C26 30D2 xor dl, dl 6951 00001C28 EBF3 jmp short wnum_1 6952 wnum_2: 6953 00001C2A 58 pop ax 6954 00001C2B 0430 add al, '0' 6955 00001C2D B407 mov ah, 07h ; color 6956 00001C2F AB stosw 6957 00001C30 39E5 cmp bp, sp 6958 00001C32 77F6 ja short wnum_2 6959 00001C34 C3 retn 6960 6961 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6962 ; partition size input 6963 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6964 6965 ; 13/03/2021 6966 ; 12/03/2021 (fdisk4.s, 2TB disk partitioning) 6967 partition_size_input: 6968 ; 23/10/2020 (fdisk3.s modification on hdimage.s source code) 6969 6970 ; 13/03/2021 6971 00001C35 6631C9 xor ecx, ecx 6972 00001C38 6631D2 xor edx, edx 6973 6974 ;mov word [pSize_multiplier+2], 0 6975 00001C3B 890E[EE69] mov [pSize_multiplier+2], cx ; 0 ; 13/03/2021 6976 00001C3F C606[F369]42 mov byte [msg_psize_unit+1], 'B' 6977 00001C44 A0[F269] mov al, [pSize_unit] 6978 00001C47 3C25 cmp al, '%' 6979 00001C49 7522 jne short psu_0 6980 ; 08/02/2019 6981 ; calculate sector count for max. available sectors percentage 6982 ;mov dx, [pp_Sectors+2] ; max. available sectors 6983 ;mov ax, [pp_Sectors] ; for a new partition 6984 ;;mov dx, [total_sectors+2] 6985 ;;mov ax, [total_sectors] 6986 ;mov cx, 100 6987 ;call div32 6988 ;mov [pSize_multiplier], ax 6989 ; 29/10/2020 6990 ;mov [pSize_multiplier+2], dx 6991 ; 13/03/2021 6992 ;;mov ecx, 100 6993 ;mov cl, 100 6994 00001C4B B163 mov cl, 99 6995 00001C4D 66A1[E069] mov eax, [pp_Sectors] ; > 0 6996 00001C51 6601C8 add eax, ecx ; eax = eax + 99 6997 00001C54 80D200 adc dl, 0 6998 00001C57 FEC1 inc cl ; ecx = 100 6999 00001C59 66F7F1 div ecx 7000 00001C5C 66A3[EC69] mov [pSize_multiplier], eax ; >= 1 7001 ;xor eax, eax 7002 ;xor dl, dl 7003 7004 ;mov ah, 0 7005 ;mov [msg_psize_unit+1], ah ; 0 7006 ; 13/03/2021 7007 00001C60 882E[F369] mov [msg_psize_unit+1], ch ; 0 7008 ;mov byte [pSize_maxdigits], 2 7009 00001C64 C606[F069]03 mov byte [pSize_maxdigits], 3 ; 29/10/2020 7010 00001C69 B025 mov al, '%' 7011 00001C6B EB5D jmp short psu_6 7012 psu_0: 7013 00001C6D 3C43 cmp al, 'C' 7014 00001C6F 7517 jne short psu_1 7015 00001C71 A1[BA3C] mov ax, [sectors] 7016 00001C74 F726[BC3C] mul word [heads] 7017 00001C78 A3[EC69] mov [pSize_multiplier], ax 7018 ;;mov byte [pSize_maxdigits], 4 7019 ;; <= 65535 cylinders 7020 ;mov byte [pSize_maxdigits], 5 ; 23/10/2020 7021 ; 13/03/2021 7022 00001C7B C606[F069]06 mov byte [pSize_maxdigits], 6 ; <= 267349 cylinders 7023 7024 ;sub dh, dh 7025 00001C80 8836[F369] mov [msg_psize_unit+1], dh ; 0 7026 00001C84 B043 mov al, 'C' 7027 00001C86 EB42 jmp short psu_6 7028 psu_1: 7029 00001C88 3C47 cmp al, 'G' 7030 00001C8A 7510 jne short psu_2 7031 ;mov word [pSize_multiplier], 2*1024 7032 ;mov word [pSize_multiplier+2], 1024 7033 ; 13/03/2021 7034 00001C8C 66C706[EC69]000020- mov dword [pSize_multiplier], 1024*1024*2 7034 00001C94 00 7035 7036 ;;mov byte [pSize_maxdigits], 1 7037 ;mov byte [pSize_maxdigits], 3 ; <= 512 GB ; 23/10/2020 7038 ; 12/03/2021 7039 00001C95 C606[F069]04 mov byte [pSize_maxdigits], 4 ; <= 2048 GB 7040 00001C9A EB2E jmp short psu_6 7041 psu_2: 7042 00001C9C 3C4D cmp al, 'M' 7043 00001C9E 750D jne short psu_3 7044 00001CA0 C706[EC69]0008 mov word [pSize_multiplier], 2*1024 7045 ;mov byte [pSize_maxdigits], 4 7046 ; 13/03/2021 7047 ; <= 2097152 MB 7048 00001CA6 C606[F069]07 mov byte [pSize_maxdigits], 7 ; 23/10/2020 7049 00001CAB EB1D jmp short psu_6 7050 psu_3: 7051 00001CAD 3C4B cmp al, 'K' 7052 00001CAF 7508 jne short psu_4 7053 00001CB1 C706[EC69]0200 mov word [pSize_multiplier], 2 7054 00001CB7 EB0C jmp short psu_5 7055 psu_4: 7056 ; al = 'S' 7057 00001CB9 30E4 xor ah, ah 7058 00001CBB 8826[F369] mov [msg_psize_unit+1], ah ; 0 7059 00001CBF C706[EC69]0100 mov word [pSize_multiplier], 1 7060 psu_5: 7061 ;mov byte [pSize_maxdigits], 7 7062 ; 13/03/2021 7063 ; <= 2147483648 KB or <= 4294967296 sectors 7064 00001CC5 C606[F069]0A mov byte [pSize_maxdigits], 10 ; 23/10/2020 7065 psu_6: 7066 00001CCA A2[B04B] mov [msg_partition_size_x], al 7067 00001CCD BE[9C4B] mov si, msg_partition_size 7068 00001CD0 E8F4FC call print_msg 7069 7070 00001CD3 89E5 mov bp, sp 7071 ;xor bx, bx 7072 ;mov [pSize_temp], bx ; 0 7073 ;;mov [pSize_temp+2], bx ; 0 7074 ; 13/03/2021 7075 ;xor ebx, ebx 7076 ;mov [pSize_temp], ebx ; 0 7077 00001CD5 31DB xor bx, bx 7078 7079 00001CD7 881E[F169] mov [pSize_digitpos], bl ; 0 7080 ; bh = 0 ; video page 7081 00001CDB B403 mov ah, 3 ; get cursor pos 7082 00001CDD CD10 int 10h 7083 00001CDF 8916[B851] mov [Cursor_Pos], dx 7084 ; 09/02/2019 7085 00001CE3 B307 mov bl, 7 ; page 0, color 7 (light gray) 7086 psu_7: 7087 00001CE5 30E4 xor ah, ah 7088 00001CE7 CD16 int 16h 7089 7090 00001CE9 3C30 cmp al, '0' 7091 00001CEB 7223 jb short psu_8 7092 00001CED 3C39 cmp al, '9' 7093 00001CEF 77F4 ja short psu_7 7094 00001CF1 8A1E[F169] mov bl, [pSize_digitpos] 7095 00001CF5 3A1E[F069] cmp bl, [pSize_maxdigits] 7096 00001CF9 73EA jnb short psu_7 7097 00001CFB FE06[F169] inc byte [pSize_digitpos] 7098 00001CFF 2C30 sub al, '0' 7099 ;xor ah, ah ; 13/03/2021 (AH will not be used) 7100 00001D01 50 push ax ; (*) 7101 00001D02 0430 add al, '0' 7102 00001D04 B40E mov ah, 0Eh ; write char as tty 7103 ;mov bx, 7 ; page 0, color 7 (light gray) 7104 00001D06 CD10 int 10h 7105 00001D08 EBDB jmp short psu_7 7106 7107 psu_8esc: 7108 ; 29/10/2020 (ESCape) 7109 00001D0A 89EC mov sp, bp ; clean stack 7110 7111 00001D0C 08C0 or al, al ; zf = 0 7112 00001D0E F9 stc 7113 00001D0F C3 retn 7114 psu_8: 7115 00001D10 20C0 and al, al 7116 00001D12 0F848300 jz psu_15 ; check for left arrow key 7117 00001D16 3C1B cmp al, 27 7118 00001D18 74F0 je short psu_8esc ; ESCAPE key ; 29/10/2020 7119 00001D1A 7777 ja psu_14 ; check for left arrow key 7120 00001D1C 3C0D cmp al, 13 7121 ;je short psu_9 ; ENTER key 7122 00001D1E 723D jb short psu_11 ; check for backspace key 7123 ;jmp short psu_7 7124 00001D20 77C3 ja short psu_7 7125 psu_9: 7126 ; 13/03/2021 7127 ;xor ax, ax 7128 ;mov [pSize_temp+2], ax ; 0 ; 08/02/2019 7129 7130 ;cmp byte [pSize_digitpos], al ; 0 7131 ;jna psu_16 7132 ; 13/03/2021 7133 00001D22 383E[F169] cmp byte [pSize_digitpos], bh ; 0 7134 00001D26 767E jna psu_16 7135 7136 ;xor bh, bh 7137 00001D28 8A1E[F169] mov bl, [pSize_digitpos] 7138 00001D2C FECB dec bl 7139 00001D2E D0E3 shl bl, 1 7140 00001D30 01E3 add bx, sp 7141 ;mov ax, [bx] 7142 ;mov [pSize_temp], ax 7143 ;;mov word [pSize_temp+2], 0 7144 ; 13/03/2021 7145 00001D32 8A0F mov cl, [bx] 7146 00001D34 66890E[E869] mov [pSize_temp], ecx 7147 ; 13/03/2021 7148 ;mov cx, 10 7149 00001D39 B10A mov cl, 10 7150 psu_10: 7151 00001D3B FE0E[F169] dec byte [pSize_digitpos] 7152 00001D3F 7465 jz short psu_16 7153 7154 ;mov ax, [pSize_temp] 7155 ;mov dx, [pSize_temp+2] 7156 ;;mov cx, 10 7157 ;call mul32 7158 ;;mov [pSize_temp], ax 7159 ;;mov [pSize_temp+2], dx 7160 ; 13/03/2021 7161 00001D41 66A1[E869] mov eax, [pSize_temp] 7162 00001D45 66F7E1 mul ecx ; * 10 7163 ;mov [pSize_temp], eax 7164 7165 ;xor bh, bh 7166 00001D48 8A1E[F169] mov bl, [pSize_digitpos] 7167 00001D4C FECB dec bl 7168 00001D4E D0E3 shl bl, 1 7169 00001D50 01E3 add bx, sp ; (*) 7170 ;mov ax, [bx] 7171 ;add [pSize_temp], ax 7172 ;adc word [pSize_temp+2], 0 7173 7174 ;add ax, [bx] 7175 ;adc dx, 0 7176 ; 13/03/2021 7177 00001D52 8A0F mov cl, [bx] 7178 00001D54 6601C8 add eax, ecx 7179 7180 ;mov [pSize_temp], ax 7181 ;mov [pSize_temp+2], dx 7182 ; 13/03/2021 7183 00001D57 66A3[E869] mov [pSize_temp], eax 7184 7185 00001D5B EBDE jmp short psu_10 7186 7187 ; Left arrow, backspace, DEL key checking 7188 psu_11: 7189 00001D5D 3C08 cmp al, 8 ; backspace key 7190 00001D5F 7584 jne psu_7 7191 psu_12: 7192 ;; bh = 0 ; video page 7193 ;mov ah, 3 ; get cursor pos 7194 ;int 10h 7195 ;cmp dl, [Cursor_Pos] 7196 ;jna short psu_13 7197 ;dec dl 7198 ;dec byte [pSize_digitpos] 7199 7200 ; 08/02/2019 7201 00001D61 8B16[B851] mov dx, [Cursor_Pos] 7202 00001D65 8A1E[F169] mov bl, [pSize_digitpos] 7203 00001D69 20DB and bl, bl 7204 00001D6B 741D jz short psu_13 7205 7206 00001D6D FECB dec bl 7207 00001D6F 881E[F169] mov [pSize_digitpos], bl 7208 7209 00001D73 00DA add dl, bl 7210 7211 ; bh = 0 ; video page 7212 00001D75 B402 mov ah, 2 ; set cursor pos 7213 00001D77 CD10 int 10h 7214 ;mov bl, dl 7215 ;sub bl, [Cursor_Pos] 7216 00001D79 B90100 mov cx, 1 7217 00001D7C B409 mov ah, 9 ; write char at current curs pos 7218 00001D7E B020 mov al, 20h ; space (blank) 7219 00001D80 8800 mov [si+bx], al 7220 ; bh = 0 ; video page 7221 00001D82 B307 mov bl, 7 ; attribute/color (light gray) 7222 00001D84 CD10 int 10h 7223 7224 ; 09/02/2019 7225 00001D86 58 pop ax ; remove last digit on top of stack 7226 ; set sp to correct position for BX (*) 7227 00001D87 E95BFF jmp psu_7 7228 psu_13: 7229 00001D8A B40E mov ah, 0Eh 7230 00001D8C B007 mov al, 7 7231 ;mov bx, 7 7232 00001D8E CD10 int 10h 7233 00001D90 E952FF jmp psu_7 7234 psu_14: 7235 00001D93 3CE0 cmp al, 0E0h 7236 00001D95 0F854CFF jne psu_7 7237 psu_15: 7238 00001D99 80FC4B cmp ah, 4Bh ; left arrow 7239 00001D9C 74C3 je short psu_12 7240 00001D9E 80FC53 cmp ah, 53h ; DEL key (backspace) 7241 00001DA1 74BE je short psu_12 7242 00001DA3 E93FFF jmp psu_7 7243 psu_16: 7244 00001DA6 89EC mov sp, bp 7245 7246 ; 29/10/2020 7247 00001DA8 803E[F269]25 cmp byte [pSize_unit], '%' 7248 00001DAD 751E jne short psu_23 7249 7250 00001DAF B86400 mov ax, 100 7251 00001DB2 3906[E869] cmp word [pSize_temp], ax ; 100 ; % limit 7252 00001DB6 7624 jna short psu_17 7253 00001DB8 A3[E869] mov word [pSize_temp], ax 7254 7255 ; (re)set asciiz number string to '100' 7256 7257 00001DBB 28FF sub bh, bh ; 0 ; video page 0 7258 00001DBD 8B16[B851] mov dx, [Cursor_Pos] 7259 00001DC1 B402 mov ah, 2 ; set cursor pos 7260 00001DC3 CD10 int 10h 7261 7262 00001DC5 BE[4265] mov si, msg_100 7263 00001DC8 E8FCFB call print_msg 7264 7265 00001DCB EB0F jmp short psu_17 7266 psu_23: 7267 00001DCD 803E[F269]53 cmp byte [pSize_unit], 'S' 7268 00001DD2 7508 jne short psu_17 7269 7270 00001DD4 BE[2061] mov si, msg_sectors_crlf 7271 00001DD7 E8EDFB call print_msg 7272 ;xor bx, bx 7273 00001DDA EB33 jmp short psu_18 7274 psu_17: 7275 00001DDC BE[F269] mov si, msg_psize_unit 7276 00001DDF E8E5FB call print_msg 7277 7278 00001DE2 BE[7452] mov si, CRLF 7279 00001DE5 E8DFFB call print_msg 7280 7281 ; 13/03/2021 7282 00001DE8 66A1[E869] mov eax, [pSize_temp] 7283 00001DEC 6621C0 and eax, eax 7284 00001DEF 7422 jz short psu_21 ; 0%, ZERO ! 7285 7286 00001DF1 668B16[EC69] mov edx, [pSize_multiplier] 7287 7288 ; 29/10/2020 7289 00001DF6 803E[F269]25 cmp byte [pSize_unit], '%' 7290 00001DFB 7512 jne short psu_18 7291 7292 ;mov cx, [pSize_temp] 7293 ; 7294 ;and cx, cx 7295 ;jz short psu_21 ; 0%, ZERO ! 7296 7297 ; 13/03/2021 7298 ;mov ax, [pSize_temp] 7299 ;and ax, ax 7300 ;jz short psu_21 ; 0%, ZERO ! 7301 7302 ;cmp cx, 100 7303 ;jna short psu_24 7304 ; 13/03/2021 7305 ;cmp eax, 100 7306 00001DFD 83F864 cmp ax, 100 7307 00001E00 720D jb short psu_18 ; < 100 7308 00001E02 7403 je short psu_19 ; = 100 7309 7310 ; show 100% for 1 second (for >100%) 7311 00001E04 E80E00 call wait1second ; 29/10/2020 7312 ;mov cx, 100 7313 psu_19: 7314 ; 13/03/2021 7315 00001E07 66A1[E069] mov eax, [pp_Sectors] ; 100% 7316 00001E0B 6631D2 xor edx, edx 7317 00001E0E C3 retn 7318 7319 ;psu_24: 7320 ;mov ax, [pSize_multiplier] 7321 ;mov dx, [pSize_multiplier+2] 7322 ; 7323 ;;mov cx, [pSize_temp] 7324 ;;and cx, cx 7325 ;;jz short psu_21 ; 0%, ZERO ! 7326 ; 7327 ;jmp mul32 7328 psu_18: 7329 ; 13/03/2021 7330 ; eax = [pSize_temp] 7331 ; edx = [pSize_multiplier] 7332 00001E0F 66F7E2 mul edx 7333 ; eax = partition size 7334 ; edx = 0 7335 00001E12 C3 retn 7336 ;psu_18: 7337 ;mov ax, [pSize_temp] 7338 ;mov dx, [pSize_temp+2] 7339 ;mov cx, ax 7340 ;or cx, dx 7341 ;;jz short psu_20 7342 ;jz short psu_21 ; 08/02/2019 7343 ; 13/03/2021 7344 ;mov eax, [pSize_temp] 7345 ;or eax, eax 7346 ;jz short psu_21 7347 7348 ;mov cx, [pSize_multiplier] 7349 ;cmp byte [pSize_unit], 'C' 7350 ;je short psu_20 ; 09/02/2019 7351 ;;jne short psu_19 7352 ;;call mul32 7353 ;; 08/02/2019 7354 ;; dx:ax = requested partition size in sectors 7355 ;;retn 7356 ;psu_19: 7357 ;;mov cx, [pSize_multiplier] 7358 ;cmp cx, 1 7359 ;;jna short psu_20 7360 ;ja short psu_19 7361 ;; 09/02/2019 7362 ;xor bx, bx 7363 ;retn 7364 7365 ; 13/03/2021 7366 ; edx = [pSize_multiplier] 7367 ;mul edx 7368 ; eax = partition size 7369 ; edx = 0 7370 ;retn 7371 ;psu_19: 7372 ; call mul32 7373 ; ;and bx, bx 7374 ; ;jnz short psu_22 ; 09/02/2019 7375 ; mov cx, [pSize_multiplier+2] 7376 ; or cx, cx 7377 ; ;jz short psu_20 7378 ; jz short psu_22 ; 09/02/2019 7379 ;psu_20: 7380 ; ;call mul32 7381 ; ;retn 7382 ; jmp mul32 ; 23/10/2020 7383 7384 psu_21: 7385 ; 13/03/2021 7386 ;xor edx, edx 7387 ; zf = 1 ; 29/10/2020 7388 00001E13 F9 stc 7389 psu_22: 7390 00001E14 C3 retn 7391 7392 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7393 ; wait for 1 second 7394 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7395 7396 ; 29/10/2020 7397 wait1second: 7398 00001E15 B402 mov ah, 2 7399 00001E17 CD1A int 1Ah ; get time of day 7400 00001E19 720C jc short w1s_2 7401 w1s_1: 7402 00001E1B 52 push dx 7403 00001E1C B402 mov ah, 2 7404 00001E1E CD1A int 1Ah ; get time of day 7405 00001E20 58 pop ax 7406 00001E21 7204 jc short w1s_2 7407 00001E23 38E6 cmp dh, ah 7408 00001E25 74F4 je short w1s_1 ; same second 7409 w1s_2: 7410 00001E27 C3 retn 7411 7412 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7413 ; partition type input 7414 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7415 7416 partition_type_input: 7417 00001E28 BE[B64B] mov si, msg_partition_type 7418 00001E2B E899FB call print_msg 7419 7420 00001E2E 31DB xor bx, bx 7421 7422 00001E30 881E[026A] mov [pType_pos], bl ; 0 7423 00001E34 891E[036A] mov [pType_num], bx ; 0 7424 7425 ; bh = 0 ; video page 7426 00001E38 B403 mov ah, 3 ; get cursor pos 7427 00001E3A CD10 int 10h 7428 00001E3C 8916[B851] mov [Cursor_Pos], dx 7429 ptu_0: 7430 00001E40 30E4 xor ah, ah 7431 00001E42 CD16 int 16h 7432 7433 00001E44 803E[026A]01 cmp byte [pType_pos], 1 7434 00001E49 773F ja short ptu_5 7435 7436 00001E4B 3C30 cmp al, '0' 7437 00001E4D 723B jb short ptu_5 7438 00001E4F 3C39 cmp al, '9' 7439 00001E51 7707 ja short ptu_1 7440 00001E53 88C4 mov ah, al 7441 00001E55 80EC30 sub ah, '0' 7442 00001E58 EB13 jmp short ptu_2 7443 ptu_1: 7444 00001E5A 3CE0 cmp al, 0E0h 7445 00001E5C 7473 je short ptu_9 7446 7447 00001E5E 24DF and al, 0DFh 7448 00001E60 3C41 cmp al, 'A' 7449 00001E62 72DC jb short ptu_0 7450 00001E64 3C46 cmp al, 'F' 7451 00001E66 77D8 ja short ptu_0 7452 00001E68 88C4 mov ah, al 7453 00001E6A 80EC37 sub ah, 'A'-10 7454 ptu_2: 7455 00001E6D 803E[026A]00 cmp byte [pType_pos], 0 7456 00001E72 7606 jna short ptu_3 7457 00001E74 8826[046A] mov [pType_num+1], ah 7458 00001E78 EB04 jmp short ptu_4 7459 ptu_3: 7460 00001E7A 8826[036A] mov [pType_num], ah 7461 ptu_4: 7462 00001E7E B40E mov ah, 0Eh 7463 00001E80 B307 mov bl, 7 7464 00001E82 CD10 int 10h 7465 7466 00001E84 FE06[026A] inc byte [pType_pos] 7467 7468 00001E88 EBB6 jmp short ptu_0 7469 ptu_5: 7470 00001E8A 20C0 and al, al 7471 00001E8C 7443 jz short ptu_9 ; check for left arrow key 7472 00001E8E 3C1B cmp al, 27 7473 00001E90 744C je short ptu_10 ; ESCAPE key 7474 00001E92 77AC ja short ptu_0 7475 00001E94 3C0D cmp al, 13 7476 00001E96 744A je short ptu_11 ; ENTER key 7477 00001E98 77A6 ja short ptu_0 7478 ptu_6: 7479 ; Left arrow, backspace, DEL key checking 7480 7481 00001E9A 3C08 cmp al, 8 ; backspace key 7482 00001E9C 75A2 jne short ptu_0 7483 ptu_7: 7484 ; bh = 0 ; video page 7485 00001E9E B403 mov ah, 3 ; get cursor pos 7486 00001EA0 CD10 int 10h 7487 00001EA2 3A16[B851] cmp dl, [Cursor_Pos] 7488 00001EA6 7620 jna short ptu_8 7489 00001EA8 FECA dec dl 7490 00001EAA FE0E[026A] dec byte [pType_pos] 7491 ; bh = 0 ; video page 7492 00001EAE B402 mov ah, 2 ; set cursor pos 7493 00001EB0 CD10 int 10h 7494 00001EB2 88D3 mov bl, dl 7495 00001EB4 2A1E[B851] sub bl, [Cursor_Pos] 7496 00001EB8 B90100 mov cx, 1 7497 00001EBB B409 mov ah, 9 ; write char at current curs pos 7498 00001EBD B020 mov al, 20h ; space (blank) 7499 00001EBF 8800 mov [si+bx], al 7500 ; bh = 0 ; video page 7501 00001EC1 B307 mov bl, 7 ; attribute/color (light gray) 7502 00001EC3 CD10 int 10h 7503 00001EC5 E978FF jmp ptu_0 7504 ptu_8: 7505 00001EC8 B40E mov ah, 0Eh 7506 00001ECA B007 mov al, 7 7507 00001ECC CD10 int 10h 7508 00001ECE E96FFF jmp ptu_0 7509 ptu_9: 7510 00001ED1 80FC4B cmp ah, 4Bh ; left arrow 7511 00001ED4 74C8 je short ptu_7 7512 00001ED6 80FC53 cmp ah, 53h ; DEL key (backspace) 7513 00001ED9 74C3 je short ptu_7 7514 00001EDB E962FF jmp ptu_0 7515 7516 ptu_10: ; ESCAPE 7517 ;mov al, 0 7518 ; 29/10/2020 7519 00001EDE 28C0 sub al, al ; 0 7520 ; partition type is 0 (none) 7521 00001EE0 EB12 jmp short ptu_12 7522 ptu_11: ; ENTER 7523 00001EE2 A0[036A] mov al, [pType_num] 7524 00001EE5 803E[026A]01 cmp byte [pType_pos], 1 7525 00001EEA 7608 jna short ptu_12 7526 00001EEC B410 mov ah, 16 7527 00001EEE F6E4 mul ah 7528 00001EF0 0206[046A] add al, [pType_num+1] 7529 ptu_12: 7530 00001EF4 50 push ax 7531 00001EF5 E8A3FB call bin_to_hex 7532 00001EF8 A3[CC4B] mov [msg_ptype_num], ax 7533 ; bh = 0 ; video page 7534 00001EFB B402 mov ah, 2 ; set cursor pos 7535 00001EFD 8B16[B851] mov dx, [Cursor_Pos] 7536 00001F01 CD10 int 10h 7537 00001F03 BE[CC4B] mov si, msg_ptype_num 7538 00001F06 E8BEFA call print_msg 7539 00001F09 58 pop ax 7540 00001F0A C3 retn 7541 7542 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7543 ; show selected partition 7544 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7545 7546 ; 20/03/2021 (fdisk4.s) 7547 show_selected_partition: 7548 ; INPUT -> 7549 ; DS:SI = Partition table row address 7550 7551 ; 2019 - 2020 (hdimage.s) 7552 ;pt_s_offset equ 7 7553 ;pt_bh_offset equ 11 7554 ;pt_bs_offset equ 15 7555 ;pt_bc_offset equ 19 7556 ;pt_fs_offset equ 23 7557 ;pt_eh_offset equ 27 7558 ;pt_es_offset equ 31 7559 ;pt_ec_offset equ 35 7560 ;pt_rs_offset equ 41 7561 ;pt_ts_offset equ 52 7562 ;pt_fsn_offset equ 63 7563 7564 ; 24/10/2020 (fdisk3.s) 7565 pt_s_offset equ 6 7566 pt_bh_offset equ 10 7567 pt_bs_offset equ 14 7568 pt_bc_offset equ 18 7569 pt_fs_offset equ 22 7570 pt_eh_offset equ 26 7571 pt_es_offset equ 30 7572 pt_ec_offset equ 34 7573 pt_rs_offset equ 40 7574 pt_ts_offset equ 51 7575 pt_fsn_offset equ 63 7576 7577 ; 20/03/2021 7578 00001F0B 6629C0 sub eax, eax 7579 7580 ; clear screen 7581 ;mov ax, 3 ; set video mode to 03h (80x25 text) 7582 00001F0E B003 mov al, 3 ; 20/03/2021 7583 00001F10 CD10 int 10h 7584 7585 00001F12 89F0 mov ax, si 7586 00001F14 2D[AE54] sub ax, MasterBootBuff + pTableOffset ; + 446 7587 00001F17 C0E804 shr al, 4 ; from offset to partition number 7588 00001F1A 0431 add al, '1' ; 1 based partition number (chr) 7589 ; Write partition number to the header location 7590 00001F1C A2[8C4D] mov [msg_selected_partition+43], al ; '1' to '4' 7591 7592 ; Partition number will be used at formatting stage 7593 00001F1F A2[5B50] mov [partition_num_chr], al ; number + '0' 7594 7595 00001F22 B268 mov dl, 'h' 7596 00001F24 8A04 mov al, [si+ptBootable] 7597 00001F26 E872FB call bin_to_hex 7598 00001F29 A3[A74E] mov [pt_row+pt_s_offset], ax 7599 00001F2C 8816[A94E] mov [pt_row+pt_s_offset+2], dl ; 'h' 7600 00001F30 8A4401 mov al, [si+ptBeginHead] 7601 00001F33 E865FB call bin_to_hex 7602 00001F36 A3[AB4E] mov [pt_row+pt_bh_offset], ax 7603 00001F39 8816[AD4E] mov [pt_row+pt_bh_offset+2], dl ; 'h' 7604 00001F3D 8A4402 mov al, [si+ptBeginSector] 7605 00001F40 E858FB call bin_to_hex 7606 00001F43 A3[AF4E] mov [pt_row+pt_bs_offset], ax 7607 00001F46 8816[B14E] mov [pt_row+pt_bs_offset+2], dl ; 'h' 7608 00001F4A 8A4403 mov al, [si+ptBeginCylinder] 7609 00001F4D E84BFB call bin_to_hex 7610 00001F50 A3[B34E] mov [pt_row+pt_bc_offset], ax 7611 00001F53 8816[B54E] mov [pt_row+pt_bc_offset+2], dl ; 'h' 7612 00001F57 8A4404 mov al, [si+ptFileSystemID] 7613 ; Partition type will be used at formatting stage 7614 00001F5A A2[E669] mov [pp_type_user], al 7615 00001F5D E83BFB call bin_to_hex 7616 00001F60 A3[B74E] mov [pt_row+pt_fs_offset], ax 7617 00001F63 8816[B94E] mov [pt_row+pt_fs_offset+2], dl ; 'h' 7618 00001F67 8A4405 mov al, [si+ptEndHead] 7619 00001F6A E82EFB call bin_to_hex 7620 00001F6D A3[BB4E] mov [pt_row+pt_eh_offset], ax 7621 00001F70 8816[BD4E] mov [pt_row+pt_eh_offset+2], dl ; 'h' 7622 00001F74 8A4406 mov al, [si+ptEndSector] 7623 00001F77 E821FB call bin_to_hex 7624 00001F7A A3[BF4E] mov [pt_row+pt_es_offset], ax 7625 00001F7D 8816[C14E] mov [pt_row+pt_es_offset+2], dl ; 'h' 7626 00001F81 8A4407 mov al, [si+ptEndCylinder] 7627 00001F84 E814FB call bin_to_hex 7628 00001F87 A3[C34E] mov [pt_row+pt_ec_offset], ax 7629 00001F8A 8816[C54E] mov [pt_row+pt_ec_offset+2], dl ; 'h' 7630 00001F8E 8A4408 mov al, [si+ptStartSector] 7631 00001F91 E807FB call bin_to_hex 7632 00001F94 A3[CF4E] mov [pt_row+pt_rs_offset+6], ax 7633 00001F97 8816[D14E] mov [pt_row+pt_rs_offset+8], dl ; 'h' 7634 00001F9B 8A4409 mov al, [si+ptStartSector+1] 7635 00001F9E E8FAFA call bin_to_hex 7636 00001FA1 A3[CD4E] mov [pt_row+pt_rs_offset+4], ax 7637 00001FA4 8A440A mov al, [si+ptStartSector+2] 7638 00001FA7 E8F1FA call bin_to_hex 7639 00001FAA A3[CB4E] mov [pt_row+pt_rs_offset+2], ax 7640 00001FAD 8A440B mov al, [si+ptStartSector+3] 7641 00001FB0 E8E8FA call bin_to_hex 7642 00001FB3 A3[C94E] mov [pt_row+pt_rs_offset], ax 7643 00001FB6 8A440C mov al, [si+ptSectors] 7644 00001FB9 E8DFFA call bin_to_hex 7645 00001FBC A3[DA4E] mov [pt_row+pt_ts_offset+6], ax 7646 00001FBF 8816[DC4E] mov [pt_row+pt_ts_offset+8], dl ; 'h' 7647 00001FC3 8A440D mov al, [si+ptSectors+1] 7648 00001FC6 E8D2FA call bin_to_hex 7649 00001FC9 A3[D84E] mov [pt_row+pt_ts_offset+4], ax 7650 00001FCC 8A440E mov al, [si+ptSectors+2] 7651 00001FCF E8C9FA call bin_to_hex 7652 00001FD2 A3[D64E] mov [pt_row+pt_ts_offset+2], ax 7653 00001FD5 8A440F mov al, [si+ptSectors+3] 7654 00001FD8 E8C0FA call bin_to_hex 7655 00001FDB A3[D44E] mov [pt_row+pt_ts_offset], ax 7656 7657 00001FDE 8A4404 mov al, [si+ptFileSystemID] 7658 00001FE1 BF[DA3D] mov di, valid_partitions 7659 00001FE4 B91300 mov cx, 19 7660 00001FE7 F2AE repnz scasb 7661 00001FE9 7405 jz short ssp_1 7662 00001FEB B8[CC3D] mov ax, FS_OTHERS 7663 00001FEE EB0C jmp short ssp_2 7664 ssp_1: 7665 00001FF0 81EF[DB3D] sub di, valid_partitions + 1 7666 00001FF4 B80E00 mov ax, 14 7667 00001FF7 F7E7 mul di 7668 00001FF9 05[C23C] add ax, FileSys_Names 7669 ssp_2: 7670 00001FFC 96 xchg ax, si 7671 00001FFD B107 mov cl, 7 7672 00001FFF BF[E04E] mov di, pt_row + pt_fsn_offset 7673 00002002 F3A5 rep movsw 7674 00002004 89C7 mov di, ax ; partition table row address 7675 7676 00002006 BE[614D] mov si, msg_selected_partition 7677 00002009 E8BBF9 call print_msg 7678 7679 0000200C BE[424F] mov si, msg_boot_indicator 7680 0000200F E8B5F9 call print_msg 7681 00002012 BE[AF59] mov si, msg_YES 7682 00002015 F60580 test byte [di+ptBootable], 80h 7683 00002018 7503 jnz short ssp_3 7684 0000201A BE[B559] mov si, msg_NO 7685 ssp_3: 7686 0000201D E8A7F9 call print_msg 7687 7688 00002020 BE[5A4F] mov si, msg_starting_head 7689 00002023 E8A1F9 call print_msg 7690 00002026 8A4501 mov al, [di+ptBeginHead] 7691 00002029 E8AD00 call write_byte_decimal 7692 0000202C E898F9 call print_msg 7693 0000202F BE[724F] mov si, msg_starting_sector 7694 00002032 E892F9 call print_msg 7695 00002035 8A4502 mov al, [di+ptBeginSector] 7696 00002038 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 7697 0000203A 243F and al, 3Fh ; sector number, 1 to 63 7698 0000203C E89A00 call write_byte_decimal 7699 0000203F E885F9 call print_msg 7700 00002042 BE[8A4F] mov si, msg_starting_cylinder 7701 00002045 E87FF9 call print_msg 7702 00002048 8A4503 mov al, [di+ptBeginCylinder] ; bits 0to7 of cyl 7703 0000204B C0EA06 shr dl, 6 ; bits 8&9 of cyl 7704 0000204E 88D4 mov ah, dl 7705 ;xor dx, dx 7706 ; 20/03/2021 7707 ; eax = binary number 7708 ; 06/11/2020 7709 00002050 BE[FF69] mov si, msg_partition_sectors + 10 ; max. 11 digits 7710 ; dx_ax: binary number 7711 00002053 E82AFA call bin_to_decimal 7712 ; ds:si = decimal number text address 7713 00002056 E86EF9 call print_msg 7714 00002059 BE[A24F] mov si, msg_system_id 7715 0000205C E868F9 call print_msg 7716 ; Write file system name (again, copy) 7717 0000205F BE[E04E] mov si, pt_row + pt_fsn_offset 7718 ;mov cx, 14 7719 00002062 B10E mov cl, 14 7720 00002064 B40E mov ah, 0Eh ; write tty 7721 00002066 BB0700 mov bx, 7 7722 ssp_4: 7723 00002069 AC lodsb 7724 0000206A CD10 int 10h 7725 0000206C E2FB loop ssp_4 7726 7727 0000206E BE[BA4F] mov si, msg_ending_head 7728 00002071 E853F9 call print_msg 7729 00002074 8A4505 mov al, [di+ptEndHead] 7730 00002077 E85F00 call write_byte_decimal 7731 0000207A E84AF9 call print_msg 7732 0000207D BE[D24F] mov si, msg_ending_sector 7733 00002080 E844F9 call print_msg 7734 00002083 8A4506 mov al, [di+ptEndSector] 7735 00002086 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 7736 00002088 243F and al, 3Fh ; sector number, 1 to 63 7737 0000208A E84C00 call write_byte_decimal 7738 0000208D E837F9 call print_msg 7739 00002090 BE[EA4F] mov si, msg_ending_cylinder 7740 00002093 E831F9 call print_msg 7741 00002096 8A4507 mov al, [di+ptEndCylinder] ; bits 0to7 of cyl 7742 00002099 C0EA06 shr dl, 6 ; bits 8&9 of cyl 7743 0000209C 88D4 mov ah, dl 7744 ;xor dx, dx 7745 ; 20/03/2021 7746 ; eax = binary number 7747 ; 06/11/2020 7748 0000209E BE[FF69] mov si, msg_partition_sectors + 10 ; max. 11 digits 7749 ; dx_ax: binary number 7750 000020A1 E8DCF9 call bin_to_decimal 7751 ; ds:si = decimal number text address 7752 000020A4 E820F9 call print_msg 7753 7754 000020A7 BE[0250] mov si, msg_relative_sectors 7755 000020AA E81AF9 call print_msg 7756 ;mov ax, [di+ptStartSector] 7757 ;mov dx, [di+ptStartSector+2] 7758 ; 20/03/2021 7759 000020AD 668B4508 mov eax, [di+ptStartSector] 7760 7761 ;;mov si, msg_partition_sectors + 7 ; max. 8 digits 7762 ;mov si, reserved_bytes + 10 ; max. 11 digits 7763 ; 06/11/2020 7764 000020B1 BE[FF69] mov si, msg_partition_sectors + 10 ; max. 11 digits 7765 ; eax = binary number ; 20/03/2021 7766 000020B4 E8C9F9 call bin_to_decimal 7767 000020B7 E80DF9 call print_msg 7768 7769 000020BA BE[1C50] mov si, msg_total_sectors 7770 000020BD E807F9 call print_msg 7771 ;mov ax, [di+ptSectors] 7772 ;mov dx, [di+ptSectors+2] 7773 ; 20/03/2021 7774 000020C0 668B450C mov eax, [di+ptSectors] 7775 7776 ;;mov si, msg_partition_sectors + 7 ; max. 8 digits 7777 ;mov si, reserved_bytes + 10 ; max. 11 digits 7778 ; 06/11/2020 7779 000020C4 BE[FF69] mov si, msg_partition_sectors + 10 ; max. 11 digits 7780 ; eax = binary number ; 20/03/2021 7781 000020C7 E8B6F9 call bin_to_decimal 7782 000020CA E8FAF8 call print_msg 7783 7784 ; 24/02/2019 7785 000020CD BE[7452] mov si, CRLF 7786 000020D0 E8F4F8 call print_msg 7787 7788 000020D3 89FE mov si, di ; partition table row address 7789 7790 ; 20/03/2021 7791 ; (clear hw of eax) 7792 000020D5 6631C0 xor eax, eax 7793 7794 000020D8 C3 retn 7795 7796 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7797 ; write byte as descimal number 7798 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7799 7800 write_byte_decimal: 7801 ; INPUT -> 7802 ; AL = binary number 7803 ; OUTPUT -> 7804 ; DS:SI = decimal number text address 7805 ; (ASCIIZ string) 7806 ; 7807 ; (SI, AX, CX will be modified) 7808 7809 ;mov si, msg_partition_sectors + 8 ; max. 8 digits 7810 ; 06/11/2020 7811 000020D9 BE[006A] mov si, msg_partition_sectors + 11 ; max. 11 digits 7812 000020DC B10A mov cl, 10 7813 wbd_loop: 7814 000020DE 4E dec si 7815 000020DF 30E4 xor ah, ah 7816 000020E1 F6F1 div cl 7817 000020E3 80C430 add ah, '0' 7818 000020E6 8824 mov [si], ah 7819 000020E8 20C0 and al, al 7820 000020EA 75F2 jnz short wbd_loop 7821 000020EC C3 retn 7822 7823 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7824 ; init (MBR) partition table 7825 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7826 ; 16/10/2020 7827 7828 ; 09/03/2021 7829 ; 03/02/2019 7830 init_partition_table: 7831 7832 ; INPUT -> none 7833 ; OUTPUT -> none 7834 7835 ; 15/10/2020 7836 ; (If a partition row contains invalid/wrong/defective parameters) 7837 ; (it's active partition flag/byte will be 0FFh, an invalid value!) 7838 7839 ; 12/02/2019 7840 ;cmp word [MBIDCode], 0AA55h 7841 ;jne ipt_stc ; invalid 7842 7843 ; 15/02/2019 7844 ; clear primary partition table structure/list 7845 7846 000020ED BF[8E6C] mov di, part_table_boot_ind 7847 ;mov cx, 36 ; 18*4 = 72 bytes 7848 ; 05/11/2020 7849 000020F0 B92C00 mov cx, 44 ; 22*4 = 88 bytes 7850 ;xor ax, ax ; 0 7851 000020F3 6631C0 xor eax, eax ; 09/03/2021 7852 000020F6 F3AB rep stosw 7853 7854 000020F8 A3[E66C] mov [pcount], ax ; reset (pcount & ppcount) 7855 000020FB A3[E86C] mov [apcount], ax ; reset (apcount & epnumber) 7856 7857 000020FE BE[AE54] mov si, MasterBootBuff+446 ; Partition table offset 7858 ;mov cx, 4 7859 00002101 B104 mov cl, 4 7860 00002103 31FF xor di, di 7861 ipt_0: 7862 00002105 8A6404 mov ah, [si+ptFileSystemID] 7863 7864 00002108 20E4 and ah, ah 7865 0000210A 0F840D01 jz ipt_8 ; empty 7866 7867 0000210E FE06[E66C] inc byte [pcount] ; partition count 7868 7869 00002112 80FC01 cmp ah, 1 ; FAT12 7870 00002115 7442 je short ipt_2 7871 00002117 80FC04 cmp ah, 4 ; FAT16 7872 0000211A 743D je short ipt_2 7873 0000211C 723F jb short ipt_3 7874 0000211E 80FC06 cmp ah, 6 ; FAT16 big 7875 00002121 7436 je short ipt_2 7876 00002123 7715 ja short ipt_1 ; EXTENDED 7877 7878 ;cmp ah, 5 ; EXTENDED 7879 ;jne short ipt_3 7880 ipt_17: 7881 00002125 803E[E96C]00 cmp byte [epnumber], 0 7882 ;ja short ipt_stc ; invalid (more than 1 extended dos partition) 7883 0000212A 7605 jna short ipt_15 7884 7885 0000212C C685[8E6C]FF mov byte [part_table_boot_ind+di], 0FFh 7886 ; Invalid/Defective partition flag 7887 ipt_15: 7888 00002131 B005 mov al, 5 7889 00002133 28C8 sub al, cl ; partition number 1 to 4 7890 00002135 A2[E96C] mov byte [epnumber], al ; extended partition entry number (1 to 4) 7891 00002138 EB23 jmp short ipt_3 7892 ipt_1: 7893 ; 26/10/2020 7894 0000213A 80FC07 cmp ah, 07h ; NTFS (Windows FS) 7895 0000213D 741A je short ipt_2 ; accept NTFS as primary dos partition 7896 ; (then, extended partition can be created) 7897 ; 24/10/2020 7898 0000213F 80FC0C cmp ah, 0Ch ; FAT32 (LBA) 7899 00002142 7415 je short ipt_2 7900 00002144 7707 ja short ipt_18 7901 ; 16/10/2020 7902 00002146 80FC0B cmp ah, 0Bh ; FAT32 (CHS) 7903 ;jne short ipt_3 7904 ; 24/10/2020 7905 00002149 740E je short ipt_2 7906 ;jb short ipt_3 ; non-dos partition (NTFS or unknown fs type) 7907 ; 09/03/2021 7908 0000214B EB10 jmp short ipt_3 ; non-dos partition (unknown fs type) 7909 ipt_18: 7910 0000214D 80FC0F cmp ah, 0Fh ; EXTENDED (LBA) 7911 00002150 74D3 je short ipt_17 7912 00002152 7709 ja short ipt_3 ; non-dos partition 7913 ; (xenix/unix/linux/singlix/runix or unknown) 7914 00002154 80FC0E cmp ah, 0Eh ; FAT16 (LBA) 7915 00002157 7504 jne short ipt_3 ; 0Dh 7916 ; FAT16 LBA (0Eh) 7917 ipt_2: 7918 00002159 FE06[E76C] inc byte [ppcount] ; primary dos partition count 7919 ipt_3: 7920 0000215D 88A5[956C] mov [part_table_sys_id+di], ah ; Partition Type (FS type) 7921 7922 00002161 8A04 mov al, [si+ptBootable] 7923 7924 00002163 20C0 and al, al 7925 00002165 7413 jz short ipt_4 7926 7927 00002167 803E[E86C]01 cmp byte [apcount], 1 ; check (previous) active partition count 7928 ;jnb short ipt_stc ; invalid (if it is not zero here) 7929 0000216C 7304 jnb short ipt_16 7930 7931 0000216E 3C80 cmp al, 80h ; active partition sign/flag? 7932 ;jne short ipt_stc ; invalid flag 7933 00002170 7404 je short ipt_11 7934 ipt_16: 7935 ; 15/10/2020 7936 00002172 B0FF mov al, 0FFh ; Invalid/Defective partition flag 7937 00002174 EB04 jmp short ipt_4 7938 ipt_11: 7939 00002176 FE06[E86C] inc byte [apcount] ; active partition count = 1 7940 ipt_4: 7941 0000217A 8885[8E6C] mov [part_table_boot_ind+di], al 7942 7943 ;mov al, [heads] 7944 ;ipt_4_fix: 7945 ;dec al 7946 0000217E 8A6401 mov ah, [si+ptBeginHead] 7947 ;cmp al, ah 7948 ;;jb short ipt_retn ; invalid 7949 ;jb ipt_heads_fix ; 10/02/2019 7950 00002181 88A5[8F6C] mov [part_table_start_head+di], ah 7951 00002185 8A6405 mov ah, [si+ptEndHead] 7952 ;cmp al, ah 7953 ;;jb short ipt_retn ; invalid 7954 ;jb short ipt_heads_fix ; 10/02/2019 7955 00002188 88A5[966C] mov [part_table_end_head+di], ah 7956 ;mov al, [sectors] 7957 0000218C 8A7C02 mov bh, [si+ptBeginSector] 7958 0000218F 88FC mov ah, bh 7959 00002191 80E43F and ah, 3Fh ; 63 7960 ;cmp al, ah 7961 ;jb short ipt_retn ; invalid 7962 00002194 88A5[906C] mov [part_table_start_sector+di], ah 7963 00002198 8A7406 mov dh, [si+ptEndSector] 7964 0000219B 88F4 mov ah, dh 7965 0000219D 80E43F and ah, 3Fh ; 63 7966 ;cmp al, ah 7967 ;jb short ipt_retn ; invalid 7968 000021A0 88A5[976C] mov [part_table_end_sector+di], ah 7969 000021A4 C0EF06 shr bh, 6 7970 ;mov bl, [si+ptBeginCylinder] 7971 000021A7 8A4403 mov al, [si+ptBeginCylinder] ; 09/03/2021 7972 000021AA 88FC mov ah, bh ; 09/03/2021 7973 ;mov ax, [cylinders] 7974 ;dec ax 7975 ;cmp ax, bx 7976 ;jb short ipt_retn ; invalid 7977 ;mov [part_table_start_cyl+di], bx 7978 000021AC 668985[916C] mov [part_table_start_cyl+di], eax ; 09/03/2021 7979 000021B1 C0EE06 shr dh, 6 7980 ;mov dl, [si+ptEndCylinder] 7981 000021B4 8A4407 mov al, [si+ptEndCylinder] ; 09/03/2021 7982 000021B7 88F4 mov ah, dh ; 09/03/2021 7983 ;cmp ax, dx 7984 ;jb short ipt_retn ; invalid 7985 ;mov [part_table_end_cyl+di], dx 7986 000021B9 668985[986C] mov [part_table_end_cyl+di], eax ; 09/03/2021 7987 7988 ;mov ax, [si+ptStartSector] 7989 ;mov dx, [si+ptStartSector+2] 7990 000021BE 668B4408 mov eax, [si+ptStartSector] ; 09/03/2021 7991 7992 ;mov [part_table_rel_sec_lw+di], ax 7993 ;mov [part_table_rel_sec_hw+di], dx 7994 000021C2 668985[9C6C] mov [part_table_rel_sec+di], eax ; 09/03/2021 7995 7996 ;or ax, dx 7997 ;;jz short ipt_stc ; invalid (start sector must not be zero) 7998 ;jnz short ipt_12 7999 ; 09/03/2021 8000 000021C7 6609C0 or eax, eax 8001 000021CA 7505 jnz short ipt_12 8002 ; 15/10/2020 8003 000021CC C685[8E6C]FF mov byte [part_table_boot_ind+di], 0FFh 8004 ; Invalid/Defective partition flag 8005 ipt_12: 8006 ;mov ax, [si+ptSectors] 8007 ;mov dx, [si+ptSectors+2] 8008 000021D1 668B440C mov eax, [si+ptSectors] ; 09/03/2021 8009 8010 ;mov bx, dx 8011 ;or bx, ax 8012 ;;jz short ipt_stc ; invalid (zero size of partition) 8013 ;jnz short ipt_6 ; 10/02/2019 8014 ; 09/03/2021 8015 000021D5 6609C0 or eax, eax 8016 000021D8 7505 jnz short ipt_6 8017 8018 ; 15/10/2020 8019 000021DA C685[8E6C]FF mov byte [part_table_boot_ind+di], 0FFh 8020 ; Invalid/Defective partition flag 8021 8022 ;cmp dx, [total_sectors+2] 8023 ;ja short ipt_stc ; invalid (partition size > disk capacity) 8024 ;jb short ipt_6 8025 ;;cmp ax, [total_sectors] ; (ax + 1) <= total sectors 8026 ;jb short ipt_6 8027 8028 ;ipt_stc: 8029 ; ; invalid MBR data 8030 ; ;stc 8031 ;ipt_retn: 8032 ; retn 8033 8034 ;ipt_heads_fix: 8035 ; 10/02/2019 8036 ; AL = [heads] - 1 8037 8038 ;test byte [cylinders], 1 8039 ;jnz short ipt_stc ; odd cylinder count (can not be shifted) 8040 8041 ;inc al ; = [heads] 8042 ;cmp al, 8 8043 ;ja short ipt_stc ; this fix is needed for <= 16 heads (& 17 spt) 8044 ;shl al, 1 8045 ;mov [heads], al ; heads = heads*2 8046 ;shr word [cylinders], 1 ; cylinders = cylinders/2 8047 ;jmp ipt_4_fix 8048 8049 ipt_6: 8050 ;mov [part_table_num_sec_lw+di], ax 8051 ;mov [part_table_num_sec_hw+di], dx 8052 ; 09/03/2021 8053 000021DF 668985[A06C] mov [part_table_num_sec+di], eax 8054 8055 ;add ax, [part_table_rel_sec_lw+di] 8056 ;adc dx, [part_table_rel_sec_hw+di] 8057 ;;jc short ipt_retn ; invalid 8058 ; 27/10/2020 8059 ;jc short ipt_13 8060 ; 09/03/2021 8061 000021E4 660385[9C6C] add eax, [part_table_rel_sec+di] 8062 000021E9 7207 jc short ipt_13 ; invalid ! 8063 8064 ;cmp dx, [total_sectors+2] 8065 ;;ja short ipt_stc ; invalid (partition end > disk capacity) 8066 ;jb short ipt_7 8067 ; 27/10/2020 8068 ;ja short ipt_13 8069 ;cmp ax, [total_sectors] ; ax <= total sectors 8070 ;;ja short ipt_stc ; invalid (partition end > disk capacity) 8071 ;jna short ipt_7 8072 ; 09/03/2011 8073 000021EB 663B06[4A65] cmp eax, [total_sectors] 8074 000021F0 7605 jna short ipt_7 8075 ipt_13: 8076 ; 15/10/2020 8077 000021F2 C685[8E6C]FF mov byte [part_table_boot_ind+di], 0FFh 8078 ; Invalid/Defective partition flag 8079 ipt_7: 8080 ; 27/10/2020 8081 ;mov ax, 1022 ; CHS cylinder number limit 8082 ;cmp [part_table_start_cyl+di], ax 8083 ;ja short ipt_19 ; = 1023 8084 ;inc ax ; 1023 8085 ;cmp [part_table_end_cyl+di], ax 8086 ;jb short ipt_14 ; < 1023 8087 ; 12/03/2021 8088 000021F7 66B8FE030000 mov eax, 1022 8089 000021FD 663985[916C] cmp [part_table_start_cyl+di], eax 8090 00002202 7708 ja short ipt_19 ; = 1023 8091 00002204 40 inc ax 8092 00002205 663985[986C] cmp [part_table_end_cyl+di], eax 8093 0000220A 7203 jb short ipt_14 ; < 1023 8094 ipt_19: 8095 ; 27/10/2020 8096 ; set cylinder number if the partition's start or end sector is 8097 ; at the beyond of chs limit 8098 ; ax = 1022 -> set start cylinder 8099 ; ax = 1023 -> set end cylinder 8100 0000220C E82600 call cylindernumberfix 8101 ipt_14: 8102 0000220F 83C610 add si, 16 8103 00002212 E201 loop ipt_5 8104 8105 ; OK! 8106 8107 ;clc 8108 00002214 C3 retn 8109 8110 ipt_5: 8111 ;add di, 18 8112 ; 05/11/2020 8113 00002215 83C716 add di, 22 8114 00002218 E9EAFE jmp ipt_0 8115 8116 ipt_8: 8117 ; Empty partition table check (all of 16 bytes must be 0) 8118 0000221B 51 push cx 8119 0000221C 56 push si ; 16/10/2020 8120 ;mov cl, 8 8121 0000221D B104 mov cl, 4 ; 12/03/2021 8122 ipt_9: 8123 ;lodsw 8124 ;or ax, ax 8125 ;jnz short ipt_10 8126 ; 12/03/2021 8127 0000221F 66AD lodsd 8128 00002221 6609C0 or eax, eax 8129 00002224 7507 jnz short ipt_10 8130 00002226 E2F7 loop ipt_9 8131 00002228 59 pop cx ; 16/10/2020 ; (discard si) 8132 00002229 59 pop cx 8133 0000222A E2E9 loop ipt_5 8134 8135 ;clc 8136 0000222C C3 retn 8137 ipt_10: 8138 ;pop cx 8139 ; invalid 8140 ;stc 8141 ; 27/10/2020 8142 ; 15/10/2020 8143 ;mov byte [part_table_boot_ind+di], 0FFh 8144 ; Invalid/Defective partition flag 8145 ;retn 8146 ; 16/10/2020 8147 ; 31/10/2020 8148 ;mov byte [part_table_sys_id+di], 0 ; Empty partition 8149 ; 12/03/2021 8150 0000222D 6629C0 sub eax, eax 8151 ; 8152 00002230 5E pop si 8153 00002231 59 pop cx 8154 00002232 E93DFF jmp ipt_16 8155 8156 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8157 ; set cylinder number to partition's start or end sector 8158 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8159 ; 27/10/2020 8160 8161 ; 09/03/2021 8162 ; 06/11/2020 (32 bit cylinder numbers, upto 267349) 8163 cylindernumberfix: 8164 ; ax = 1022 -> set start cylinder 8165 ; ax = 1023 -> set end cylinder 8166 ; di = partition table structure offset 8167 8168 ;; modified registers: ax, dx, bx 8169 ; modified registers: eax, edx ; 09/03/2021 8170 8171 00002235 3DFF03 cmp ax, 1023 8172 00002238 733D jnb short cnf_4 ; set end cylinder 8173 8174 0000223A 80BD[8F6C]FE cmp byte [part_table_start_head+di], 0FEh ; 254 8175 0000223F 7536 jne short cnf_4 ; no need to fix (start cyl) 8176 ; 30/10/2020 8177 ; 28/10/2020 8178 00002241 80BD[906C]3F cmp byte [part_table_start_sector+di], 3Fh ; 63 8179 00002246 752F jne short cnf_4 ; no need to fix (start cyl) 8180 ; 30/10/2020 8181 8182 ;mov ax, [part_table_rel_sec_lw+di] ; start sector, lw 8183 ;mov dx, [part_table_rel_sec_hw+di] ; start sector, hw 8184 ;push cx 8185 ;mov cx, [hs] ; [heads*spt] 8186 ;call div32 8187 ; ; dx:ax = cylinder number, dx = 0, quotient 8188 ; ; bx = remainder 8189 ;pop cx 8190 ;or dx, dx 8191 ;jnz short cnf_2 ; invalid 8192 8193 ; 09/03/2021 8194 00002248 668B85[9C6C] mov eax, [part_table_rel_sec+di] 8195 0000224D 6631D2 xor edx, edx 8196 00002250 66F736[086A] div dword [hs] ; [heads*spt] ; <= 16065 8197 8198 ;cmp ax, [part_table_start_cyl+di] 8199 ; 09/03/2021 8200 00002255 663B85[916C] cmp eax, [part_table_start_cyl+di] 8201 ;je short cnf_5 8202 0000225A 7407 je short cnf_1 8203 0000225C 7213 jb short cnf_2 ; invalid 8204 ;mov [part_table_start_cyl+di], ax ; change it 8205 ; 09/03/2021 8206 0000225E 668985[916C] mov [part_table_start_cyl+di], eax ; change it 8207 ;jmp short cnf_5 8208 cnf_1: 8209 00002263 80BD[966C]FE cmp byte [part_table_end_head+di], 0FEh ; 254 8210 00002268 7507 jne short cnf_2 ; no need to fix (also invalid) 8211 8212 ; 28/10/2020 8213 0000226A 80BD[976C]3F cmp byte [part_table_end_sector+di], 3Fh ; 63 8214 0000226F 7414 je short cnf_5 ; fix 8215 ; no need to fix (also invalid) 8216 cnf_2: 8217 00002271 C685[8E6C]FF mov byte [part_table_boot_ind+di], 0FFh ; invalid PTE 8218 cnf_3: 8219 00002276 C3 retn 8220 cnf_4: 8221 00002277 80BD[966C]FE cmp byte [part_table_end_head+di], 0FEh ; 254 8222 0000227C 75F8 jne short cnf_3 ; no need to fix (end cyl) 8223 8224 ; 28/10/2020 8225 0000227E 80BD[976C]3F cmp byte [part_table_end_sector+di], 3Fh ; 63 8226 00002283 75F1 jne short cnf_3 ; no need to fix (end cyl) 8227 cnf_5: 8228 ;mov ax, [part_table_rel_sec_lw+di] ; start sector, lw 8229 ;mov dx, [part_table_rel_sec_hw+di] ; start sector, hw 8230 ; 8231 ;add ax, [part_table_num_sec_lw+di] ; number of sectors, lw 8232 ;adc dx, [part_table_num_sec_hw+di] ; number of sectors, hw 8233 ;;jc short cnf_2 8234 8235 ; 09/03/2021 8236 00002285 668B85[9C6C] mov eax, [part_table_rel_sec+di] ; start sector 8237 0000228A 660385[A06C] add eax, [part_table_num_sec+di] ; number of sectors 8238 ;jc short cnf_2 8239 8240 ;sub ax, 1 8241 ;sbb dx, 0 8242 ; ; dx:ax = end sector 8243 ;push cx 8244 ;mov cx, [hs] ; [heads*spt] 8245 ;call div32 8246 ; ; dx:ax = cylinder number, dx = 0, quotient 8247 ; ; bx = remainder 8248 ;pop cx 8249 ;or dx, dx 8250 ;jnz short cnf_2 ; invalid 8251 8252 ; 09/03/2021 8253 0000228F 6648 dec eax ; end sector 8254 00002291 6631D2 xor edx, edx ; 12/03/2021 8255 00002294 66F736[086A] div dword [hs] ; [heads*spt] ; <= 16065 8256 8257 ;cmp ax, [part_table_end_cyl+di] 8258 ; 09/03/2021 8259 00002299 663B85[986C] cmp eax, [part_table_end_cyl+di] 8260 0000229E 74D6 je short cnf_3 ; same cylinder number 8261 000022A0 72CF jb short cnf_2 ; invalid 8262 ;mov [part_table_end_cyl+di], ax ; change it 8263 ; 09/03/2021 8264 000022A2 668985[986C] mov [part_table_end_cyl+di], eax ; change it 8265 000022A7 C3 retn 8266 8267 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8268 ; sort partition table in (ending) cylinder number order 8269 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8270 ; 25/10/2020 (fdisk3.s) 8271 8272 ; 10/03/2021 (fdisk4.s) 8273 ; 02/02/2019 (hdimage.s) 8274 8275 sort_partition_table: 8276 8277 ; INPUT -> none 8278 ; OUTPUT -> none 8279 8280 000022A8 31DB xor bx, bx 8281 ;jmp short sortpt_2 ; 25/10/2020 8282 sortpt_1: 8283 000022AA 889F[1E6A] mov [bx+sort], bl ; 0 8284 000022AE FEC3 inc bl 8285 sortpt_2: 8286 000022B0 80FB04 cmp bl, 4 ; number of partition table entries to sort 8287 000022B3 72F5 jb short sortpt_1 8288 8289 ; Do a bubble sort 8290 8291 000022B5 EB04 jmp short sortpt_4 8292 sortpt_3: 8293 ; Sort until we don't do a swap 8294 8295 000022B7 08C9 or cl, cl ; sort changed ? 8296 000022B9 7454 jz short sortpt_8 ; no 8297 sortpt_4: 8298 000022BB 30C9 xor cl, cl 8299 8300 000022BD B301 mov bl, 1 8301 8302 ;mov dl, 18 ; partition table structure size 8303 ; 05/11/2020 8304 000022BF B216 mov dl, 22 8305 000022C1 EB07 jmp short sortpt_6 8306 sortpt_5: 8307 000022C3 FEC3 inc bl 8308 8309 000022C5 80FB04 cmp bl, 4 8310 000022C8 73ED jnb short sortpt_3 8311 8312 sortpt_6: 8313 000022CA 8A87[1E6A] mov al, [bx+sort] 8314 8315 000022CE F6E2 mul dl 8316 8317 000022D0 89C6 mov si, ax 8318 8319 ;mov di, [part_table_end_cyl+si] 8320 8321 000022D2 8A87[1D6A] mov al, [bx+sort-1] 8322 8323 000022D6 F6E2 mul dl ; * 22 ; 05/11/2020 8324 8325 ;xchg di, ax 8326 ; 10/03/2021 8327 000022D8 89C7 mov di, ax 8328 000022DA 668B84[986C] mov eax, [part_table_end_cyl+si] 8329 8330 ;cmp [part_table_end_cyl+di], ax ; previous > current 8331 ; 10/03/2021 8332 000022DF 663985[986C] cmp [part_table_end_cyl+di], eax ; previous > current 8333 000022E4 771B ja short sortpt_7 ; swap order indicators 8334 ; 31/10/2020 8335 ; current end cyl >= previous end cyl 8336 ; 31/10/2020 8337 000022E6 72DB jb short sortpt_5 8338 ; current end cyl > previous end cyl 8339 8340 ;and ax, ax ; cylinder 0 ? 8341 ; 10/03/2021 8342 000022E8 6621C0 and eax, eax ; cylinder 0 ? 8343 000022EB 75D6 jnz short sortpt_5 ; no 8344 ; current end cyl = previous end cyl, cyl > 0 8345 8346 ; current end cyl = previous end cyl = 0 8347 8348 ; If current entry is empty partition entry 8349 ; and previous entry is not empty partition entry 8350 ; swap them. 8351 8352 ;mov ax, [part_table_num_sec_hw+di] ; previous entry 8353 ;or ax, [part_table_num_sec_lw+di] 8354 ;jz short sortpt_5 8355 ; 10/03/2021 8356 000022ED 668B85[A06C] mov eax, [part_table_num_sec+di] 8357 000022F2 6609C0 or eax, eax 8358 000022F5 74CC jz short sortpt_5 8359 8360 ;mov ax, [part_table_num_sec_hw+si] ; current entry 8361 ;or ax, [part_table_num_sec_lw+si] 8362 ;jnz short sortpt_5 8363 ; 10/03/2021 8364 000022F7 668B84[A06C] mov eax, [part_table_num_sec+si] 8365 000022FC 6609C0 or eax, eax 8366 000022FF 75C2 jnz short sortpt_5 8367 sortpt_7: 8368 ; Swap the order indicators 8369 8370 00002301 8B87[1D6A] mov ax, [bx+sort-1] 8371 00002305 86E0 xchg ah, al 8372 00002307 8987[1D6A] mov [bx+sort-1], ax 8373 8374 0000230B B101 mov cl, 1 ; sort changed 8375 0000230D EBB4 jmp short sortpt_5 8376 8377 sortpt_8: 8378 ; 30/10/2020 8379 ;mov byte [p_sorted], 1 ; 04/02/2019 8380 8381 ; 10/03/2021 8382 ;xor eax, eax 8383 8384 0000230F C3 retn 8385 8386 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8387 ; find free space before/after/between partitions 8388 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8389 ; 03/02/2019 8390 8391 ; 12/03/2021 8392 ; 11/03/2021 (fdisk4.s) -32 bit cylinder numbers- 8393 ; 8394 find_part_free_space: ; find/calculate free space for partitions 8395 ; 15/02/2019 8396 8397 ; INPUT -> 8398 ; AL = 0 -> calculate for primary/MBR partitions 8399 ; AL = 5 -> calculate for extended partition 8400 ; OUTPUT -> 8401 ; CX = the largest free space/cylinders (between partitions) 8402 ; AX = Free space index (gap number) - from 0 to 4 - 8403 ; BX = Free space structure offset (for the largest free space) 8404 ; 8405 ; 22/02/2019 8406 ; [freespace_count] = number of free spaces/gaps 8407 8408 ; 12/03/2021 8409 ; OUTPUT: 8410 ; ECX = the largest free space/cylinders (between partitions) 8411 ; AX = Free space index (gap number) - from 0 to 4 - 8412 ; BX = Free space structure offset (for the largest free space) 8413 ; (EDX = 0) 8414 8415 00002310 A2[386C] mov [p_type], al 8416 8417 ; Sort the partition table 8418 8419 00002313 E892FF call sort_partition_table ; 16/02/2019 8420 8421 ; Initialize free space to zero 8422 8423 ; 15/02/2019 8424 00002316 BF[426D] mov di, fspc ; free_space.space 8425 00002319 B92800 mov cx, 5*8 ; (5*16/2) 8426 ;mov ecx, 5*8 ; 11/03/2021 8427 ;xor ax, ax ; 0 8428 0000231C 6631C0 xor eax, eax ; 11/03/2021 8429 0000231F F3AB rep stosw 8430 8431 00002321 A2[366C] mov [freespace_count], al ; 0 8432 ; 22/02/2019 8433 ;mov [last_found_partition], al ; 0 8434 8435 00002324 A3[346C] mov [_i_], ax ; 0 8436 ;jmp short fpfs_2 8437 ; 31/10/020 8438 00002327 EB0E jmp short fpfs_3 8439 fpfs_1: 8440 00002329 FE06[346C] inc byte [_i_] 8441 ;;fpfs_2: 8442 0000232D 803E[346C]04 cmp byte [_i_], 4 8443 00002332 7203 jb short fpfs_3 8444 00002334 E96201 jmp fpfs_13 8445 fpfs_3: 8446 ; Find space between start of disk and first partition 8447 8448 ;mov ax, [_i_] 8449 00002337 8B1E[346C] mov bx, [_i_] ; 31/10/2020 8450 fpfs_2: 8451 ;mov bx, ax ; 31/10/2020 8452 ;mov al, [sort+bx] 8453 0000233B 8A8F[1E6A] mov cl, [sort+bx] ; 15/02/2019 8454 8455 ;;mov cl, 18 ; partition table structure size = 18 bytes 8456 ;mov al, 18 ; 15/02/2019 8457 ; 05/11/2020 8458 0000233F B016 mov al, 22 ; partition table structure size = 22 bytes 8459 00002341 F6E1 mul cl 8460 00002343 89C3 mov bx, ax 8461 8462 00002345 80BF[956C]00 cmp byte [part_table_sys_id+bx], 0 8463 0000234A 74DD je short fpfs_1 8464 8465 0000234C 880E[376C] mov [last_found_partition], cl ; 15/02/2019 8466 8467 ;xor cx, cx 8468 00002350 30C9 xor cl, cl ; 0 8469 ;mov al, 1 ; LBA = 1 (after MBR) ; ah = 0 8470 ; 03/11/2020 8471 00002352 A0[BA3C] mov al, [sectors] ; 63 or 17 ; 03/11/2020 8472 8473 00002355 803E[386C]05 cmp byte [p_type], 5 ; EXTENDED 8474 0000235A 7506 jne short fpfs_4 8475 8476 ; This is a special case - the extended partition can not start 8477 ; on cylinder 0 due to its architecture. Protect against that here 8478 8479 ; 13/02/2019 8480 ; LBA value of free space start 8481 ;mov al, [sectors] ; 03/11/2020 8482 0000235C F626[BC3C] mul byte [heads] 8483 ; ax = start sector (for Extended Partition) 8484 00002360 FEC1 inc cl ; 1 ; cx = start cylinder = 1 8485 fpfs_4: 8486 ; Found a partition, get the space 8487 8488 ; 15/02/2019 8489 ;mov dx, [part_table_start_cyl+bx] 8490 ; ; Start cylinder of the 1st partition (as sorted) 8491 ;cmp dx, cx ; (cx=0 for primary partition, cx=1 for extd partition) 8492 ;jna fpfs_9 ; It is accepted as free (partition) space 8493 ; ; if this space between masterboot sector and partition 1 8494 ; ; has 1 cylinder (heads*spt) size at least. 8495 8496 ; 11/03/2021 8497 00002362 668B97[916C] mov edx, [part_table_start_cyl+bx] 8498 00002367 6639CA cmp edx, ecx 8499 0000236A 0F86B400 jna fpfs_9 8500 8501 ; 22/02/2019 8502 0000236E 31FF xor di, di ; 0 ; Reset Free Space Table offset 8503 8504 00002370 FE06[366C] inc byte [freespace_count] ; mov byte [freespace_count], 1 8505 8506 ;mov [free_space.start], cx ; 0 (for PP) or 1 (for EP) 8507 ; 11/03/2021 8508 00002374 66890E[466D] mov [free_space.start], ecx 8509 8510 ; non-aligned address of start sector (for the 1st partition as sorted) 8511 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 8512 ; if new partition will be selected as a primary dos partition. 8513 ; (But, start sector -LBA- will not be changed 8514 ; if it is a non-dos or user input type partition.. unless 8515 ; cylinder boundary alignment option is used.) 8516 8517 00002379 A3[526D] mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 8518 ; or 1 (for PP) 8519 ;mov [free_space.startsector+2], 0 8520 8521 ; free space ends before start of next valid partition 8522 ;mov ax, dx ; start cylinder of partition 1 (as sorted) 8523 ;sub dx, cx ; cylinder count of free space 1 (gap 1) 8524 ;dec ax ; end cylinder of free space 1 (gap 1) 8525 ;mov [free_space.end], ax 8526 ;mov [free_space.space], dx 8527 ; 11/03/2021 8528 0000237C 6689D0 mov eax, edx 8529 0000237F 6629CA sub edx, ecx 8530 00002382 6648 dec eax 8531 00002384 66A3[4A6D] mov [free_space.end], eax 8532 00002388 668916[426D] mov [free_space.space], edx 8533 8534 ; save free space (1) as (non-aligned) sector count 8535 ;mov ax, [part_table_rel_sec_lw+bx] 8536 ;mov dx, [part_table_rel_sec_hw+bx] 8537 ;sub ax, [free_space.startsector] 8538 ;sbb dx, 0 8539 ;mov [free_space.sectors_unused], ax 8540 ;mov [free_space.sectors_unused+2], dx 8541 ; 11/03/2021 8542 0000238D 668B87[9C6C] mov eax, [part_table_rel_sec+bx] 8543 00002392 662B06[526D] sub eax, [free_space.startsector] 8544 00002397 66A3[4E6D] mov [free_space.sectors_unused], eax 8545 8546 ;mov ax, [free_space.space] 8547 8548 ;call cylinders_to_sectors 8549 8550 ;mov [free_space.sectors_unused], ax 8551 ;mov [free_space.sectors_unused+2], dx 8552 8553 ;mov cx, [cylinders] ; Total (disk) cylinders -divisor- 8554 ;mov bx, [free_space.space] ; Partition cylinders -dividend- 8555 ; 12/03/2021 8556 0000239B 66A1[426D] mov eax, [free_space.space] 8557 8558 0000239F E8E501 call cylinders_to_percent 8559 8560 000023A2 A3[566D] mov [free_space.percent_unused], ax 8561 8562 ; 15/02/2019 8563 ;mov bl, [_i_] 8564 ;xor bh, bh 8565 ;mov al, [sort+bx] 8566 8567 ;mov [last_found_partition], al 8568 8569 ; 31/10/2020 8570 000023A5 EB7B jmp fpfs_9 8571 8572 ; Look for space between the rest of the partitions 8573 8574 fpfs_7: 8575 ; ah = 0 8576 ;mov al, [_i_] 8577 ;;cbw 8578 ;mov bx, ax 8579 ; 22/02/2019 8580 000023A7 8B1E[346C] mov bx, [_i_] 8581 8582 ; 15/02/2019 8583 ;mov al, [sort+bx] 8584 000023AB 8A8F[1E6A] mov cl, [sort+bx] 8585 ;;mov bl, 18 8586 ;;mul bl 8587 ;mov al, 18 8588 ; 05/11/2020 8589 000023AF B016 mov al, 22 8590 000023B1 F6E1 mul cl 8591 000023B3 89C6 mov si, ax 8592 8593 000023B5 80BC[956C]00 cmp byte [part_table_sys_id+si], 0 8594 000023BA 7466 je short fpfs_9 8595 8596 ; 15/02/2019 8597 000023BC 860E[376C] xchg [last_found_partition], cl 8598 8599 ; Check to see if more than one partition on a cylinder 8600 ; If so, leave the space at zero */ 8601 8602 ; NOTE: 8603 ; If free space (gap) between partitions 8604 ; has 1 cylinder (heads*spt) size at least.. 8605 ; ..It is accepted as valid free (partition) space. 8606 8607 ;mov al, 18 ; Partition tables/data structure size = 18 bytes 8608 ; 05/11/2020 8609 000023C0 B016 mov al, 22 ; Partition tables/data structure size = 22 bytes 8610 000023C2 F6E1 mul cl 8611 000023C4 89C3 mov bx, ax ; ah = 0 8612 8613 ;mov dx, [part_table_end_cyl+bx] ; end cyl. of previous partition 8614 ;mov ax, [part_table_start_cyl+si] ; start cyl. of current partition 8615 ; 8616 ;inc dx ; start cylinder of free space is after the end cylinder of 8617 ; ; the previous partition (as sorted) 8618 ; 8619 ;cmp ax, dx ; and it must be before than the next partition (as sorted) 8620 ;jna short fpfs_9 ; je short fpfs_9 8621 8622 ; 12/03/2021 8623 000023C6 668B97[986C] mov edx, [part_table_end_cyl+bx] ; end cyl. of previous partition 8624 000023CB 668B8C[916C] mov ecx, [part_table_start_cyl+si] ; start cyl. of current partition 8625 8626 000023D0 6642 inc edx ; start cylinder of free space is after the end cylinder of 8627 ; the previous partition (as sorted) 8628 8629 000023D2 6639D1 cmp ecx, edx ; and it must be before than the next partition (as sorted) 8630 000023D5 764B jna short fpfs_9 ; je short fpfs_9 8631 8632 ; No, things are normal 8633 ; Get space between the end of the last one and the start of the next one 8634 8635 ; 22/02/2019 8636 ;;add di, 16 8637 ;mov di, [freespace_count] 8638 ;shl di, 4 ; * 16 ; next entry offset (in free space table) 8639 ; 12/03/2021 8640 000023D7 B016 mov al, 22 ; ah = 0 8641 000023D9 F626[366C] mul byte [freespace_count] 8642 000023DD 89C7 mov di, ax 8643 8644 000023DF FE06[366C] inc byte [freespace_count] 8645 8646 ;mov cx, ax 8647 000023E3 6689C8 mov eax, ecx 8648 ;sub cx, dx 8649 000023E6 6629D1 sub ecx, edx 8650 ;dec ax 8651 000023E9 6648 dec eax 8652 ;mov [free_space.start+di], dx 8653 ;mov [free_space.end+di], ax 8654 ;mov [free_space.space+di], cx 8655 8656 000023EB 668995[466D] mov [free_space.start+di], edx 8657 000023F0 668985[4A6D] mov [free_space.end+di], eax 8658 000023F5 66898D[426D] mov [free_space.space+di], ecx 8659 8660 ;mov ax, [free_space.space+di] 8661 ;call cylinders_to_sectors 8662 ;mov [free_space.sectors_unused+di], ax 8663 ;mov [free_space.sectors_unused+2+di], dx 8664 8665 ; calculate and save (non-aligned) free sector count between partitions 8666 8667 ;mov ax, [part_table_rel_sec_lw+bx] 8668 ;mov dx, [part_table_rel_sec_hw+bx] 8669 ; 12/03/2021 8670 000023FA 668B87[9C6C] mov eax, [part_table_rel_sec+bx] 8671 8672 ;add ax, [part_table_num_sec_lw+bx] 8673 ;adc dx, [part_table_num_sec_hw+bx] 8674 000023FF 660387[A06C] add eax, [part_table_num_sec+bx] 8675 8676 ;mov cx, [part_table_rel_sec_lw+si] 8677 ;mov bx, [part_table_rel_sec_hw+si] 8678 00002404 668B94[9C6C] mov edx, [part_table_rel_sec+si] 8679 8680 ;mov [free_space.startsector+di], ax 8681 ;mov [free_space.startsector+2+di], dx 8682 00002409 668985[526D] mov [free_space.startsector+di], eax 8683 8684 ;sub cx, ax 8685 ;sbb bx, dx 8686 0000240E 6629C2 sub edx, eax 8687 8688 ;mov [free_space.sectors_unused+di], cx 8689 ;mov [free_space.sectors_unused+2+di], bx 8690 00002411 668995[4E6D] mov [free_space.sectors_unused+di], edx 8691 8692 fpfs_8: 8693 ; NOTE: Percentage is based on cylinder-boundary aligned partition size. 8694 ; (total disk cylinders and partition's cylinder count are used for that) 8695 8696 ;mov cx, [cylinders] ; -divisor- 8697 ;mov bx, [free_space.space+di] ; -dividend- 8698 ; 12/03/2021 8699 00002416 668B85[426D] mov eax, [free_space.space+di] 8700 8701 0000241B E86901 call cylinders_to_percent 8702 8703 0000241E 8985[566D] mov [free_space.percent_unused+di], ax 8704 8705 ; ah = 0 8706 8707 ; 15/02/2019 8708 ;mov bl, [_i_] 8709 ;xor bh, bh 8710 ;mov al, [sort+bx] 8711 ; 8712 ;mov [last_found_partition], al 8713 8714 fpfs_9: 8715 00002422 FE06[346C] inc byte [_i_] 8716 fpfs_10: 8717 00002426 803E[346C]04 cmp byte [_i_], 4 8718 0000242B 7303 jnb short fpfs_11 8719 8720 0000242D E977FF jmp fpfs_7 8721 8722 fpfs_11: 8723 ; Find the space between the last partition and the end of the disk 8724 ; Make sure that freespace cannot become negative 8725 8726 00002430 A0[376C] mov al, [last_found_partition] 8727 ;mov cl, 18 ; Partition table structure size = 18 bytes 8728 ; 05/11/2020 8729 00002433 B116 mov cl, 22 ; Partition table structure size = 22 bytes 8730 00002435 F6E1 mul cl 8731 00002437 89C3 mov bx, ax 8732 ;mov cx, [cylinders] 8733 ;dec cx ; 15/02/2019 8734 ; ; (min. cylinder count = 1 for a valid/usable free space) 8735 ;;mov ax, [part_table_end_cyl+bx] 8736 ; 12/03/2021 8737 00002439 668B0E[BE3C] mov ecx, [cylinders] 8738 0000243E 6649 dec ecx 8739 8740 ; 05/11/2020 8741 ;cmp [part_table_end_cyl+bx], cx 8742 ;;cmp ax, cx ; cx = end cylinder of the disk 8743 ;jb short fpfs_12 8744 ; 12/03/2021 8745 00002440 66398F[986C] cmp [part_table_end_cyl+bx], ecx 8746 00002445 7203 jb short fpfs_12 8747 8748 00002447 E99E00 jmp fpfs_15 8749 fpfs_12: 8750 ; 22/02/2019 8751 ;mov di, [freespace_count] 8752 ;;shl di, 4 ; * 16 ; next entry offset (in free space table) 8753 ; 05/11/2020 8754 ;mov ax, 22 8755 ;mul word [freespace_count] 8756 ;mov di, ax 8757 ; 12/03/2021 8758 0000244A B016 mov al, 22 8759 0000244C F626[366C] mul byte [freespace_count] 8760 00002450 89C7 mov di, ax 8761 8762 00002452 FE06[366C] inc byte [freespace_count] 8763 8764 ;mov [free_space.end+di], cx ; end cyl. of free space 5 (gap 5) 8765 ; 12/03/2021 8766 00002456 66898D[4A6D] mov [free_space.end+di], ecx 8767 8768 ; 05/11/2020 8769 ;mov ax, [part_table_end_cyl+bx] 8770 ;mov dx, cx ; cx = end cylinder of the disk 8771 ;sub dx, ax ; ax = end cylinder of the last partition 8772 ;mov [free_space.space+di], dx ; di = 4*22 ; 05/11/2020 8773 ;inc ax 8774 ;mov [free_space.start+di], ax 8775 ; 12/03/2021 8776 0000245B 668B87[986C] mov eax, [part_table_end_cyl+bx] 8777 ; eax = end cylinder of the last partition 8778 ; ecx = end cylinder of the disk 8779 00002460 6629C1 sub ecx, eax 8780 00002463 66898D[426D] mov [free_space.space+di], ecx ; di = 4*22 8781 00002468 6640 inc eax 8782 0000246A 668985[466D] mov [free_space.start+di], eax 8783 8784 ;inc cx ; [cylinders] 8785 ;mov ax, [free_space.space+si] 8786 ;call cylinders_to_sectors 8787 ;mov [free_space.sectors_unused+di], ax 8788 ;mov [free_space.sectors_unused+2+di], dx 8789 8790 ; calculate and save (non-aligned) free sector count 8791 8792 ; 22/02/2019 8793 ;mov ax, [part_table_rel_sec_lw+bx] 8794 ;mov dx, [part_table_rel_sec_hw+bx] 8795 ;add ax, [part_table_num_sec_lw+bx] 8796 ;adc dx, [part_table_num_sec_hw+bx] 8797 ; 12/03/2021 8798 0000246F 668B87[9C6C] mov eax, [part_table_rel_sec+bx] 8799 00002474 660387[A06C] add eax, [part_table_num_sec+bx] 8800 8801 ;mov [free_space.startsector+di], ax 8802 ;mov [free_space.startsector+2+di], dx 8803 00002479 668985[526D] mov [free_space.startsector+di], eax 8804 8805 ;mov cx, [total_sectors] 8806 ;mov bx, [total_sectors+2] 8807 ;sub cx, ax 8808 ;sbb bx, dx 8809 ; 12/03/2021 8810 0000247E 668B0E[4A65] mov ecx, [total_sectors] 8811 00002483 6629C1 sub ecx, eax 8812 8813 ;mov [free_space.sectors_unused+di], cx 8814 ;mov [free_space.sectors_unused+2+di], bx 8815 00002486 66898D[4E6D] mov [free_space.sectors_unused+di], ecx 8816 8817 ;mov cx, [cylinders] 8818 ;mov bx, [free_space.space+di] 8819 ; 12/03/2021 8820 0000248B 668B85[426D] mov eax, [free_space.space+di] 8821 00002490 E8F400 call cylinders_to_percent 8822 00002493 8985[566D] mov [free_space.percent_unused+di], ax 8823 00002497 EB4F jmp short fpfs_15 8824 8825 fpfs_13: 8826 ; No partitions found, show entire space as free 8827 8828 ; 22/02/2019 8829 00002499 FE06[366C] inc byte [freespace_count] ; mov byte [freespace_count], 1 8830 8831 ; 15/02/2019 8832 ;;sub ax, ax 8833 ;; ah = 0 ; 31/10/2020 8834 ;sub dx, dx 8835 ; 12/03/2021 8836 0000249D 6629D2 sub edx, edx 8837 8838 ;;inc al ; LBA = 1 (after MBR) ; ah = 0 8839 ;mov al, 1 ; 25/02/2019 8840 ; 12/03/2021 8841 000024A0 6631C0 xor eax, eax 8842 000024A3 FEC0 inc al ; eax = 1 8843 8844 ;This is a special case - the extended partition can not start 8845 ;on cylinder 0 due to its architecture. Protect against that here 8846 8847 000024A5 803E[386C]05 cmp byte [p_type], 5 ; EXTENDED 8848 000024AA 7509 jne short fpfs_14 8849 8850 000024AC FEC2 inc dl 8851 8852 ; 15/02/2019 8853 ; LBA value of free space start 8854 000024AE A0[BA3C] mov al, [sectors] 8855 000024B1 F626[BC3C] mul byte [heads] 8856 ; ax = start sector (for Extended Partition) 8857 fpfs_14: 8858 ;mov [free_space.start], dx ; 0 or 1 8859 ; 12/03/2021 8860 000024B5 668916[466D] mov [free_space.start], edx ; 0 or 1 8861 8862 ; non-aligned address of start sector (for the 1st partition as sorted) 8863 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 8864 ; if new partition will be selected as a primary dos partition. 8865 8866 ;mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 8867 ; ; or 1 (for PP) 8868 ;;mov [free_space.startsector+2], 0 8869 ; 12/03/2021 8870 000024BA 66A3[526D] mov [free_space.startsector], eax 8871 8872 ;mov ax, [cylinders] ; disk capacity 8873 ;mov cx, ax 8874 ;dec ax 8875 ;mov [free_space.end], ax 8876 ;sub ax, dx 8877 ;inc ax 8878 ;mov [free_space.space], ax 8879 ; 12/03/2021 8880 000024BE 66A1[BE3C] mov eax, [cylinders] ; disk capacity 8881 000024C2 6648 dec eax 8882 000024C4 66A3[4A6D] mov [free_space.end], eax 8883 000024C8 6629D0 sub eax, edx 8884 000024CB 6640 inc eax 8885 000024CD 66A3[426D] mov [free_space.space], eax 8886 8887 ;mov ax, [total_sectors] 8888 ;mov dx, [total_sectors+2] 8889 ;sub ax, [free_space.startsector] 8890 ;sbb dx, 0 8891 ;mov [free_space.sectors_unused], ax 8892 ;mov [free_space.sectors_unused+2], dx 8893 ; 12/03/2021 8894 000024D1 66A1[4A65] mov eax, [total_sectors] 8895 000024D5 662B06[526D] sub eax, [free_space.startsector] 8896 000024DA 66A3[4E6D] mov [free_space.sectors_unused], eax 8897 8898 ;;mov cx, [cylinders] 8899 ;mov bx, [free_space.space] 8900 ; 12/03/2021 8901 000024DE 66A1[426D] mov eax, [free_space.space] 8902 000024E2 E8A200 call cylinders_to_percent 8903 000024E5 A3[566D] mov [free_space.percent_unused], ax 8904 8905 fpfs_15: 8906 ; Find largest free space 8907 ;sub cx, cx 8908 ; 12/03/2021 8909 000024E8 6629C9 sub ecx, ecx 8910 000024EB 6629C0 sub eax, eax 8911 8912 ; 22/02/2019 8913 ;sub ax, ax 8914 000024EE 31DB xor bx, bx 8915 000024F0 8A16[366C] mov dl, [freespace_count] 8916 000024F4 08D2 or dl, dl 8917 000024F6 7423 jz short fpfs_19 8918 000024F8 8816[346C] mov [_i_], dl 8919 fpfs_16: 8920 ;mov dx, [free_space.space+bx] 8921 ; 12/03/2021 8922 000024FC 668B97[426D] mov edx, [free_space.space+bx] 8923 ;cmp dx, cx 8924 00002501 6639CA cmp edx, ecx 8925 00002504 7605 jbe short fpfs_17 8926 ; 22/02/2019 8927 ;mov cx, dx ; Largest free space 8928 ; 12/03/2021 8929 00002506 6689D1 mov ecx, edx ; Largest free space 8930 00002509 89D8 mov ax, bx 8931 fpfs_17: 8932 0000250B FE0E[346C] dec byte [_i_] 8933 0000250F 7405 jz short fpfs_18 8934 8935 ;add bx, 16 ; Free space structure size 8936 ; 12/03/2021 8937 00002511 83C316 add bx, 22 8938 00002514 EBE6 jmp short fpfs_16 8939 fpfs_18: 8940 ; 22/02/2019 8941 00002516 89C3 mov bx, ax ; offset (from 0 to 64) 8942 ; bx = offset (from 0 to 88) ; 12/03/2021 8943 00002518 C0E804 shr al, 4 ; index (from 0 to 4) 8944 fpfs_19: 8945 0000251B 6631D2 xor edx, edx ; 12/03/2021 8946 0000251E C3 retn 8947 8948 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8949 ; find enough free space 8950 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8951 8952 ; ; 15/02/2019 8953 ;find_enough_free_space: 8954 ; ; Find enough free space 8955 ; ; 8956 ; ; INPUT: 8957 ; ; AX = Requested space (in cylinders) 8958 ; ; 22/02/2019 8959 ; ; [freespace_count] = number of free spaces/gaps 8960 ; ; OUTPUT: 8961 ; ; AX = Available space 8962 ; DX = Requested space 8963 ; ; If CF = 0 -> AX >= DX 8964 ; ; If CF = 1 -> AX < DX 8965 ; ; CX = Index of available space in free space structure 8966 ; ; (GAP number, 0 to 4) - if AX > 0 - 8967 ; 8968 ; mov dx, ax ; 22/02/2019 8969 ; sub ax, ax 8970 ; xor bx, bx 8971 ; ; 22/02/2019 8972 ; mov ch, [freespace_count] 8973 ; mov [_i_], ax ; 0 8974 ; jmp short fefs_1 8975 ;fefs_0: 8976 ; ;mov al, 16 8977 ; ;mul byte [_i_] 8978 ; ;mov bx, ax 8979 ; mov bl, [_i_] 8980 ; shl bl, 4 ; * 16 8981 ;fefs_1: 8982 ; mov ax, [free_space.space+bx] 8983 ; and ax, ax 8984 ; jz short fefs_2 ; not a free space 8985 ; mov cl, [_i_] 8986 ; cmp ax, dx 8987 ; jnb short fefs_3 ; enough space 8988 ;fefs_2: 8989 ; ; 22/02/2019 8990 ; inc byte [_i_] 8991 ; cmp byte [_i_], ch 8992 ; jb short fefs_0 8993 ; sub ch, ch 8994 ; stc 8995 ; retn 8996 ;fefs_3: 8997 ; xor ch, ch 8998 ; retn 8999 9000 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9001 ; find enough free sectors 9002 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9003 9004 ; 15/03/2021 (fdisk4.s) 9005 ; ((32 bit registers, 32 bit cylinder numbers)) 9006 ; 15/02/2019 9007 find_enough_free_sectors: 9008 ; Find (first) enough free space in sectors 9009 ; 9010 ; INPUT: 9011 ; DX:AX = Requested space (as non-aligned free sectors) 9012 ; 22/02/2019 9013 ; [freespace_count] = number of free spaces/gaps 9014 ; OUTPUT: 9015 ; DX:AX = Available space 9016 ; If CF = 0 -> DX:AX >= Request 9017 ; If CF = 1 -> DX:AX < Request 9018 ; CX = Index of available space in free space structure 9019 ; (GAP number, 0 to 4) - if DX:AX > 0 - 9020 9021 ; 15/03/2021 9022 ; INPUT: 9023 ; EAX = Requested space (as non-aligned free sectors) 9024 ; [freespace_count] = number of free spaces/gaps 9025 ; OUTPUT: 9026 ; EAX = Available space 9027 ; If CF = 0 -> EAX >= Request 9028 ; If CF = 1 -> EAX < Request 9029 ; CX = Index of available space in free space structure 9030 ; (GAP number, 0 to 4) - if EAX > 0 - 9031 9032 ;xor di, di 9033 ;xor si, si 9034 ; 15/03/2021 9035 0000251F 6631D2 xor edx, edx 9036 9037 00002522 31DB xor bx, bx 9038 ; 22/02/2019 9039 00002524 8A2E[366C] mov ch, [freespace_count] 9040 00002528 891E[346C] mov [_i_], bx ; 0 9041 0000252C EB07 jmp short fefss_1 9042 fefss_0: 9043 ;mov al, 16 9044 ;mul byte [_i_] 9045 ;mov bx, ax 9046 0000252E 8B1E[346C] mov bx, [_i_] 9047 00002532 C0E304 shl bl, 4 ; * 16 9048 fefss_1: 9049 00002535 81C3[4E6D] add bx, free_space.sectors_unused 9050 ;cmp dx, [bx+2] 9051 ;jb short fefss_7 9052 ;ja short fefss_2 9053 ;cmp ax, [bx] 9054 ;je short fefss_8 9055 ;jb short fefss_7 ; 18/02/2019 9056 ; 15/03/2021 9057 00002539 663B07 cmp eax, [bx] 9058 0000253C 7426 je short fefss_8 ; available space 9059 ; = requested space 9060 0000253E 7221 jb short fefss_7 ; > requested space 9061 fefss_2: 9062 ; 30/10/2020 9063 ;;cmp word [bx], 0 9064 ;;jne short fefss_3 9065 ;;cmp word [bx+2], 0 9066 ;;je short fefss_6 9067 fefss_3: 9068 ;cmp di, [bx+2] 9069 ;ja short fefss_6 9070 ;je short fefss_4 9071 ;mov di, [bx+2] 9072 ;jmp short fefss_5 9073 fefss_4: 9074 ;cmp si, [bx] 9075 ;jnb short fefss_6 9076 ; 15/03/2021 9077 00002540 67663B3B cmp edi, [ebx] 9078 00002544 7307 jnb short fefss_6 9079 fefss_5: 9080 ;mov si, [bx] 9081 ; 15/03/2021 9082 00002546 668B17 mov edx, [bx] 9083 ; 22/02/2019 9084 00002549 8A0E[346C] mov cl, [_i_] 9085 fefss_6: 9086 0000254D FE06[346C] inc byte [_i_] 9087 00002551 382E[346C] cmp byte [_i_], ch ; [freespace_count] 9088 00002555 72D7 jb short fefss_0 9089 9090 ;mov ax, si 9091 ;mov dx, di 9092 ; 15/03/2021 9093 00002557 6689D0 mov eax, edx ; (max.) available space 9094 ; (< requested space) 9095 0000255A 6629D2 sub edx, edx 9096 ; 9097 0000255D 30ED xor ch, ch 9098 0000255F F9 stc 9099 00002560 C3 retn 9100 fefss_7: 9101 ;mov ax, [bx] 9102 ;mov dx, [bx+2] 9103 ; 15/03/2021 9104 00002561 668B07 mov eax, [bx] ; available space 9105 ; (> requested space) 9106 fefss_8: 9107 00002564 8B0E[346C] mov cx, [_i_] 9108 ; 15/03/2021 9109 00002568 6631D2 xor edx, edx 9110 ; 9111 0000256B C3 retn 9112 9113 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9114 ; get first free partition table entry 9115 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9116 9117 ; 16/02/2019 9118 get_first_free_pte: 9119 ; Find free partition table entry 9120 ; 9121 ; INPUT: 9122 ; none 9123 ; OUTPUT: 9124 ; If CF = 0 -> CX = partition table entry number 9125 ; If CF = 1 -> there is not a free entry in partition table 9126 9127 0000256C BE[AE54] mov si, MasterBootBuff+pTableOffset 9128 0000256F 31C9 xor cx, cx 9129 gffp_1: 9130 00002571 8A4404 mov al, [si+ptFileSystemID] ; 23/02/2019 9131 9132 00002574 20C0 and al, al 9133 00002576 740E jz short gffp_3 ; empty 9134 9135 00002578 80F903 cmp cl, 3 9136 0000257B 7307 jnb short gffp_2 9137 9138 0000257D FEC1 inc cl 9139 0000257F 83C610 add si, 16 ; Partition table entry size 9140 00002582 EBED jmp short gffp_1 9141 gffp_2: 9142 ; CL = 3 9143 00002584 F9 stc 9144 00002585 C3 retn 9145 gffp_3: 9146 ; CL = PTE number (0 to 3) 9147 00002586 C3 retn 9148 9149 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9150 ; convert cylinder count to sectors 9151 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9152 ; 03/02/2019 9153 9154 ; 15/03/2021 (fdisk4.s) 9155 ;cylinders_to_sectors: 9156 ; INPUT: 9157 ; ax = Cylinders (Total or partition's cylinder count) 9158 ; OUTPUT: 9159 ; dx:ax = Sectors 9160 9161 ; 15/03/2021 9162 ; INPUT: 9163 ; eax = cylinders (Total or partition's cyl count) 9164 ; OUTPUT: 9165 ; eax = sectors 9166 9167 ;;mov dx, [heads] 9168 ;;mul dx 9169 ;; 30/10/2020 9170 ;mul word [heads] 9171 ;; dx:ax = Number of tracks (cylinders*heads) 9172 ;mov cx, [sectors] 9173 ;call mul32 9174 ; ; dx:ax = Number of sectors 9175 ;retn 9176 9177 ; 15/03/2021 9178 ;mul dword [hs] ; [heads] * [sectors] 9179 ;; eax = number of sectors 9180 ;retn 9181 9182 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9183 ; convert cylinder count to percent of disk size (total cylinders) 9184 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9185 ; 03/02/2019 9186 9187 ; 12/03/2021 9188 ; 11/03/2021 (fdisk4.s) - 32 bit cylinder count- 9189 ; 9190 cylinders_to_percent: 9191 9192 ; INPUT: 9193 ; bx = Number of cylinders (of partition) -dividend- 9194 ; cx = Total cylinders -divisor- 9195 ; OUTPUT: 9196 ; ax = Percentage 9197 9198 ; if (cylinders_in == 0) 9199 ; percentage_out = 0; 9200 ; else if (total_cylinders == 0) 9201 ; percentage_out = 0; 9202 ; else 9203 9204 ; 11/03/2021 9205 ; INPUT: dword [cylinders] ; number of total disk cylinders 9206 ; eax = partition's cylinder count 9207 ; OUTPUT: ax = pencentage 9208 9209 ;or bx, bx 9210 ;jz short ctpc_6 ; ax = 0 = percentage_out 9211 ; 11/03/2021 9212 00002587 6609C0 or eax, eax 9213 0000258A 742B jz short ctpc_6 ; ax = 0 = percentage_out 9214 ctpc_1: 9215 ;or cx, cx 9216 ;jz short ctpc_6 9217 9218 0000258C 668B0E[BE3C] mov ecx, [cylinders] 9219 00002591 6609C9 or ecx, ecx 9220 00002594 7421 jz short ctpc_6 9221 9222 ;mov ax, 100 9223 ;mul bx ; [cylinders_in] 9224 ; ; dx:ax = Dividend 9225 ; 9226 ;mul edx 9227 9228 ;call div32 ; 100*cylinders_in / total_cylinders 9229 ; ; DX:AX = Quotient 9230 ; ; BX = Remainder 9231 9232 00002596 66BA64000000 mov edx, 100 9233 0000259C 66F7E2 mul edx 9234 0000259F 66F7F1 div ecx 9235 9236 ; ax = percentage_out 9237 9238 ; 12/03/2021 9239 000025A2 66D1E9 shr ecx, 1 9240 9241 ;cmp bx, cx ; is remainder >= total_cylinders/2 ? 9242 ;jb short ctpc_5 ; No. 9243 9244 000025A5 6639CA cmp edx, ecx ; is remainder >= total_cylinders/2 ? 9245 000025A8 7201 jb short ctpc_5 ; No. 9246 ctpc_4: 9247 000025AA 40 inc ax 9248 ctpc_5: 9249 ; 12/03/2021 9250 000025AB 66BA64000000 mov edx, 100 9251 ;cmp ax, 100 9252 000025B1 39D0 cmp ax, dx ; 100 9253 000025B3 7602 jbe short ctpc_6 9254 ;mov ax, 100 9255 000025B5 89D0 mov ax, dx 9256 ctpc_6: 9257 000025B7 C3 retn 9258 9259 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9260 ; display partition table 9261 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9262 ; 04/02/2019 9263 9264 ; 12/03/2021 9265 display_partition_table_x: 9266 000025B8 66B805000000 mov eax, 5 ; display extended partition table 9267 000025BE EB03 jmp short dpt_x 9268 9269 ; 11/03/2021 (fdisk4.s) 9270 display_partition_table: 9271 9272 ; INPUT: 9273 ; al = 0 for MBR 9274 ; = 5 for EBR (logical drives in extended partition) 9275 ; OUTPUT: 9276 ; none 9277 9278 ;pt_positions: 9279 n_pos equ 30 ; 1 byte 9280 9281 ; 12/03/2021 9282 000025C0 6631C0 xor eax, eax ; display primary partition table 9283 dpt_x: 9284 000025C3 A2[396C] mov [_e_], al 9285 9286 ; clear screen 9287 000025C6 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 9288 000025C9 CD10 int 10h 9289 9290 000025CB 803E[396C]05 cmp byte [_e_], 5 9291 000025D0 7507 jne short dpt_1 9292 dpt_0: 9293 000025D2 BD[EA6C] mov bp, ext_table_boot_ind 9294 000025D5 B045 mov al, 'E' 9295 000025D7 EB05 jmp short dpt_4 9296 dpt_1: 9297 000025D9 BD[8E6C] mov bp, part_table_boot_ind 9298 000025DC B04D mov al, 'M' 9299 dpt_4: 9300 000025DE BE[4A55] mov si, p_table_header 9301 000025E1 88441E mov [si+n_pos], al 9302 000025E4 E8E0F3 call print_msg 9303 9304 000025E7 31DB xor bx, bx 9305 000025E9 891E[346C] mov [_i_], bx 9306 dpt_5: 9307 000025ED FE06[346C] inc byte [_i_] 9308 9309 ; BX = partition entry (0 to 3) 9310 ; BP = partition table structure address 9311 9312 000025F1 E86400 call display_pt_entry ; display partition table row 9313 9314 000025F4 8B1E[346C] mov bx, [_i_] 9315 9316 000025F8 80FB04 cmp bl, 4 9317 000025FB 72F0 jb short dpt_5 9318 9319 000025FD BE[8B56] mov si, p_table_footer 9320 00002600 E8C4F3 call print_msg 9321 9322 ; 27/02/2019 9323 00002603 BF[A052] mov di, str_disk_sectors 9324 9325 00002606 803E[396C]05 cmp byte [_e_], 5 9326 0000260B 741A je short dpt_9 9327 9328 ; display total disk sectors 9329 9330 ;mov di, str_disk_sectors 9331 9332 ;cmp byte [di], '0' 9333 ;jnb short dpt_8 9334 9335 ;mov ax, [total_sectors] 9336 ;mov dx, [total_sectors+2] 9337 ; 11/03/2021 9338 0000260D 66A1[4A65] mov eax, [total_sectors] 9339 9340 00002611 E81F00 call dpt_10 9341 dpt_8: 9342 00002614 BE[8A52] mov si, msg_disk_sectors 9343 dpt_11: 9344 00002617 E8ADF3 call print_msg 9345 9346 0000261A BE[A052] mov si, str_disk_sectors 9347 0000261D E8A7F3 call print_msg 9348 9349 00002620 BE[7452] mov si, CRLF 9350 00002623 E8A1F3 call print_msg 9351 9352 00002626 C3 retn 9353 9354 dpt_9: 9355 ; display extended partition size 9356 9357 ;mov ax, [ep_Size] 9358 ;mov dx, [ep_Size+2] 9359 ; 11/03/2021 9360 00002627 66A1[2C6C] mov eax, [ep_Size] 9361 9362 0000262B E80500 call dpt_10 9363 9364 0000262E BE[AB52] mov si, msg_ep_size 9365 00002631 EBE4 jmp short dpt_11 9366 9367 dpt_10: 9368 00002633 89E6 mov si, sp 9369 ;mov cx, 10 9370 ; 11/03/2021 9371 00002635 66B90A000000 mov ecx, 10 9372 dpt_6: 9373 ;call div32 9374 9375 ;add bl, '0' 9376 ;push bx 9377 ;and ax, ax 9378 ;jnz short dpt_6 9379 ;and dx, dx 9380 ;jnz short dpt_6 9381 9382 0000263B 6631D2 xor edx, edx 9383 0000263E 66F7F1 div ecx 9384 ; 21/03/2021 9385 00002641 80C230 add dl, '0' 9386 00002644 52 push dx 9387 00002645 6621C0 and eax, eax 9388 00002648 75F1 jnz short dpt_6 9389 9390 0000264A 29E6 sub si, sp 9391 0000264C D1EE shr si, 1 9392 dpt_7: 9393 0000264E 58 pop ax 9394 0000264F AA stosb 9395 00002650 4E dec si 9396 00002651 75FB jnz short dpt_7 9397 9398 ;xor al, al 9399 00002653 6631C0 xor eax, eax ; 11/03/2021 9400 00002656 AA stosb 9401 9402 ; 27/02/2019 9403 00002657 C3 retn 9404 9405 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9406 ; display partition table entry/row 9407 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9408 ; 04/02/2019 9409 9410 ; 05/11/2020 9411 9412 struc ptbl 9413 9414 00000000 ?? .boot_ind: resb 1 9415 00000001 ?? .start_head: resb 1 9416 00000002 ?? .start_sector: resb 1 9417 ;.start_cyl: resw 1 9418 00000003 ???????? .start_cyl: resd 1 9419 00000007 ?? .sys_id: resb 1 9420 00000008 ?? .end_head: resb 1 9421 00000009 ?? .end_sector: resb 1 9422 ;.end_cyl: resw 1 9423 0000000A ???????? .end_cyl: resd 1 9424 ;.rel_sec_lw: resw 1 9425 ;.rel_sec_hw: resw 1 9426 0000000E ???????? .rel_sec: resd 1 9427 ;.num_sec_lw: resw 1 9428 ;.num_sec_hw: resw 1 9429 00000012 ???????? .num_sec: resd 1 9430 .size: ; 22 ; 05/11/2020 9431 9432 endstruc 9433 9434 ; 20/03/2021 (fdisk4.s) 9435 display_pt_entry: 9436 ; 24/10/2020 (fdisk3.s) 9437 9438 ; INPUT: 9439 ; bl = partition entry 9440 ; bh = 0 9441 ; bp = partition table structure address 9442 ; OUTPUT: 9443 ; none 9444 9445 ; 24/10/2020 (fdisk3.s) 9446 ;pt_positions: 9447 p_pos equ 3 ; 1 byte 9448 s_pos equ 6 ; 2+1 byte 9449 bh_pos equ 10 ; 2+1 bytes 9450 bs_pos equ 14 ; 2+1 bytes 9451 bc_pos equ 18 ; 2+1 bytes 9452 fs_pos equ 22 ; 2+1 bytes 9453 eh_pos equ 26 ; 2+1 bytes 9454 es_pos equ 30 ; 2+1 bytes 9455 ec_pos equ 34 ; 2+1 bytes 9456 rs_pos equ 42 ; 10 bytes 9457 ns_pos equ 53 ; 10 bytes 9458 fsx_pos equ 64 ; 14 bytes 9459 9460 ; 2019-2020 (hdimage.s) 9461 ;;pt_positions: 9462 ;p_pos equ 7 ; 1 byte 9463 ;s_pos equ 9 ; 2+1 byte 9464 ;bh_pos equ 13 ; 2+1 bytes 9465 ;bs_pos equ 17 ; 2+1 bytes 9466 ;bc_pos equ 21 ; 2+1 bytes 9467 ;fs_pos equ 25 ; 2+1 bytes 9468 ;eh_pos equ 29 ; 2+1 bytes 9469 ;es_pos equ 33 ; 2+1 bytes 9470 ;ec_pos equ 37 ; 2+1 bytes 9471 ;rs_pos equ 42 ; 7 bytes 9472 ;ns_pos equ 52 ; 7 bytes 9473 ;fsx_pos equ 61 ; 14 bytes 9474 9475 00002658 55 push bp ; 23/02/2019 9476 9477 00002659 08DB or bl, bl 9478 0000265B 7406 jz short dpte_0 9479 9480 ;xor bh, bh 9481 0000265D B016 mov al, ptbl.size ; 22 ; 05/11/2020 9482 0000265F F6E3 mul bl 9483 00002661 01C5 add bp, ax 9484 dpte_0: 9485 00002663 807E0700 cmp byte [bp+ptbl.sys_id], 0 9486 00002667 0F861501 jna dpte_9 9487 9488 0000266B B768 mov bh, 'h' 9489 9490 0000266D BE[3C6C] mov si, pte_row 9491 9492 ; clear partition table display buffer/row 9493 00002670 89F7 mov di, si 9494 00002672 B92800 mov cx, 40 9495 00002675 B82020 mov ax, 2020h 9496 00002678 F3AB rep stosw 9497 9498 0000267A 88D8 mov al, bl 9499 0000267C 0431 add al, '1' 9500 0000267E 884403 mov [si+p_pos], al ; partition number '1' to '4' 9501 9502 ; partition status, type and CHS parameters 9503 ; (as hexadecimal number) 9504 9505 ;mov al, [bp+ptbl.boot_ind] 9506 00002681 8A4600 mov al, [bp] 9507 00002684 E814F4 call byte_to_hex 9508 9509 00002687 894406 mov [si+s_pos], ax 9510 0000268A 887C08 mov [si+s_pos+2], bh ; 'h' 9511 9512 0000268D 8A4601 mov al, [bp+ptbl.start_head] 9513 00002690 E808F4 call byte_to_hex 9514 9515 00002693 89440A mov [si+bh_pos], ax 9516 00002696 887C0C mov [si+bh_pos+2], bh ; 'h' 9517 9518 00002699 8B4E03 mov cx, [bp+ptbl.start_cyl] 9519 ; 28/10/2020 9520 0000269C 81F9FF03 cmp cx, 1023 9521 000026A0 7603 jna short dpte_10 ; cyl number is in CHS limit 9522 000026A2 B9FF03 mov cx, 1023 ; fix cylinder number (to it's PTE value) 9523 ; to correct display PTE (CHS bytes) 9524 dpte_10: 9525 000026A5 C0E506 shl ch, 6 9526 000026A8 8A4602 mov al, [bp+ptbl.start_sector] 9527 000026AB 08E8 or al, ch 9528 000026AD E8EBF3 call byte_to_hex 9529 9530 000026B0 89440E mov [si+bs_pos], ax 9531 000026B3 887C10 mov [si+bs_pos+2], bh ; 'h' 9532 9533 ;mov al, [bp+ptbl.start_cyl] 9534 000026B6 88C8 mov al, cl 9535 000026B8 E8E0F3 call byte_to_hex 9536 9537 000026BB 894412 mov [si+bc_pos], ax 9538 000026BE 887C14 mov [si+bc_pos+2], bh ; 'h' 9539 9540 000026C1 8A4607 mov al, [bp+ptbl.sys_id] 9541 000026C4 E8D4F3 call byte_to_hex 9542 9543 000026C7 894416 mov [si+fs_pos], ax 9544 000026CA 887C18 mov [si+fs_pos+2], bh ; 'h' 9545 9546 000026CD 8A4608 mov al, [bp+ptbl.end_head] 9547 000026D0 E8C8F3 call byte_to_hex 9548 9549 000026D3 89441A mov [si+eh_pos], ax 9550 000026D6 887C1C mov [si+eh_pos+2], bh ; 'h' 9551 9552 000026D9 8B4E0A mov cx, [bp+ptbl.end_cyl] 9553 ; 28/10/2020 9554 000026DC 81F9FF03 cmp cx, 1023 9555 000026E0 7603 jna short dpte_11 ; cyl number is in CHS limit 9556 000026E2 B9FF03 mov cx, 1023 ; fix cylinder number (to it's PTE value) 9557 ; to correct display PTE (CHS bytes) 9558 dpte_11: 9559 000026E5 C0E506 shl ch, 6 9560 000026E8 8A4609 mov al, [bp+ptbl.end_sector] 9561 000026EB 08E8 or al, ch 9562 000026ED E8ABF3 call byte_to_hex 9563 9564 000026F0 89441E mov [si+es_pos], ax 9565 000026F3 887C20 mov [si+es_pos+2], bh ; 'h' 9566 9567 ;mov al, [bp+ptbl.end_cyl] 9568 000026F6 88C8 mov al, cl 9569 000026F8 E8A0F3 call byte_to_hex 9570 9571 000026FB 894422 mov [si+ec_pos], ax 9572 000026FE 887C24 mov [si+ec_pos+2], bh ; 'h' 9573 9574 ; relative (start) sector address (lba) 9575 ; (as decimal number) 9576 9577 ;mov ax, [bp+ptbl.rel_sec_lw] 9578 ;mov dx, [bp+ptbl.rel_sec_hw] 9579 ; 20/03/2021 9580 00002701 668B460E mov eax, [bp+ptbl.rel_sec] 9581 9582 00002705 89E7 mov di, sp 9583 ; 20/03/2021 9584 ;mov cx, 10 9585 00002707 6631C9 xor ecx, ecx 9586 0000270A B10A mov cl, 10 9587 dpte_1: 9588 ;call div32 9589 ; 20/03/2021 9590 0000270C 6631D2 xor edx, edx 9591 0000270F 66F7F1 div ecx 9592 9593 ;add bl, '0' 9594 ;push bx 9595 ; 20/03/2021 9596 00002712 80C230 add dl, '0' 9597 00002715 52 push dx ; ++* 9598 9599 ;and ax, ax 9600 ;jnz short dpte_1 9601 ;and dx, dx 9602 ;jnz short dpte_1 9603 ; 20/03/2021 9604 00002716 6621C0 and eax, eax 9605 00002719 75F1 jnz short dpte_1 9606 9607 0000271B 8D5C31 lea bx, [si+rs_pos+7] 9608 9609 0000271E 29E7 sub di, sp 9610 00002720 D1EF shr di, 1 9611 00002722 29FB sub bx, di 9612 dpte_2: 9613 00002724 58 pop ax ; ++* 9614 00002725 8807 mov [bx], al 9615 00002727 4F dec di 9616 00002728 7403 jz short dpte_3 9617 9618 0000272A 43 inc bx 9619 0000272B EBF7 jmp short dpte_2 9620 9621 dpte_3: 9622 ; number of sectors) 9623 ; (as decimal number) 9624 9625 ;mov ax, [bp+ptbl.num_sec_lw] 9626 ;mov dx, [bp+ptbl.num_sec_hw] 9627 ; 20/03/2021 9628 0000272D 668B4612 mov eax, [bp+ptbl.num_sec] 9629 9630 00002731 89E7 mov di, sp 9631 ;mov cx, 10 9632 dpte_4: 9633 ;call div32 9634 ; 20/03/2021 9635 00002733 31D2 xor dx, dx 9636 00002735 66F7F1 div ecx 9637 9638 ;add bl, '0' 9639 ;push bx 9640 ; 20/03/2021 9641 00002738 80C230 add dl, '0' 9642 0000273B 52 push dx ; ++** 9643 9644 ;and ax, ax 9645 ;jnz short dpte_4 9646 ;and dx, dx 9647 ;jnz short dpte_4 9648 ; 20/03/2021 9649 0000273C 6621C0 and eax, eax 9650 0000273F 75F2 jnz short dpte_4 9651 9652 00002741 8D5C3C lea bx, [si+ns_pos+7] 9653 9654 00002744 29E7 sub di, sp 9655 00002746 D1EF shr di, 1 9656 00002748 29FB sub bx, di 9657 dpte_5: 9658 0000274A 58 pop ax ; ++** 9659 0000274B 8807 mov [bx], al 9660 0000274D 4F dec di 9661 0000274E 7403 jz short dpte_6 9662 9663 00002750 43 inc bx 9664 00002751 EBF7 jmp short dpte_5 9665 dpte_6: 9666 ; set file system name 9667 9668 00002753 8A4607 mov al, [bp+ptbl.sys_id] 9669 00002756 BF[DA3D] mov di, valid_partitions 9670 00002759 B91300 mov cx, 19 9671 0000275C F2AE repnz scasb 9672 0000275E 7405 jz short dpte_7 9673 00002760 B8[CC3D] mov ax, FS_OTHERS 9674 00002763 EB0C jmp short dpte_8 9675 dpte_7: 9676 00002765 81EF[DB3D] sub di, valid_partitions + 1 9677 00002769 B80E00 mov ax, 14 9678 0000276C F7E7 mul di 9679 0000276E 05[C23C] add ax, FileSys_Names 9680 dpte_8: 9681 00002771 8D7C40 lea di, [si+fsx_pos] 9682 00002774 89C6 mov si, ax 9683 00002776 B107 mov cl, 7 9684 00002778 F3A5 rep movsw 9685 9686 0000277A BE[3C6C] mov si, pte_row 9687 0000277D E847F2 call print_msg 9688 dpte_9: 9689 00002780 5D pop bp ; 23/02/2019 9690 9691 00002781 C3 retn 9692 9693 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9694 ; fix partition table 9695 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9696 ; 24/02/2019 9697 9698 partition_table_fix: 9699 ; DELETE or EXIT option for Invalid Partition Table Entry 9700 ; INPUT: 9701 ; DS:SI = PTE address in MBR buffer 9702 9703 00002782 56 push si ; save PTE address 9704 9705 00002783 89F0 mov ax, si 9706 00002785 2D[AE54] sub ax, MasterBootBuff+446 9707 00002788 C0E804 shr al, 4 ; / 16 9708 0000278B 0431 add al, '1' 9709 0000278D A2[AC5B] mov [inv_pte_num], al 9710 9711 ; DS:SI = PTE address in MBR buffer 9712 00002790 E878F7 call show_selected_partition 9713 9714 ;mov si, CRLF 9715 ;call print_msg 9716 9717 ; Warning message... 9718 9719 00002793 BE[885B] mov si, msg_inv_pte 9720 00002796 E82EF2 call print_msg 9721 9722 00002799 5F pop di ; restore PTE address 9723 ptf_0: 9724 0000279A 30E4 xor ah, ah 9725 0000279C CD16 int 16h 9726 9727 0000279E 3C0D cmp al, 13 9728 000027A0 7406 je short ptf_1 9729 9730 000027A2 3C1B cmp al, 27 9731 000027A4 75F4 jne short ptf_0 9732 9733 000027A6 F9 stc 9734 000027A7 C3 retn 9735 ptf_1: 9736 ; Clear that (invalid) PTE 9737 000027A8 31C0 xor ax, ax 9738 000027AA B90800 mov cx, 8 9739 000027AD F3AB rep stosw 9740 9741 ; Clear screen 9742 000027AF B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 9743 000027B2 CD10 int 10h 9744 9745 000027B4 C3 retn 9746 9747 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9748 ; display (& edit) EXTENDED (DOS) partition table 9749 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9750 ; 28/02/2019 9751 9752 display_extended_pt: 9753 ; 12/03/2021 9754 ;mov al, 5 ; extended partition (logical drives) 9755 ;call display_partition_table 9756 000027B5 E800FE call display_partition_table_x 9757 9758 000027B8 BE[805D] mov si, ebr_editing_options 9759 000027BB E809F2 call print_msg 9760 9761 000027BE BE[355A] mov si, enter_opt_num_cancel_msg 9762 000027C1 E803F2 call print_msg 9763 9764 000027C4 BE[7452] mov si, CRLF 9765 000027C7 E8FDF1 call print_msg 9766 dept_1: 9767 000027CA 30E4 xor ah, ah 9768 000027CC CD16 int 16h 9769 9770 000027CE 3C30 cmp al, '0' 9771 000027D0 740C je short dept_2 9772 9773 000027D2 3C31 cmp al, '1' 9774 000027D4 7464 je short edit_ext_table_create 9775 000027D6 3C32 cmp al, '2' 9776 000027D8 7407 je short edit_ext_table_delete 9777 9778 000027DA 3C1B cmp al, 27 ; ESCape 9779 000027DC 75EC jne short dept_1 9780 dept_2: 9781 000027DE E9F2DB jmp A_42 9782 9783 edit_ext_table_delete: 9784 ; 28/02/2019 9785 ;mov al, 5 ; extended partition (logical drives) 9786 ;call display_partition_table 9787 ; 12/03/2021 9788 000027E1 E8D4FD call display_partition_table_x 9789 9790 000027E4 BE[FF5D] mov si, msg_delete_ldd_q 9791 000027E7 E8DDF1 call print_msg 9792 9793 ;mov si, CRLF 9794 ;call print_msg 9795 eetd_1: 9796 000027EA 30E4 xor ah, ah 9797 000027EC CD16 int 16h 9798 9799 000027EE 3C1B cmp al, 27 9800 000027F0 7410 je short eetd_2 9801 9802 000027F2 24DF and al, 0DFh 9803 000027F4 3C59 cmp al, 'Y' 9804 000027F6 7412 je short eetd_yes 9805 000027F8 3C4E cmp al, 'N' 9806 000027FA 75EE jne short eetd_1 9807 eetd_no: 9808 000027FC BE[B559] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 9809 000027FF E8C5F1 call print_msg 9810 eetd_2: 9811 00002802 BE[7452] mov si, CRLF ; Next line 9812 00002805 E8BFF1 call print_msg 9813 00002808 EBAB jmp short display_extended_pt 9814 eetd_yes: 9815 0000280A BE[AF59] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 9816 0000280D E8B7F1 call print_msg 9817 00002810 BE[7452] mov si, CRLF ; Next line 9818 00002813 E8B1F1 call print_msg 9819 00002816 E8F905 call delete_logical_drives 9820 00002819 803E[1C6A]00 cmp byte [ldrives], 0 9821 0000281E 7795 ja short display_extended_pt 9822 00002820 E9B0DB jmp A_42 9823 9824 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9825 ; logical drive count limit error 9826 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9827 9828 eetc_2: 9829 00002823 BE[655E] mov si, msg_create_ldd_max_error 9830 eetc_10: 9831 00002826 E89EF1 call print_msg 9832 00002829 BE[D052] mov si, msg_press_any_key 9833 0000282C E898F1 call print_msg 9834 0000282F 30E4 xor ah, ah 9835 00002831 CD16 int 16h 9836 00002833 EB80 jmp display_extended_pt 9837 9838 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9839 ; no free space in extended partition 9840 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9841 9842 ; 05/03/2019 9843 eetc_9: 9844 00002835 BE[9E60] mov si, msg_c_ldd_nofspc_error 9845 00002838 EBEC jmp short eetc_10 9846 9847 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9848 ; create logical dos drive in EXTENDED (DOS) partition 9849 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9850 ; 19/10/2020 (fdisk3.s) 9851 9852 ; 13/03/2021 9853 ; 12/03/2021 (fdisk4.s) 9854 edit_ext_table_create: ; 01/03/2019 (hdimage.s) 9855 9856 ; Create Method: ; 04/03/2019 9857 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 9858 ;LDD 2 <- LDD_START1, ebr 2nd entry <- EBR 1 9859 ;LDD 3 <- LDD_START2, ebr 2nd entry <- EBR 2 9860 ;LDD 4 <- LDD_START3, ebr 2nd entry <- EBR 3 9861 9862 ; 01/03/2019 9863 0000283A 803E[E96C]00 cmp byte [epnumber], 0 ; check extended partition 9864 0000283F 0F868DE4 jna B_07 ; cancel with error message 9865 9866 ; 05/03/2019 9867 00002843 E89602 call check_ext_free_space 9868 00002846 72ED jc eetc_9 ; error, no free space in extented partition 9869 9870 ; 30/10/2020 9871 ;mov [ep_free_sectors], ax 9872 ;mov [ep_free_sectors+2], dx 9873 ; 12/03/2021 9874 00002848 66A3[D46D] mov [ep_free_sectors], eax 9875 9876 0000284C 803E[1C6A]04 cmp byte [ldrives], 4 9877 00002851 73D0 jnb eetc_2 ; error, write program limit message 9878 9879 edit_ext_table_create_x: ; 02/03/2019 9880 9881 ; Get logical drive size/cylinders (request) from user 9882 00002853 E82903 call get_ldd_size 9883 ;cmp word [lcylinders], 1 ; at least 1 cylinder 9884 ;jb display_extended_pt ; cancel 9885 ; 13/03/2021 9886 00002856 66833E[D86D]01 cmp dword [lcylinders], 1 ; at least 1 cylinder 9887 0000285C 0F8255FF jb display_extended_pt ; cancel 9888 9889 ; 03/03/2019 9890 00002860 A0[1C6A] mov al, [ldrives] 9891 9892 ;cmp byte [ldrives], 1 9893 ;jnb short eetc_3 ; skip verify MBR extended partition 9894 9895 00002863 20C0 and al, al 9896 00002865 756C jnz short eetc_3 9897 9898 00002867 31ED xor bp, bp 9899 9900 ; Read MBR at EBR buffer 9901 ;xor ah, ah ; 19/10/2020 9902 ;xor dx, dx 9903 ; 09/03/2021 9904 00002869 6631C0 xor eax, eax 9905 9906 0000286C BB[226A] mov bx, ebr_buffer 9907 0000286F E864F1 call read_hd_sector 9908 00002872 7219 jc short eetc_0 9909 9910 ;mov al, [epnumber] 9911 ;cbw 9912 ;shl al, 4 ; * 16 9913 ; 13/03/2021 9914 ; eax = 0 9915 00002874 30ED xor ch, ch 9916 00002876 8A0E[E96C] mov cl, [epnumber] 9917 0000287A C0E104 shl cl, 4 ; * 16 9918 0000287D BE[E06B] mov si, ebr_buffer+446 9919 ;add si, ax 9920 00002880 01CE add si, cx 9921 00002882 BF[AE54] mov di, MasterBootBuff+446 9922 ;add di, ax 9923 00002885 01CF add di, cx 9924 ;mov cx, 8 9925 00002887 B108 mov cl, 8 9926 00002889 F3A7 repe cmpsw ; repeat comparising while cx > 0 and zf = 1 9927 0000288B E30A jcxz eetc_1 ; Extended partition entry is not changed 9928 ; Different PTE (means there is a new extended partition) 9929 eetc_0: 9930 ; Write current MBR (with modified PT) 9931 0000288D BB[F052] mov bx, MasterBootBuff 9932 ;xor ax, ax 9933 ;;xor dx, dx 9934 ; eax = 0 ; 13/03/2021 9935 00002890 E892F1 call write_hd_sector 9936 00002893 0F82C2DE jc print_error_code ; ! display error msg and then exit ! 9937 eetc_1: 9938 ; clear EBR buffer 9939 00002897 BF[226A] mov di, ebr_buffer 9940 ;xor ax, ax 9941 ; eax = 0 ; 13/03/2021 9942 ;mov cx, 255 9943 0000289A B1FF mov cl, 255 ; 13/03/2021 9944 0000289C F3AB rep stosw 9945 0000289E C70555AA mov word [di], 0AA55h 9946 9947 ; Set logical dos drive parameters in it's EBR 9948 000028A2 BF[E06B] mov di, ebr_buffer+446 9949 9950 ;mov cx, [sectors] 9951 ;sub bx, bx ; 0 9952 ; 13/03/2021 9953 000028A5 660FB70E[BA3C] movzx ecx, word [sectors] 9954 9955 ;mov ax, [ep_StartSector] 9956 ;mov dx, [ep_StartSector+2] 9957 ; 13/03/2021 9958 000028AB 66A1[246C] mov eax, [ep_StartSector] 9959 9960 ; 03/03/2019 9961 ; set partition start address & size 9962 9963 ;mov [ldd_start], ax 9964 ;mov [ldd_start+2], dx 9965 ; 13/03/2021 9966 000028AF 66A3[B46D] mov [ldd_start], eax 9967 9968 ; 01/11/2020 9969 ;cmp word [lcylinders], 65535 9970 ; ; sign for using all of available sectors 9971 ;jb short eetc_11 9972 ; 13/03/2021 9973 000028B3 66833E[D86D]FF cmp dword [lcylinders], 0FFFFFFFFh 9974 000028B9 7206 jb short eetc_11 9975 9976 ;mov ax, [ep_free_sectors] 9977 ;mov dx, [ep_free_sectors+2] 9978 ; 13/03/2021 9979 000028BB 66A1[D46D] mov eax, [ep_free_sectors] 9980 9981 000028BF EB09 jmp short eetc_12 9982 eetc_11: 9983 ;mov al, [heads] 9984 ;mul byte [sectors] 9985 ;mul word [lcylinders] 9986 ; 13/03/2021 9987 000028C1 66A1[086A] mov eax, [hs] ; [heads] * [sectors] 9988 000028C5 66F726[D86D] mul dword [lcylinders] 9989 eetc_12: 9990 ; 01/11/2020 9991 000028CA 31ED xor bp, bp 9992 ;mov [ldd_size], ax 9993 ;mov [ldd_size+2], dx 9994 ; 13/03/2021 9995 000028CC 66A3[C46D] mov [ldd_size], eax 9996 9997 ; 1st ldd start sector is always 63 or 17 (= spt) 9998 ;sub ax, cx ; cx = 63 or 17, [sectors] 9999 ;sbb dx, bx ; sbb dx, 0 10000 10001 ; 01/11/2020 10002 000028D0 E9B700 jmp eetc_4 10003 10004 ;mov [di+ptStartSector], cx 10005 ;mov [di+ptStartSector+2], bx 10006 ; 10007 ;; 01/11/2020 10008 ;mov [di+ptSectors], ax 10009 ;mov [di+ptSectors+2], dx 10010 ; 10011 ;mov cx, ax 10012 ;mov bx, dx 10013 ;; cx:bx = volume size of logical -dos- drive 10014 ; 10015 ;pop ax ; ldd's LBA 10016 ;pop dx 10017 ;; dx:ax = start sector address of ldd 10018 ; 10019 ;; 01/11/2020 10020 ;add cx, ax 10021 ;adc bx, dx 10022 ;sub cx, 1 10023 ;sbb bx, 0 10024 ;; bx:cx = end sector address of ldd 10025 ;push cx 10026 ;push bx 10027 ; 10028 ;jmp eetc_4 10029 10030 eetc_3: 10031 ; [ldrives] >= 1 10032 ; Read EBR 10033 ;mov al, [ldrives] 10034 000028D3 30E4 xor ah, ah ; 02/11/2020 10035 000028D5 C0E002 shl al, 2 10036 000028D8 89C5 mov bp, ax 10037 10038 ; 03/03/2019 10039 ;mov ax, [bp+ldd_start-4] 10040 ;mov dx, [bp+ldd_start-2] 10041 ; 09/03/2021 10042 000028DA 668B86[B06D] mov eax, [bp+ldd_start-4] 10043 10044 000028DF BB[226A] mov bx, ebr_buffer 10045 000028E2 E8F1F0 call read_hd_sector 10046 000028E5 0F8270DE jc print_error_code ; ! display error msg and then exit ! 10047 10048 ; 04/03/2019 10049 000028E9 BE[F06B] mov si, ebr_buffer+446+16 ; 2nd entry (next EBR) 10050 10051 ; 03/03/2019 10052 ;mov ax, [bp+ldd_start-4] 10053 ;mov dx, [bp+ldd_start-2] 10054 ;add ax, [bp+ldd_size-4] 10055 ;adc dx, [bp+ldd_size-2] 10056 ; 13/03/2021 10057 000028EC 668B86[B06D] mov eax, [bp+ldd_start-4] 10058 000028F1 660386[C06D] add eax, [bp+ldd_size-4] 10059 10060 ;mov cx, [ep_StartSector] 10061 ;mov bx, [ep_StartSector+2] 10062 ; 13/03/2021 10063 000028F6 668B16[246C] mov edx, [ep_StartSector] 10064 10065 ;mov [bp+ldd_start], ax 10066 ;mov [bp+ldd_start+2], dx 10067 ; 13/03/2021 10068 000028FB 668986[B46D] mov [bp+ldd_start], eax 10069 10070 ;push dx ; ldd's start sector LBA 10071 ;push ax 10072 ; 13/03/2021 10073 00002900 6650 push eax ; * 10074 10075 ;sub ax, cx 10076 ;sbb dx, bx 10077 ;; dx:ax = offset from start of the ep start sector 10078 ; 13/03/2021 10079 00002902 6629D0 sub eax, edx 10080 ; eax = offset from start of the ep start sector 10081 10082 ;mov [si+ptStartSector], ax 10083 ;mov [si+ptStartSector+2], dx 10084 ; 13/03/2021 10085 00002905 66894408 mov [si+ptStartSector], eax 10086 10087 ; 01/11/2020 10088 ;cmp word [lcylinders], 65535 10089 ; ; sign for using all of available sectors 10090 ;jb short eetc_13 10091 ; 13/03/2021 10092 00002909 66833E[D86D]FF cmp dword [lcylinders], 0FFFFFFFFh 10093 0000290F 7206 jb short eetc_13 10094 10095 ;mov ax, [ep_free_sectors] 10096 ;mov dx, [ep_free_sectors+2] 10097 ; 13/03/2021 10098 00002911 66A1[D46D] mov eax, [ep_free_sectors] 10099 10100 00002915 EB09 jmp short eetc_14 10101 eetc_13: 10102 ;mov al, [heads] 10103 ;mul byte [sectors] 10104 ;mul word [lcylinders] 10105 ; 13/03/2021 10106 00002917 66A1[086A] mov eax, [hs] ; [heads] * [sectors] 10107 0000291B 66F726[D86D] mul dword [lcylinders] 10108 eetc_14: 10109 ; 01/11/2020 10110 ;mov [bp+ldd_size], ax 10111 ;mov [bp+ldd_size+2], dx 10112 ; 13/03/2021 10113 00002920 668986[C46D] mov [bp+ldd_size], eax 10114 10115 ;mov [si+ptSectors], ax 10116 ;mov [si+ptSectors+2], dx 10117 ; 13/03/2021 10118 00002925 6689440C mov [si+ptSectors], eax 10119 10120 ; 01/11/2020 10121 ;mov cx, ax 10122 ;mov bx, dx 10123 ;; cx:bx = volume size of logical -dos- drive 10124 ; 13/03/2021 10125 00002929 6689C2 mov edx, eax ; ldd's volume size 10126 10127 ;pop ax ; ldd's start sector LBA 10128 ;pop dx 10129 ; 13/03/2021 10130 0000292C 6658 pop eax ; * 10131 10132 ; 01/11/2020 10133 ;add cx, ax 10134 ;adc bx, dx 10135 ; 13/03/2021 10136 0000292E 6601C2 add edx, eax ; ldd's start sector LBA 10137 10138 ;sub cx, 1 10139 ;sbb bx, 0 10140 ;; bx:cx = end sector address of ldd 10141 ; 13/03/2021 10142 00002931 664A dec edx ; end sector address of ldd 10143 10144 ;push cx 10145 ;push bx 10146 ; 13/03/2021 10147 00002933 6652 push edx ; ** 10148 10149 ; calculate CHS from LBA 10150 00002935 E8D801 call lba_to_chs 10151 ; ax = cylinder 10152 ; dl = sector 10153 ; dh = head 10154 10155 00002938 C60400 mov byte [si+ptBootable], 0 10156 0000293B 887401 mov [si+ptBeginHead], dh 10157 0000293E 884403 mov [si+ptBeginCylinder], al 10158 00002941 C0E406 shl ah, 6 10159 00002944 08E2 or dl, ah 10160 00002946 885402 mov [si+ptBeginSector], dl 10161 10162 ;;mov ax, [si+ptSectors] 10163 ;;mov dx, [si+ptSectors+2] 10164 ;mov ax, [bp+ldd_size] 10165 ;mov dx, [bp+ldd_size+2] 10166 ;sub ax, 1 10167 ;sbb dx, 0 10168 ;add ax, [bp+ldd_start] 10169 ;adc dx, [bp+ldd_start+2] 10170 ; ; dx:ax = end sector 10171 10172 ; 01/11/2020 10173 ;pop ax 10174 ;pop dx 10175 ;; dx:ax = end sector address of ldd 10176 ; 13/03/2021 10177 00002949 6658 pop eax ; ** 10178 10179 0000294B E8C201 call lba_to_chs 10180 ; ax = cylinder 10181 ; dl = sector 10182 ; dh = head 10183 ; 24/10/2020 10184 ; bl = Extended partition ID 10185 10186 ; 13/03/2021 10187 0000294E 6631C9 xor ecx, ecx 10188 10189 ;mov byte [si+ptFileSystemID], 5 ; EXTENDED 10190 ; 24/10/2020 10191 00002951 885C04 mov [si+ptFileSystemID], bl ; EXTENDED ; 05h or 0Fh 10192 ; 10193 00002954 887405 mov [si+ptEndHead], dh 10194 00002957 884407 mov [si+ptEndCylinder], al 10195 0000295A C0E406 shl ah, 6 10196 0000295D 08D4 or ah, dl 10197 0000295F 886406 mov [si+ptEndSector], ah 10198 10199 ; Write EBR 10200 ;mov ax, [bp+ldd_start-4] 10201 ;mov dx, [bp+ldd_start-2] 10202 ; 13/03/2021 10203 00002962 668B86[B06D] mov eax, [bp+ldd_start-4] 10204 10205 00002967 BB[226A] mov bx, ebr_buffer 10206 0000296A E8B8F0 call write_hd_sector 10207 0000296D 0F82E8DD jc print_error_code ; ! display error msg and then exit ! 10208 10209 ; clear EBR buffer 10210 00002971 BF[226A] mov di, ebr_buffer 10211 00002974 31C0 xor ax, ax 10212 ;mov cx, 255 10213 ; 13/03/2021 10214 00002976 B1FF mov cl, 255 10215 00002978 F3AB rep stosw 10216 0000297A C70555AA mov word [di], 0AA55h 10217 10218 0000297E BF[E06B] mov di, ebr_buffer+446 ; 1st entry points to LDD 10219 10220 ;mov cx, [sectors] 10221 ;sub bx, bx ; 0 10222 ; 13/03/2021 10223 00002981 8A0E[BA3C] mov cl, [sectors] 10224 ; ecx = [sectors] 10225 10226 ; 01/11/2020 10227 ;mov ax, [bp+ldd_size] 10228 ;mov dx, [bp+ldd_size+2] 10229 ; 13/03/2021 10230 00002985 668B86[C46D] mov eax, [bp+ldd_size] 10231 10232 ;sub ax, cx 10233 ;sbb dx, bx ; sbb dx, 0 10234 eetc_4: 10235 ;mov [di+ptStartSector], cx 10236 ;mov [di+ptStartSector+2], bx 10237 ; 13/03/2021 10238 0000298A 66894D08 mov [di+ptStartSector], ecx 10239 10240 ; 01/11/2020 10241 ; 1st ldd start sector is always 63 or 17 (= spt) 10242 ;sub ax, cx ; cx = 63 or 17, [sectors] 10243 ;sbb dx, bx ; sbb dx, 0 10244 ; 13/03/2021 10245 0000298E 6629C8 sub eax, ecx 10246 10247 ; 01/11/2020 10248 ;mov [di+ptSectors], ax 10249 ;mov [di+ptSectors+2], dx 10250 ; 13/03/2021 10251 00002991 6689450C mov [di+ptSectors], eax 10252 10253 ;mov cx, [bp+ldd_size] 10254 ;mov bx, [bp+ldd_size+2] 10255 ;; cx:bx = volume size of logical -dos- drive 10256 ; 13/03/2021 10257 00002995 668B96[C46D] mov edx, [bp+ldd_size] 10258 10259 ;mov ax, [bp+ldd_start] 10260 ;mov dx, [bp+ldd_start+2] 10261 ;; dx:ax = start sector address of ldd (EBR addr) 10262 ; 13/03/2021 10263 0000299A 668B86[B46D] mov eax, [bp+ldd_start] 10264 10265 ; 01/11/2020 10266 ;add cx, ax 10267 ;adc bx, dx 10268 ;sub cx, 1 10269 ;sbb bx, 0 10270 ;; bx:cx = end sector address of ldd 10271 ; 13/03/2021 10272 0000299F 6601C2 add edx, eax 10273 000029A2 664A dec edx 10274 10275 ;push bx 10276 ;push cx 10277 ; 13/03/2021 10278 000029A4 6652 push edx ; *** 10279 ;eetc_4: 10280 ; 01/11/2020 10281 ; stack = end sector address of ldd 10282 ; dx:ax = start sector address of ldd 10283 10284 ; calculate CHS from LBA 10285 10286 000029A6 E86701 call lba_to_chs 10287 ; ax = cylinder 10288 ; dl = sector 10289 ; dh = head 10290 10291 ;mov byte [di+ptBootable], 0 10292 000029A9 887501 mov [di+ptBeginHead], dh 10293 000029AC 884503 mov [di+ptBeginCylinder], al 10294 ;mov bl, ah 10295 ;shl bl, 6 10296 ;or dl, bl 10297 ; 01/11/2020 10298 000029AF C0E406 shl ah, 6 10299 000029B2 08E2 or dl, ah 10300 000029B4 885502 mov [di+ptBeginSector], dl 10301 10302 ;add ax, [lcylinders] 10303 ;dec ax ; end cylinder 10304 ;mov bx, ax 10305 10306 ; 01/11/2020 10307 ;pop ax 10308 ;pop dx 10309 ;; dx:ax = end sector address of ldd 10310 ; 13/03/2021 10311 000029B7 6658 pop eax ; *** 10312 10313 000029B9 E85401 call lba_to_chs 10314 ; ax = cylinder number (0-1023) 10315 ; dl = sector 10316 ; dh = head 10317 ; 01/11/2020 10318 ; cx = cylinder number (0-65535) 10319 ; 13/03/2021 10320 ; ecx = cylinder number (0-267349) 10321 10322 ;; 02/11/2020 10323 ;;mov [endcyl], cx ; 01/11/2020 10324 ;xchg [endcyl], cx 10325 ; cx = end cylinder of the ep 10326 ; [endcyl] = end cylinder of the ldd 10327 ; 13/03/2021 10328 000029BC 66870E[DE6D] xchg [endcyl], ecx 10329 10330 ;mov [di+ptFileSystemID], 0 10331 ;mov cx, [heads] 10332 ;dec cl 10333 ;mov [di+ptEndHead], cl 10334 ; 01/11/2020 10335 000029C1 887505 mov [di+ptEndHead], dh 10336 10337 000029C4 884507 mov [di+ptEndCylinder], al 10338 ;mov dx, [sectors] 10339 000029C7 C0E406 shl ah, 6 10340 000029CA 08D4 or ah, dl 10341 000029CC 886506 mov [di+ptEndSector], ah 10342 10343 ; 02/03/2019 10344 ; Check unused space if it is 3rd LDD 10345 ; (write message to add unused space.) 10346 10347 ; 02/11/2020 10348 ;cmp byte [ldrives], 3 10349 ;jb eetc_7 10350 10351 ; 01/11/2020 10352 ;cmp word [lcylinders], 65535 10353 ; ; sign for using all of available sectors 10354 ;jnb eetc_7 ; no need to add unused sector 10355 ; ; (there are not any unused sectors) 10356 ; 13/03/2021 10357 000029CF 66833E[D86D]FF cmp dword [lcylinders], 0FFFFFFFFh 10358 000029D5 0F83A200 jnb eetc_7 ; no need to add unused sector 10359 10360 ; cx = cylinder number (0 to 65535) 10361 ; 13/03/2021 10362 ; ecx = cylinder number (0 to 267349) 10363 10364 ; 02/11/2020 10365 000029D9 803E[1C6A]03 cmp byte [ldrives], 3 ; is this logical drive 4 ? 10366 000029DE 730B jnb short eetc_17 10367 ; force to show unused space message 10368 10369 ; 02/11/2020 10370 ; (add unused space if cyl nums are same or diff is 1) 10371 ;dec cx ; tolerate cylinder numbers n and n-1 10372 ;cmp cx, [endcyl] 10373 ;ja eetc_7 ; the end cyl number of the last ldd 10374 ; ; is 2 or more cyls less than 10375 ; ; the end cyl number of the ep 10376 ; ; (a next ldd can be added to 10377 ; ; extd partition with 2 or more cyls) 10378 ; 13/03/2021 10379 000029E0 6649 dec ecx 10380 000029E2 663B0E[DE6D] cmp ecx, [endcyl] 10381 000029E7 0F879000 ja eetc_7 10382 eetc_17: 10383 ; 02/11/2020 10384 000029EB A0[1C6A] mov al, [ldrives] 10385 ;add al, '0' 10386 000029EE 0431 add al, '1' ; 03/11/2020 10387 000029F0 A2[DD5E] mov [char_lddn], al 10388 10389 ;mov al, [sectors] 10390 ;mov bh, al 10391 ;mov bl, [heads] 10392 ;dec bl 10393 ;mul bl ; [sectors] * [heads] - 1 10394 ; 13/03/2021 10395 000029F3 66A1[086A] mov eax, [hs] ; [sectors] * [heads] 10396 000029F7 6648 dec eax ; [sectors] * [heads] - 1 10397 10398 ;push ax 10399 ; 13/03/2021 10400 000029F9 6650 push eax ; **** 10401 10402 ;mov al, bh ; [sectors] 10403 ;;mul byte [heads] 10404 ;inc bl 10405 ;mul bl 10406 ; ; ax = heads * sectors 10407 ;;mul cx ; * end cylinder 10408 ;mul word [endcyl] ; 02/11/2020 10409 ; ; dx:ax = end cylinder * heads * sectors 10410 ; 13/03/2021 10411 000029FB 6640 inc eax ; heads * sectors 10412 000029FD 66F726[DE6D] mul dword [endcyl] 10413 ; eax = ((cylinders-1) * heads * sectors) 10414 10415 ;pop cx 10416 ;add ax, cx ; + (sectors * (heads - 1)) 10417 ;adc dx, 0 10418 ; 13/03/2021 10419 00002A02 665A pop edx ; **** 10420 00002A04 6601D0 add eax, edx ; + (sectors * (heads - 1)) 10421 10422 ; 03/03/2019 10423 ;mov cx, [sectors] 10424 ;dec cl ; [sectors] - 1 10425 ;add ax, cx ; + (sectors - 1) 10426 ;adc dx, 0 10427 ; ; DX:AX = end LBA 10428 ; 13/03/2021 10429 00002A07 6631D2 xor edx, edx 10430 00002A0A 8A16[BA3C] mov dl, [sectors] 10431 00002A0E FECA dec dl ; [sectors] - 1 10432 00002A10 6601D0 add eax, edx ; + (sectors - 1) 10433 10434 ;mov cx, [ep_EndSector] 10435 ;mov bx, [ep_EndSector+2] 10436 ; 13/03/2021 10437 00002A13 668B16[286C] mov edx, [ep_EndSector] 10438 10439 ;cmp dx, bx 10440 ;jne short eetc_5 10441 ;cmp ax, cx 10442 ;je short eetc_7 ; 05/03/2019 10443 ; 13/03/2021 10444 00002A18 6639D0 cmp eax, edx 10445 00002A1B 745E je short eetc_7 10446 eetc_5: 10447 ;push bx 10448 00002A1D BE[9A5E] mov si, msg_c_ldd_unused_warning 10449 00002A20 E8A4EF call print_msg 10450 ;pop bx 10451 eetc_6: 10452 00002A23 28E4 sub ah, ah 10453 00002A25 CD16 int 16h 10454 00002A27 3C0D cmp al, 13 ; ENTER 10455 00002A29 7450 je short eetc_7 ; continue 10456 00002A2B 3C1B cmp al, 27 ; ESC 10457 00002A2D 75F4 jne short eetc_6 10458 10459 ; 03/03/2019 10460 ; change end cylinder value 10461 00002A2F A0[E96C] mov al, [epnumber] 10462 00002A32 FEC8 dec al 10463 ;mov ah, 18 ; primary partition table structure size 10464 ; 05/11/2020 10465 00002A34 B416 mov ah, 22 ; primary partition table structure size 10466 00002A36 F6E4 mul ah 10467 00002A38 89C6 mov si, ax 10468 ;mov ax, [si+part_table_end_cyl] 10469 ; 02/11/2020 10470 ;mov [endcyl], ax ; end cylinder of the ep 10471 ; 13/03/2021 10472 00002A3A 668B84[986C] mov eax, [si+part_table_end_cyl] 10473 00002A3F 66A3[DE6D] mov [endcyl], eax ; end cylinder of the ep 10474 eetc_19: 10475 ; 03/11/2020 10476 ;cmp ax, 1023 ; overs CHS limit ? 10477 ;jna short eetc_20 ; no 10478 ;mov ax, 1023 ; 03FFh ; fix end CHS values of the PTE 10479 ; 13/03/2021 10480 00002A43 663DFF030000 cmp eax, 1023 10481 00002A49 7606 jna short eetc_20 10482 00002A4B 66B8FF030000 mov eax, 1023 10483 eetc_20: 10484 00002A51 884507 mov [di+ptEndCylinder], al 10485 00002A54 8A84[976C] mov al, [si+part_table_end_sector] 10486 00002A58 C0E406 shl ah, 6 10487 00002A5B 08C4 or ah, al 10488 00002A5D 886506 mov [di+ptEndSector], ah 10489 00002A60 8A84[966C] mov al, [si+part_table_end_head] 10490 00002A64 884505 mov [di+ptEndHead], al 10491 10492 ;mov ax, cx 10493 ;mov dx, bx 10494 ;add ax, 1 10495 ;adc dx, 0 10496 ; ; dx:ax = end of extd partition + 1 10497 ; 13/03/2021 10498 00002A67 6689D0 mov eax, edx 10499 00002A6A 6648 dec eax 10500 10501 ; 02/11/2020 10502 ;sub ax, [bp+ldd_start] 10503 ;sbb dx, [bp+ldd_start+2] 10504 ;sub ax, [di+ptStartSector] 10505 ;sbb dx, [di+ptStartSector+2] 10506 ; ; dx:ax = new sector count of the ldd 10507 ; 13/03/2021 10508 00002A6C 662B86[B46D] sub eax, [bp+ldd_start] 10509 00002A71 662B4508 sub eax, [di+ptStartSector] 10510 10511 ;mov [di+ptSectors], ax 10512 ;mov [di+ptSectors+2], dx 10513 ; 13/03/2021 10514 00002A75 6689450C mov [di+ptSectors], eax 10515 10516 00002A79 EB04 jmp short eetc_8 10517 eetc_7: 10518 ;mov ax, [di+ptSectors] 10519 ;mov dx, [di+ptSectors+2] 10520 ; 13/03/2021 10521 00002A7B 668B450C mov eax, [di+ptSectors] 10522 eetc_8: 10523 ; 13/03/2021 10524 ;xor edx, edx 10525 ; 01/11/2020 10526 ;cmp word [endcyl], 1023 10527 ;jna short eetc_15 10528 ; 13/03/2021 10529 00002A7F 66813E[DE6D]FF0300- cmp dword [endcyl], 1023 10529 00002A87 00 10530 00002A88 7605 jna short eetc_15 10531 10532 ; 25/10/2020 10533 ;mov cx, [bp+ldd_start] 10534 ;mov bx, [bp+ldd_start+2] 10535 ;; 01/11/2020 10536 ;add cx, [bp+ldd_size] 10537 ;adc bx, [bp+ldd_size+2] 10538 ;sub cx, 1 ; * 10539 ;sbb bx, 0 ; * 10540 ;cmp bx, [chs_limit+2] 10541 ;jb short eetc_15 10542 ;ja short eetc_19 10543 ;cmp cx, [chs_limit] 10544 ;jna short eetc_15 10545 ;eetc_19: 10546 00002A8A E8D900 call size_to_fat_type_lba ; 25/10/2020 10547 00002A8D EB03 jmp short eetc_16 10548 eetc_15: 10549 ; Get proper FAT type in [ldd_type] 10550 ; by using DX:AX - size - 10551 00002A8F E8B500 call size_to_fat_type 10552 eetc_16: 10553 00002A92 884504 mov [di+ptFileSystemID], al 10554 10555 ; 13/03/2021 10556 ; edx < 65536 10557 10558 ; Write current EBR (with modified PT) 10559 ;mov ax, [bp+ldd_start] 10560 ;mov dx, [bp+ldd_start+2] 10561 00002A95 668B86[B46D] mov eax, [bp+ldd_start] 10562 10563 ; 01/11/2020 10564 ; ! safety ! (to protect MBR and primary partition) 10565 ;eetc_16: 10566 ;cmp dx, [ep_StartSector+2] 10567 ;jb short eetc_18 10568 ;ja short eetc_17 10569 ;cmp ax, [ep_StartSector] 10570 ;jna short eetc_18 10571 ;eetc_17: 10572 ;mov ah, 0FFh 10573 ;jmp print_error_code 10574 ;eetc_18: 10575 10576 00002A9A BB[226A] mov bx, ebr_buffer 10577 00002A9D E885EF call write_hd_sector 10578 00002AA0 0F82B5DC jc print_error_code ; ! display error msg and then exit ! 10579 10580 00002AA4 A0[1C6A] mov al, [ldrives] 10581 ;mov ah, 18 ; extended partition table structure size 10582 ; 05/11/2020 10583 00002AA7 B416 mov ah, 22 ; extended partition table structure size 10584 00002AA9 F6E4 mul ah 10585 10586 00002AAB 89C6 mov si, ax 10587 00002AAD 81C6[EA6C] add si, ext_table_boot_ind 10588 00002AB1 87F7 xchg si, di 10589 10590 ; set partition (logical -dos- drive) data 10591 00002AB3 A5 movsw ; boot indicator, beginning head 10592 00002AB4 AC lodsb 10593 00002AB5 88C4 mov ah, al 10594 00002AB7 243F and al, 3Fh 10595 00002AB9 AA stosb ; beginning sector 10596 00002ABA C0EC06 shr ah, 6 10597 00002ABD AC lodsb ; beginning cylinder 10598 00002ABE AB stosw 10599 ; 21/03/2021 10600 00002ABF 31C0 xor ax, ax 10601 00002AC1 AB stosw 10602 00002AC2 A5 movsw ; partition id, end head 10603 00002AC3 AC lodsb 10604 00002AC4 88C4 mov ah, al 10605 00002AC6 243F and al, 3Fh 10606 00002AC8 AA stosb ; end sector 10607 00002AC9 C0EC06 shr ah, 6 10608 00002ACC AC lodsb ; end cylinder 10609 00002ACD AB stosw 10610 ; 21/03/2021 10611 00002ACE 31C0 xor ax, ax 10612 00002AD0 AB stosw 10613 10614 00002AD1 A5 movsw ; copy start sector (LBA) and sector count 10615 00002AD2 A5 movsw 10616 00002AD3 A5 movsw 10617 00002AD4 A5 movsw 10618 10619 00002AD5 FE06[1C6A] inc byte [ldrives] 10620 10621 00002AD9 E9D9FC jmp display_extended_pt 10622 10623 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10624 ; check free space in EXTENDED (DOS) partition 10625 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10626 ; 05/03/2019 10627 10628 ; 12/03/2021 (fdisk4.s, 32 bit registers) 10629 check_ext_free_space: 10630 ;mov ax, [ep_Size] 10631 ;mov dx, [ep_Size+2] 10632 00002ADC 66A1[2C6C] mov eax, [ep_Size] 10633 ; 12/03/2021 10634 00002AE0 6631DB xor ebx, ebx 10635 00002AE3 8A1E[1C6A] mov bl, [ldrives] 10636 00002AE7 20DB and bl, bl 10637 00002AE9 7421 jz short cefs_1 10638 00002AEB 80FB04 cmp bl, 4 10639 00002AEE 7602 jna short cefs_0 10640 00002AF0 B304 mov bl, 4 10641 cefs_0: 10642 00002AF2 FECB dec bl 10643 00002AF4 C0E302 shl bl, 2 ; * 4 10644 ;xor bh, bh 10645 ;mov si, bx 10646 10647 ;mov cx, [si+ldd_start] 10648 ;mov bx, [si+ldd_start+2] 10649 ;add cx, [si+ldd_size] 10650 ;adc bx, [si+ldd_size+2] 10651 ; 12/03/2021 10652 00002AF7 668B97[B46D] mov edx, [bx+ldd_start] 10653 00002AFC 660397[C46D] add edx, [bx+ldd_size] 10654 10655 ;add ax, [ep_StartSector] 10656 ;adc dx, [ep_StartSector+2] 10657 00002B01 660306[246C] add eax, [ep_StartSector] 10658 10659 ;sub ax, cx 10660 ;sbb dx, bx 10661 10662 00002B06 6629D0 sub eax, edx 10663 00002B09 7501 jnz short cefs_1 10664 10665 ;or ax, ax 10666 ;jnz short cefs_1 10667 10668 ; cf = 0 if the result not negative 10669 10670 00002B0B F9 stc 10671 10672 ; cf = 1 if the result is negative or zero 10673 10674 ; If cf = 0 -> There is free space as in DX:AX 10675 ; NOTE: This calculation is unsafe if 10676 ; logical dos drive count > 4 ! 10677 ; (But still meaningful for creating a new ldd. 10678 ; Because a new ldd will be created only 10679 ; if ldd count < 4.) 10680 cefs_1: 10681 ; 12/03/2021 10682 00002B0C 6689DA mov edx, ebx ; edx < 65536 10683 ; eax = free space (sectors) 10684 00002B0F C3 retn 10685 10686 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10687 ; convert LBA to CHS parameters (in registers) 10688 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10689 ; 24/10/2020 10690 10691 ; 21/03/2021 10692 ; 13/03/2021 (fdisk4.s) 10693 ; 01/03/2019 (hdimage.s) 10694 lba_to_chs: 10695 ; INPUT: 10696 ; DX:AX = LBA address 10697 ; OUTPUT: 10698 ; AX = cylinder 10699 ; DL = sector 10700 ; DH = head 10701 ; 24/10/2020 10702 ; BL = extended partition ID (05h, 0Fh) 10703 ; 10704 ; (modified registers: ax, bx, cx, dx) 10705 10706 ; 13/03/2021 10707 ; 10708 ; INPUT: 10709 ; EAX = LBA address 10710 ; OUTPUT: 10711 ; EAX = cylinder (<= 1023) 10712 ; DL = sector 10713 ; DH = head 10714 ; 10715 ; ECX = cylinder 10716 10717 ;mov cx, [sectors] 10718 ;call div32 10719 ;inc bl 10720 ; 13/03/2021 10721 00002B10 6629D2 sub edx, edx 10722 00002B13 660FB70E[BA3C] movzx ecx, word [sectors] 10723 00002B19 66F7F1 div ecx 10724 00002B1C FEC2 inc dl 10725 10726 ;push bx ; BL = sector 10727 ;mov cx, [heads] 10728 ;call div32 10729 ;pop dx ; DL = sector 10730 ;mov dh, bl ; BL = head 10731 ; 13/03/2021 10732 00002B1E 52 push dx 10733 00002B1F 31D2 xor dx, dx ; 21/03/2021 10734 00002B21 8B0E[BC3C] mov cx, [heads] 10735 00002B25 66F7F1 div ecx 10736 ; dl = head 10737 00002B28 88D3 mov bl, dl 10738 00002B2A 5A pop dx ; dl = sector 10739 00002B2B 88DE mov dh, bl ; dh = head 10740 10741 ; 24/10/2020 10742 ; check cylinder number (CHS) limit 10743 ;mov bh, 05h ; ENTENTED (LBA) 10744 ; 13/03/2021 10745 00002B2D B305 mov bl, 05h ; ENTENTED (LBA) 10746 10747 ;mov cx, ax ; 01/11/2020 10748 ; 13/03/2021 10749 00002B2F 6689C1 mov ecx, eax 10750 10751 ;cmp ax, 1023 10752 ; 13/03/2021 10753 00002B32 663DFF030000 cmp eax, 1023 10754 00002B38 760C jna short lbatochs_ok 10755 10756 ;mov ax, 1023 ; BC/EC = 0FFh 10757 ; 13/03/2021 10758 00002B3A 66B8FF030000 mov eax, 1023 10759 00002B40 B23F mov dl, 63 ; BS/ES = 0FFh 10760 00002B42 B6FE mov dh, 254 ; BH/EH = 0FEh 10761 00002B44 B30F mov bl, 0Fh ; EXTENDED (CHS) 10762 lbatochs_ok: 10763 00002B46 C3 retn 10764 10765 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10766 ; specify FAT type by using partition/volume size (CHS) 10767 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10768 ; 02/03/2019 10769 10770 ; 13/03/2021 (fdisk4.s) 10771 size_to_fat_type: 10772 ; INPUT: 10773 ; DX:AX = DOS Partition Size in sectors 10774 ; OUTPUT: 10775 ; AL = Partition type/ID (FAT type) 10776 10777 ;or dx, dx 10778 ;jnz short stft_2 10779 10780 ; 13/03/2021 10781 00002B47 6689C2 mov edx, eax 10782 00002B4A 66C1EA10 shr edx, 16 10783 00002B4E 750B jnz short stft_2 10784 10785 00002B50 3DA87F cmp ax, 32680 10786 00002B53 7703 ja short stft_1 10787 stft_0: 10788 00002B55 B001 mov al, 1 ; FAT12 file system 10789 00002B57 C3 retn 10790 stft_1: 10791 00002B58 B004 mov al, 4 ; FAT16 (< 32MB) 10792 00002B5A C3 retn 10793 stft_2: 10794 00002B5B 83FA10 cmp dx, 10h 10795 00002B5E 7303 jnb short stft_3 ; FAT32 (CHS) file system 10796 10797 00002B60 B006 mov al, 6 ; FAT16 (>= 32MB) 10798 00002B62 C3 retn 10799 stft_3: 10800 00002B63 B00B mov al, 0Bh ; FAT32 (CHS) 10801 00002B65 C3 retn 10802 10803 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10804 ; specify FAT type by using partition/volume size (LBA) 10805 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10806 ; 25/10/2020 10807 10808 ; 13/03/2021 (fdisk4.s) 10809 size_to_fat_type_lba: 10810 ; INPUT: 10811 ; DX:AX = DOS Partition Size in sectors 10812 ; OUTPUT: 10813 ; AL = Partition type/ID (FAT type) 10814 10815 ; 13/03/2021 10816 ; eax = DOS Partition Size in sectors 10817 10818 ;or dx, dx 10819 ;jz short stft_4 10820 10821 ; 13/03/2021 10822 00002B66 6689C2 mov edx, eax 10823 00002B69 66C1EA10 shr edx, 16 10824 00002B6D 7408 jz short stft_4 10825 10826 00002B6F 83FA10 cmp dx, 10h 10827 00002B72 7208 jb short stft_5 ; FAT16 (LBA) file system 10828 10829 00002B74 B00C mov al, 0Ch ; FAT32 file system (LBA) 10830 00002B76 C3 retn 10831 stft_4: 10832 00002B77 3DA87F cmp ax, 32680 10833 00002B7A 76D9 jna short stft_0 ; FAT12 file system 10834 stft_5: 10835 00002B7C B00E mov al, 0Eh ; FAT16 file system (LBA) 10836 00002B7E C3 retn 10837 10838 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10839 ; get requested logical dos drive size (from user) 10840 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10841 ; 02/03/2019 10842 10843 ; 13/03/2021 10844 ; 12/03/2021 (fdisk4.s) 10845 get_ldd_size: 10846 ; INPUT -> none 10847 ; 10848 ; OUTPUT -> 10849 ; [lcylinders] = cylinder count 10850 ; 10851 ; (Modified registers: ax, bx, cx, dx, si, di) 10852 10853 00002B7F B80300 mov ax, 3 ; clear screen 10854 00002B82 CD10 int 10h 10855 10856 00002B84 BE[1945] mov si, msg_create_dos_partition_h 10857 00002B87 E83DEE call print_msg 10858 10859 ; 03/03/2019 10860 00002B8A A0[1C6A] mov al, [ldrives] 10861 00002B8D 08C0 or al, al ; cmp byte [ldrives], 0 10862 00002B8F 7405 jz short gldds_1 ; jna short gldds_0 10863 10864 ;push ax ; * 10865 10866 ;dec al 10867 ;mov ah, 22 ; 05/11/2020 10868 ;mul ah 10869 10870 ;mov di, ext_table_rel_sec_lw 10871 ;add di, ax 10872 10873 00002B91 BE[2D4B] mov si, msg_use_all_space 10874 ; 01/11/2020 10875 ;call print_msg 10876 00002B94 EB03 jmp short gldds_2 10877 10878 ; Calculate available space 10879 10880 ;mov ax, [ep_Size] ; ext part size in sectors 10881 ;mov dx, [ep_Size+2] 10882 10883 ; 04/03/2019 10884 ;gldds_0: 10885 ;mov cx, [di] ; start sector 10886 ;mov bx, [di+2] 10887 ;add cx, [di+4] ; sectors 10888 ;adc bx, [di+6] 10889 ; ; bx:cx = start of next ldd 10890 ;sub ax, cx 10891 ;sbb dx, bx 10892 ; ; dx:ax = free space in sectors 10893 ; 10894 ;pop cx ; * 10895 ;dec cl 10896 ;jz short gldds_2 10897 ;sub di, 22 ; 05/11/2020 10898 ;push cx ; * 10899 ;jmp short gldds_0 10900 10901 ; 05/03/2019 10902 ;call check_ext_free_space 10903 ;jc short gldds_cancel 10904 10905 ; 01/11/2020 10906 ; 30/10/2020 10907 ;mov ax, [ep_free_sectors] 10908 ;mov dx, [ep_free_sectors+2] 10909 10910 ; DX:AX = free sectors in extended partition 10911 ;jmp short gldds_2 10912 gldds_1: 10913 00002B96 BE[604B] mov si, msg_use_entire_ep_space 10914 ;call print_msg 10915 10916 ; 01/11/2020 10917 ; Calculate free space in extended partition 10918 ;mov ax, [ep_Size] 10919 ;mov dx, [ep_Size+2] 10920 gldds_2: 10921 ; 01/11/2020 10922 00002B99 E82BEE call print_msg 10923 10924 ; 13/03/2021 10925 ;mov al, [heads] 10926 ;mul byte [sectors] 10927 ;;mov cx, ax 10928 ;; 12/03/2021 10929 ;movzx ecx, ax 10930 10931 ;mov ax, [ep_free_sectors] 10932 ;mov dx, [ep_free_sectors+2] 10933 ; 12/03/2021 10934 00002B9C 66A1[D46D] mov eax, [ep_free_sectors] 10935 10936 ;; 01/11/2020 10937 ;; this is needed for partition size input 10938 ;; (maximum available sectors) 10939 ;;mov [pp_Sectors], ax 10940 ;;mov [pp_Sectors+2], dx 10941 10942 ;; 01/11/2020 10943 ;; subtrack start offset (which always equals to spt value) 10944 ;;sub ax, [sectors] 10945 ;;sbb dx, 0 10946 10947 ;;mov cx, ax 10948 ;;mov al, [heads] 10949 ;;mul byte [sectors] 10950 ;;xchg ax, cx 10951 ; ; dx:ax = sectors 10952 ; ; cx = heads*spt 10953 ;;call div32 10954 ; ; ax = cylinders 10955 ; ; bx = remainder 10956 ; ; dx = 0 10957 ;;and bx, bx 10958 ;;jz short gldds_3 10959 ;;inc ax 10960 ; 01/11/2020 10961 ;div cx 10962 ; 12/03/2021 10963 00002BA0 6631D2 xor edx, edx 10964 ;div ecx 10965 ; 13/03/2021 10966 00002BA3 66F736[086A] div dword [hs] ; heads*spt 10967 10968 ;and dx, dx 10969 ;jz short gldds_3 10970 ;inc ax 10971 gldds_3: 10972 ;mov [lcylinders], ax ; <= 65535 (< 65535) 10973 ; 12/03/2021 10974 00002BA8 66A3[D86D] mov [lcylinders], eax ; <= 267369 10975 gldds_getchar: 10976 00002BAC 30E4 xor ah, ah 10977 00002BAE CD16 int 16h 10978 10979 00002BB0 3C1B cmp al, 27 ; ESCAPE key 10980 00002BB2 7419 je short gldds_cancel 10981 00002BB4 24DF and al, 0DFh 10982 00002BB6 3C4E cmp al, 'N' 10983 00002BB8 741D je short gldds_4 10984 00002BBA 3C59 cmp al, 'Y' 10985 00002BBC 75EE jne short gldds_getchar 10986 10987 ; 01/11/2020 10988 ;mov word [lcylinders], 65535 ; sign for all free sectors 10989 ; 12/03/2021 10990 00002BBE 66C706[D86D]FFFFFF- mov dword [lcylinders], 0FFFFFFFFh 10990 00002BC6 FF 10991 ; sign for all free sectors 10992 00002BC7 BE[AE59] mov si, _msg_YES 10993 ;call print_msg 10994 ;retn 10995 00002BCA E9FAED jmp print_msg 10996 10997 gldds_cancel: 10998 ;mov word [lcylinders], 0 10999 ; 12/03/2021 11000 00002BCD 66C706[D86D]000000- mov dword [lcylinders], 0 11000 00002BD5 00 11001 gldds_28: 11002 00002BD6 C3 retn 11003 gldds_4: 11004 00002BD7 BE[B459] mov si, _msg_NO 11005 00002BDA E8EAED call print_msg 11006 gldds_26: 11007 00002BDD B80300 mov ax, 3 ; clear screen 11008 00002BE0 CD10 int 10h 11009 11010 00002BE2 BE[1945] mov si, msg_create_dos_partition_h 11011 00002BE5 E8DFED call print_msg 11012 11013 00002BE8 BE[205F] mov si, msg_create_ldd_s 11014 00002BEB E8D9ED call print_msg 11015 00002BEE BE[EB4A] mov si, msg_press_esc_to_cancel 11016 00002BF1 E8D3ED call print_msg 11017 gldds_25: 11018 00002BF4 30E4 xor ah, ah 11019 00002BF6 CD16 int 16h 11020 11021 00002BF8 3C1B cmp al, 27 ; ESCAPE key 11022 00002BFA 7502 jne short gldds_5 11023 11024 00002BFC EBCF jmp short gldds_cancel 11025 gldds_5: 11026 ; 04/03/2019 11027 00002BFE 3C20 cmp al, 32 ; SPACE key 11028 00002C00 74D4 je short gldds_28 11029 11030 ; 01/11/2020 11031 ;mov byte [pSize_unit], '%' 11032 00002C02 3C25 cmp al, '%' 11033 00002C04 7416 je short gldds_6 11034 ;mov byte [pSize_unit], 'M' 11035 00002C06 3C0D cmp al, 13 ; 0Dh, Carriage Return key 11036 ;je short gldds_6 11037 00002C08 7504 jne short gldds_29 11038 ; 01/11/2020 11039 00002C0A B04D mov al, 'M' 11040 00002C0C EB0E jmp short gldds_6 11041 gldds_29: 11042 00002C0E 24DF and al, 0DFh 11043 00002C10 3C4D cmp al, 'M' 11044 00002C12 7408 je short gldds_6 11045 ;mov [pSize_unit], al 11046 00002C14 3C47 cmp al, 'G' 11047 00002C16 7404 je short gldds_6 11048 00002C18 3C43 cmp al, 'C' 11049 00002C1A 75D8 jne short gldds_25 11050 gldds_6: 11051 ; 01/11/2020 11052 00002C1C A2[F269] mov [pSize_unit], al 11053 11054 ; Set maximum sector count (all of extended partition) 11055 ;mov al, [sectors] 11056 ;mul byte [heads] 11057 ;mul word [lcylinders] 11058 ; 01/11/2020 11059 ;mov ax, [ep_free_sectors] 11060 ;mov dx, [ep_free_sectors+2] 11061 ;mov [pp_Sectors], ax 11062 ;mov [pp_Sectors+2], dx 11063 ; 12/03/2021 11064 00002C1F 66A1[D46D] mov eax, [ep_free_sectors] 11065 00002C23 66A3[E069] mov [pp_Sectors], eax 11066 11067 00002C27 E80BF0 call partition_size_input 11068 00002C2A 72A1 jc short gldds_cancel 11069 ; DX:AX = Partition size in sectors 11070 ;or bx, bx 11071 ;jnz short gldds_cancel 11072 11073 ; 01/11/2020 11074 ;mov [ppn_Sectors], ax 11075 ;mov [ppn_Sectors+2], dx 11076 ; 12/03/2021 11077 00002C2C 66A3[146A] mov [ppn_Sectors], eax ; edx = 0 11078 11079 ;mov cx, ax 11080 ;mov al, [heads] 11081 ;mul byte [sectors] 11082 ;xchg ax, cx 11083 ; ; dx:ax = sectors 11084 ; ; cx = heads*spt 11085 ;call div32 11086 ; ; ax = cylinders 11087 ; ; bx = remainder 11088 ; ; dx = 0 11089 ; 02/11/2020 11090 ;and bx, bx 11091 ;jz short gldds_7 11092 ;inc ax 11093 11094 ; 13/03/2021 11095 ; eax = partition size input, edx = 0 11096 00002C30 66F736[086A] div dword [hs] ; heads*sectors ; <= 16065 11097 ; eax = cylinders, dx = remainder 11098 00002C35 09D2 or dx, dx 11099 00002C37 7402 jz short gldds_7 11100 00002C39 6640 inc eax ; +1 11101 gldds_7: 11102 ;cmp ax, [lcylinders] 11103 ; 13/03/2021 11104 00002C3B 663B06[D86D] cmp eax, [lcylinders] 11105 00002C40 7705 ja short gldds_9 11106 gldds_8: 11107 ; OK 11108 ;mov [lcylinders], ax 11109 ; 13/03/2021 11110 00002C42 66A3[D86D] mov [lcylinders], eax 11111 00002C46 C3 retn 11112 11113 gldds_9: 11114 ; Partition size limit message 11115 11116 00002C47 803E[F269]43 cmp byte [pSize_unit], 'C' 11117 00002C4C 7415 je short gldds_10 11118 11119 ; Tolerate 1 cylinder if unit is not cylinder 11120 ;dec ax 11121 ;cmp ax, [lcylinders] 11122 ;jna short gldds_8 11123 11124 ; 01/11/2020 11125 ; Tolerate sectors if sectorcount doesn't over ep limit 11126 ;mov ax, [ppn_Sectors] 11127 ;mov dx, [ppn_Sectors+2] 11128 ;cmp dx, [ep_free_sectors+2] 11129 ;ja short gldds_10 11130 ;jb short gldds_30 11131 ;cmp ax, [ep_free_sectors] 11132 ;ja short gldds_10 11133 ; 13/03/2021 11134 00002C4E 66A1[146A] mov eax, [ppn_Sectors] 11135 00002C52 663B06[D46D] cmp eax, [ep_free_sectors] 11136 00002C57 770A ja short gldds_10 11137 gldds_30: 11138 ;mov word [lcylinders], 65535 ; sign for all free sectors 11139 ; 13/03/2021 11140 00002C59 66C706[D86D]FFFFFF- mov dword [lcylinders], 0FFFFFFFFh 11140 00002C61 FF 11141 00002C62 C3 retn 11142 11143 gldds_10: 11144 ; clear screen 11145 00002C63 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 11146 00002C66 CD10 int 10h 11147 11148 00002C68 BE[1945] mov si, msg_create_dos_partition_h ; header 11149 00002C6B E859ED call print_msg 11150 11151 00002C6E BE[CD5A] mov si, msg_partition_size_limit 11152 00002C71 E853ED call print_msg 11153 11154 00002C74 803E[F269]4D cmp byte [pSize_unit], 'M' 11155 00002C79 7414 je short gldds_11 11156 11157 00002C7B 803E[F269]25 cmp byte [pSize_unit], '%' 11158 00002C80 745E je short gldds_22 11159 11160 00002C82 803E[F269]43 cmp byte [pSize_unit], 'C' 11161 00002C87 7506 jne short gldds_11 11162 11163 ;mov ax, [lcylinders] 11164 ; 13/03/2021 11165 00002C89 66A1[D86D] mov eax, [lcylinders] 11166 00002C8D EB15 jmp short gldds_12 11167 gldds_11: 11168 ; 'M' 11169 ;mov ax, [pp_Sectors] 11170 ;mov dx, [pp_Sectors+2] 11171 ;mov cx, 2*1024 ; sectors -> MB 11172 ;call div32 11173 ; ; DX = 0 11174 ; ; AX = Available space in Megabytes 11175 ; 13/03/2021 11176 00002C8F 31FF xor di, di ; (**) 11177 00002C91 66A1[E069] mov eax, [pp_Sectors] 11178 ;xor edx, edx 11179 00002C95 31D2 xor dx, dx 11180 ;mov ecx, 2*1024 11181 00002C97 B90008 mov cx, 2*1024 11182 00002C9A 66F7F1 div ecx 11183 00002C9D 6683F801 cmp eax, 1 11184 00002CA1 7601 jna short gldds_12 11185 00002CA3 47 inc di ; (**) 11186 gldds_12: 11187 00002CA4 B90A00 mov cx, 10 11188 00002CA7 89E5 mov bp, sp 11189 gldds_13: 11190 00002CA9 31D2 xor dx, dx 11191 ;mov cx, 10 11192 00002CAB F7F1 div cx 11193 00002CAD 52 push dx ; * 11194 00002CAE 83F809 cmp ax, 9 11195 00002CB1 77F6 ja short gldds_13 11196 gldds_14: 11197 00002CB3 BB0700 mov bx, 07h 11198 00002CB6 09C0 or ax, ax 11199 00002CB8 7501 jnz short gldds_16 11200 gldds_15: 11201 00002CBA 58 pop ax ; * 11202 gldds_16: 11203 00002CBB 0430 add al, '0' 11204 gldds_17: 11205 00002CBD B40E mov ah, 0Eh 11206 ;mov bx, 07h 11207 00002CBF CD10 int 10h ; write character (as tty) 11208 11209 00002CC1 39EC cmp sp, bp 11210 00002CC3 72F5 jb short gldds_15 11211 11212 00002CC5 803E[F269]25 cmp byte [pSize_unit], '%' 11213 00002CCA 7508 jne short gldds_18 11214 11215 00002CCC 3C25 cmp al, '%' 11216 00002CCE 743C je short gldds_21 11217 00002CD0 B025 mov al, '%' 11218 00002CD2 EBE9 jmp short gldds_17 11219 gldds_18: 11220 00002CD4 803E[F269]43 cmp byte [pSize_unit], 'C' 11221 00002CD9 751D jne short gldds_19 11222 11223 00002CDB BE[695B] mov si, msg_cylinders 11224 00002CDE EB29 jmp short gldds_20 11225 11226 gldds_22: 11227 ; '%' 11228 ; 01/11/2020 11229 ;mov dx, [ep_Size+2] 11230 ;mov ax, [ep_Size] ; * 11231 ;and dx, dx 11232 ;jz short gldds_33 ; dx = 0 11233 ; 13/03/2021 11234 ;mov cx, 1 11235 ;gldds_31: 11236 ;shl cx, 1 11237 ;call div32 11238 ;or dx, dx 11239 ;jz short gldds_32 ; * 11240 ;mov ax, [ep_Size] 11241 ;mov dx, [ep_Size+2] 11242 ;jmp short gldds_31 11243 ;gldds_32: 11244 ;mov dx, [ep_free_sectors+2] 11245 ; ep free sectors <= ep size 11246 gldds_33: 11247 ;push ax ; * ; dx = 0 (ep size weight) 11248 ;mov ax, [ep_free_sectors] 11249 ; 13/03/2021 11250 00002CE0 66A1[D46D] mov eax, [ep_free_sectors] 11251 ;mov ecx, 100 11252 00002CE4 B96400 mov cx, 100 11253 ;and dx, dx 11254 ;jnz short gldds_34 11255 ;mul cx 11256 ;jmp short gldds_35 11257 ;gldds_34: 11258 ;call mul32 11259 ; ; dx:ax = 100 * ep free sectors weight 11260 ; 13/03/2021 11261 ;xor edx, edx 11262 00002CE7 31D2 xor dx, dx 11263 00002CE9 66F7E1 mul ecx ; 100 * ep free sectors 11264 ;gldds_35: 11265 ;pop cx ; * 11266 ;call div32 ; 100 * ep free sectors / ep size 11267 ; ; ax = % value (<= 100) 11268 00002CEC 66F736[2C6C] div dword [ep_Size] 11269 11270 00002CF1 09C0 or ax, ax 11271 ;jnz short gldds_23 11272 00002CF3 75AF jnz short gldds_12 ; 13/03/2021 11273 00002CF5 40 inc ax ; 0 -> 1 11274 ; 13/03/2021 11275 00002CF6 EBAC jmp short gldds_12 11276 11277 ;gldds_23: 11278 ;mov bp, sp 11279 ;mov cx, 10 11280 ;gldds_24: 11281 ;xor dx, dx 11282 ;div cx 11283 ;push dx ; * 11284 ;cmp ax, 9 11285 ;ja short gldds_24 11286 ;jmp short gldds_14 11287 11288 gldds_19: 11289 00002CF8 BE[7D5B] mov si, msg_megabytes 11290 00002CFB C606[865B]73 mov byte [msg_megabytes_s], 's' 11291 ;cmp di, 1 11292 ;ja short gldds_20 11293 ; 13/03/2021 11294 00002D00 09FF or di, di ; (**) 11295 00002D02 7505 jnz short gldds_20 11296 ; di = 0 -> 1 MB 11297 00002D04 C606[865B]00 mov byte [msg_megabytes_s], 0 11298 gldds_20: 11299 00002D09 E8BBEC call print_msg 11300 gldds_21: 11301 00002D0C BE[1A5B] mov si, msg_partition_size_limit_r 11302 00002D0F E8B5EC call print_msg 11303 gldds_27: 11304 00002D12 30E4 xor ah, ah 11305 00002D14 CD16 int 16h 11306 11307 00002D16 3C1B cmp al, 27 ; ESCAPE key 11308 00002D18 0F84C1FE je gldds_26 11309 00002D1C 3C0D cmp al, 13 ; ENTER (Carriage Return) key 11310 00002D1E 75F2 jne short gldds_27 11311 11312 ;mov ax, [lcylinders] 11313 00002D20 C3 retn 11314 11315 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11316 ; initialize extended (dos) partition table 11317 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11318 ; 18/10/2020 (fdisk3.s) 11319 ; 26/02/2019 (hdimage.s) 11320 11321 ; 09/03/2021 11322 ; 05/11/2020 (fdisk4.s) 11323 init_ext_partition_table: 11324 11325 ; INPUT -> 11326 ; [epnumber] = extended partition number 11327 ; 11328 ; OUTPUT -> none 11329 11330 ; Display Method: ; 04/03/2019 11331 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 11332 ;LDD 2 <- LDD_START1, ebr 1st entry <- EBR 1 11333 ;LDD 3 <- LDD_START2, ebr 1st entry <- EBR 2 11334 ;LDD 4 <- LDD_START3, ebr 1st entry <- EBR 3 11335 ;LDD 5 <- LDD_START3, ebr 2nd entry (LDD 5 is not displayed) 11336 11337 ; 08/03/2019 11338 11339 ; clear extended partition table structure/list 11340 11341 00002D21 BF[EA6C] mov di, ext_table_boot_ind 11342 00002D24 89FE mov si, di ; 28/02/2019 11343 ;mov cx, 36 ; 18*4 = 72 bytes 11344 ; 05/11/2020 11345 00002D26 B92C00 mov cx, 44 ; 22*4 = 84 bytes 11346 00002D29 31C0 xor ax, ax ; 0 11347 00002D2B F3AB rep stosw 11348 00002D2D 89F7 mov di, si ; 28/02/2019 11349 11350 ;mov byte [ldrives], 0 11351 00002D2F A2[1C6A] mov [ldrives], al ; 0 11352 11353 ;cmp byte [epnumber], 1 11354 ;jb short iept_0 11355 11356 00002D32 A0[E96C] mov al, [epnumber] 11357 00002D35 FEC8 dec al 11358 ;mov ah, 18 ; partition table structure size 11359 ; 05/11/2020 11360 00002D37 B416 mov ah, 22 ; partition table structure size 11361 00002D39 F6E4 mul ah 11362 ;mov si, part_table_rel_sec_lw 11363 00002D3B BE[9C6C] mov si, part_table_rel_sec ; 09/03/2021 11364 00002D3E 01C6 add si, ax 11365 11366 ; 02/11/2020 11367 ;(save end cylinder for comparising later) 11368 00002D40 8B44FE mov ax, [si-2] ; part_table_end_cyl 11369 ; 16 bit cylinder number 11370 00002D43 A3[DE6D] mov [endcyl], ax 11371 11372 ;mov ax, [si] 11373 ;mov dx, [si+2] 11374 ;mov [ep_StartSector], ax 11375 ;mov [ep_StartSector+2], dx 11376 ;mov cx, [si+4] 11377 ;mov bx, [si+6] 11378 ;mov [ep_Size], cx 11379 ;mov [ep_Size+2], bx 11380 ;sub cx, 1 11381 ;sbb bx, 0 11382 ;add cx, ax 11383 ;adc bx, dx 11384 ;mov [ep_EndSector], cx 11385 ;mov [ep_EndSector+2], bx 11386 11387 ; 09/03/2021 11388 00002D46 668B04 mov eax, [si] 11389 00002D49 66A3[246C] mov [ep_StartSector], eax 11390 00002D4D 668B5404 mov edx, [si+4] 11391 00002D51 668916[2C6C] mov [ep_Size], edx 11392 00002D56 6601C2 add edx, eax 11393 00002D59 664A dec edx 11394 00002D5B 668916[286C] mov [ep_EndSector], edx 11395 00002D60 6631D2 xor edx, edx 11396 11397 ; 27/02/2019 11398 ;mov [ldd_start], ax 11399 ;mov [ldd_start+2], dx 11400 ; 09/03/2021 11401 00002D63 66A3[B46D] mov [ldd_start], eax 11402 11403 ; 03/03/2019 11404 ;mov word [ldd_size], 0 11405 ;mov word [ldd_size+2], 0 11406 11407 00002D67 BB[226A] mov bx, ebr_buffer 11408 ; dx:ax = Extended partition address 11409 ; es:bx = Extended partition buffer 11410 ; 09/03/2021 11411 ; eax = Extended partition address 11412 ; es:bx = Extended partition buffer 11413 11414 00002D6A E869EC call read_hd_sector 11415 00002D6D 7209 jc short iept_0 11416 11417 ; Check EBR if it is a valid boot record or not 11418 00002D6F 813E[206C]55AA cmp word [ebr_buffer+510], 0AA55h 11419 00002D75 7402 je short iept_1 11420 iept_stc_retn: 11421 00002D77 F9 stc 11422 iept_0: 11423 00002D78 C3 retn 11424 iept_1: 11425 ; Check PTE 1, if it is valid or not 11426 00002D79 A0[E46B] mov al, [ebr_buffer+446+ptFileSystemID] 11427 00002D7C 20C0 and al, al 11428 00002D7E 74F7 jz short iept_stc_retn ; empty pte, error 11429 00002D80 3C05 cmp al, 5 11430 00002D82 74F3 je short iept_stc_retn ; extended partition, error 11431 ; 24/10/2020 11432 00002D84 3C0F cmp al, 0Fh 11433 00002D86 74EF je short iept_stc_retn ; extended partition, error 11434 11435 ;inc byte [ldrives] ; logical (dos) drive count 11436 11437 00002D88 BE[E06B] mov si, ebr_buffer+446 ; Partition table offset 11438 00002D8B B90400 mov cx, 4 11439 11440 ; set partition (logical -dos- drive) data 11441 00002D8E A5 movsw ; boot indicator, beginning head 11442 00002D8F AC lodsb 11443 00002D90 88C4 mov ah, al 11444 00002D92 243F and al, 3Fh 11445 00002D94 AA stosb ; beginning sector 11446 00002D95 C0EC06 shr ah, 6 11447 00002D98 AC lodsb ; beginning cylinder 11448 00002D99 AB stosw 11449 ; 09/03/2021 11450 00002D9A 31C0 xor ax, ax 11451 00002D9C AB stosw 11452 ; 11453 00002D9D A5 movsw ; partition id, end head 11454 00002D9E AC lodsb 11455 00002D9F 88C4 mov ah, al 11456 00002DA1 243F and al, 3Fh 11457 00002DA3 AA stosb ; end sector 11458 00002DA4 C0EC06 shr ah, 6 11459 00002DA7 AC lodsb ; end cylinder 11460 00002DA8 AB stosw 11461 ; 09/03/2021 11462 00002DA9 31C0 xor ax, ax 11463 00002DAB AB stosw 11464 ; 11465 11466 ; 04/03/2019 11467 00002DAC 8A1E[1C6A] mov bl, [ldrives] 11468 ;dec bl 11469 ;jnz short iept_2 11470 11471 ; 05/03/2019 11472 00002DB0 08DB or bl, bl 11473 00002DB2 7511 jnz short iept_2 11474 11475 ;mov ax, [si] ; start sector of 1st LDD (offset) 11476 ;mov dx, [si+2] 11477 ;add ax, [si+4] ; size of 1st LDD (volume) 11478 ;adc dx, [si+6] 11479 ; 09/03/2021 11480 00002DB4 668B04 mov eax, [si] 11481 00002DB7 66034404 add eax, [si+4] 11482 11483 ;mov [ldd_size], ax ; size of 1st LDD (partition) 11484 ;mov [ldd_size+2], dx 11485 ; 09/03/2021 11486 00002DBB 66A3[C46D] mov [ldd_size], eax 11487 11488 ; 05/03/2019 11489 00002DBF FE06[1C6A] inc byte [ldrives] ; logical (dos) drive count 11490 00002DC3 FEC3 inc bl 11491 iept_2: 11492 00002DC5 F3A5 rep movsw ; copy start sector (LBA) and sector count 11493 11494 ; get next extended partition (logical -dos- drive) data 11495 00002DC7 8A4404 mov al, [si+ptFileSystemID] 11496 00002DCA 20C0 and al, al ; EMPTY 11497 00002DCC 74AA jz short iept_0 ; end of logical -dos- drive chain 11498 11499 00002DCE 3C05 cmp al, 5 ; EXTENDED 11500 ;jne short iept_stc_retn ; 2nd PTE must have 11501 ; ; extended partition ID 11502 00002DD0 7404 je short iept_4 11503 ; 24/10/2020 11504 00002DD2 3C0F cmp al, 0Fh ; EXTENDED (LBA) 11505 00002DD4 75A1 jne short iept_stc_retn ; 2nd PTE must have 11506 ; extended partition ID 11507 iept_4: 11508 ; 05/03/2019 11509 00002DD6 FE06[1C6A] inc byte [ldrives] ; logical (dos) drive count 11510 11511 ;cmp byte [ldrives], al ; 5 11512 00002DDA 80FB04 cmp bl, 4 ; number of logical dos drives (till here) 11513 00002DDD 7332 jnb short iept_3 11514 11515 00002DDF 83C608 add si, 8 11516 11517 ;lodsw 11518 ;mov dx, ax ; start sector 11519 ;lodsw 11520 ;xchg dx, ax ; start sector + 2 11521 ; 09/03/2021 11522 00002DE2 66AD lodsd 11523 11524 ; 04/03/2019 11525 ;add ax, [ep_StartSector] 11526 ;adc dx, [ep_StartSector+2] 11527 ; 09/03/2021 11528 00002DE4 660306[246C] add eax, [ep_StartSector] 11529 11530 00002DE9 30FF xor bh, bh 11531 00002DEB C0E302 shl bl, 2 ; *4 11532 11533 ; 28/02/2019 11534 ;mov [bx+ldd_start], ax ; start of (next) LDD (partition) 11535 ;mov [bx+ldd_start+2], dx 11536 ; 09/03/2021 11537 00002DEE 668987[B46D] mov [bx+ldd_start], eax 11538 11539 ; 03/03/2019 11540 ; set partition size for logical dos drive 11541 ;mov cx, [si] 11542 ;mov [bx+ldd_size], cx 11543 ;mov cx, [si+2] 11544 ;mov [bx+ldd_size+2], cx 11545 ; 09/03/2021 11546 00002DF3 668B14 mov edx, [si] 11547 00002DF6 668997[C46D] mov [bx+ldd_size], edx 11548 00002DFB 6629D2 sub edx, edx 11549 11550 00002DFE BB[226A] mov bx, ebr_buffer 11551 11552 ; dx:ax = Extended partition address 11553 ; es:bx = Extended partition buffer 11554 ; 09/03/2021 11555 ; eax = Extended partition address 11556 11557 00002E01 E8D2EB call read_hd_sector 11558 00002E04 720B jc short iept_3 ; 03/03/2019 11559 11560 ; Check EBR if it is valid or not 11561 00002E06 813E[206C]55AA cmp word [ebr_buffer+510], 0AA55h 11562 00002E0C 0F8469FF je iept_1 11563 11564 00002E10 F9 stc 11565 iept_3: 11566 00002E11 C3 retn 11567 11568 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11569 ; delete logical -dos- drives in extended partition 11570 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11571 ; 18/10/2020 (fdisk3.s) 11572 11573 ; 12/03/2021 11574 ; 09/03/2021 (fdisk4.s) 11575 delete_logical_drives: 11576 ; 27/02/2019 (hdimage.s) 11577 11578 ; Delete Method: ; 04/03/2019 11579 ;LDD 5 <- LDD_START3, ebr 2nd entry 11580 ;LDD 4 <- LDD_START2, ebr 2nd entry 11581 ;LDD 3 <- LDD_START1, ebr 2nd entry 11582 ;LDD 2 <- LDD_START0, ebr 2nd entry 11583 ;LDD 1 <- LDD_START0, ebr 1st entry 11584 11585 ;cmp byte [ldrives], 0 11586 ;jna short dld_stc 11587 11588 ;mov al, 5 ; extended partition (logical drives) 11589 ;call display_partition_table 11590 ; 12/03/2021 11591 00002E12 E8A3F7 call display_partition_table_x 11592 11593 00002E15 A0[1C6A] mov al, [ldrives] 11594 00002E18 0430 add al, '0' 11595 00002E1A A2[F35C] mov [lddp_num], al 11596 11597 00002E1D BE[A05C] mov si, msg_delete_ldd 11598 00002E20 E8A4EB call print_msg 11599 11600 00002E23 BE[EB4A] mov si, msg_press_esc_to_cancel 11601 00002E26 E89EEB call print_msg 11602 dld_0: 11603 00002E29 30E4 xor ah, ah 11604 00002E2B CD16 int 16h 11605 11606 00002E2D 80FC53 cmp ah, 53h ; DELETE or DEL key 11607 00002E30 751C jne short dld_1 11608 11609 ; Delete PTE 1 & PTE 2 on EBR 1 11610 00002E32 30E4 xor ah, ah 11611 00002E34 A0[1C6A] mov al, [ldrives] 11612 00002E37 FEC8 dec al 11613 00002E39 7518 jnz short dld_2 11614 11615 00002E3B BF[E06B] mov di, ebr_buffer+446 11616 00002E3E B91000 mov cx, 16 11617 00002E41 F3AB rep stosw 11618 11619 ; 04/03/2019 11620 ; Clear ldd data in extended partition table/structure 11621 00002E43 BF[EA6C] mov di, ext_table_boot_ind 11622 00002E46 B109 mov cl, 9 11623 00002E48 F3AB rep stosw 11624 00002E4A 31F6 xor si, si 11625 00002E4C EB3D jmp short dld_3 11626 dld_1: 11627 00002E4E 3C1B cmp al, 27 ; ESC key 11628 00002E50 75D7 jne short dld_0 11629 dld_5: 11630 00002E52 C3 retn 11631 11632 ;dld_stc: 11633 ; stc 11634 ; retn 11635 11636 dld_2: 11637 ; 04/03/2019 11638 ; Delete 2nd PTE on EBR 2 to 4 11639 00002E53 FEC8 dec al 11640 00002E55 C0E002 shl al, 2 ; * 4 11641 00002E58 89C6 mov si, ax 11642 11643 ;mov ax, [si+ldd_start] 11644 ;mov dx, [si+ldd_start+2] 11645 ; 09/03/2021 11646 00002E5A 668B84[B46D] mov eax, [si+ldd_start] 11647 11648 00002E5F BB[226A] mov bx, ebr_buffer 11649 00002E62 E871EB call read_hd_sector 11650 00002E65 7235 jc short dld_4 11651 11652 00002E67 BF[F06B] mov di, ebr_buffer+446+16 11653 00002E6A B90800 mov cx, 8 11654 00002E6D 29C0 sub ax, ax 11655 00002E6F F3AB rep stosw 11656 11657 ; 04/03/2019 11658 ;cmp byte [ldrives], 5 11659 ;jnb short dld_3 11660 00002E71 8A26[1C6A] mov ah, [ldrives] 11661 00002E75 80FC05 cmp ah, 5 11662 00002E78 7311 jnb short dld_3 11663 11664 ; Clear ldd data in extended partition table/structure 11665 ;mov ah, [ldrives] 11666 00002E7A FECC dec ah 11667 ;mov al, 18 11668 ; 05/11/2020 11669 00002E7C B016 mov al, 22 11670 00002E7E F6E4 mul ah 11671 00002E80 BF[EA6C] mov di, ext_table_boot_ind 11672 00002E83 01C7 add di, ax 11673 ;;mov cx, 9 11674 ;mov cl, 9 11675 ; 05/11/2020 11676 00002E85 B10B mov cl, 11 11677 ;xor ax, ax 11678 00002E87 30C0 xor al, al 11679 00002E89 F3AB rep stosw 11680 dld_3: 11681 ; Write changed EBR 11682 ;mov ax, [si+ldd_start] 11683 ;mov dx, [si+ldd_start+2] 11684 ; 09/03/2021 11685 00002E8B 668B84[B46D] mov eax, [si+ldd_start] 11686 11687 00002E90 BB[226A] mov bx, ebr_buffer 11688 00002E93 E88FEB call write_hd_sector 11689 00002E96 7204 jc short dld_4 11690 11691 ; 28/02/2019 11692 00002E98 FE0E[1C6A] dec byte [ldrives] 11693 dld_4: 11694 00002E9C 803E[1C6A]00 cmp byte [ldrives], 0 11695 00002EA1 0F876DFF ja delete_logical_drives 11696 11697 00002EA5 C3 retn 11698 11699 ;============================================================================= 11700 ; initialized data 11701 ;============================================================================= 11702 11703 ; 12/10/2020 11704 int13h_x: 11705 00002EA6 00 db 0 11706 11707 TRDOS386_MASTERBOOT_SECTOR: 11708 00002EA7 incbin 'FS1_MBR.BIN' ; Singlix FS1 MBR 11709 11710 TRDOS_FAT_hd_bs: 11711 ;incbin 'TRHDBS.BIN' 11712 ; 04/05/2024 11713 TRDOS_FAT32_hd_bs: 11714 ;incbin 'FAT32_BS.BIN' ; 27/04/2024 11715 000030A7 incbin 'RD5HDBS3.BIN' ; 29/01/2026 11716 TRDOS_FAT16_hd_bs: 11717 ;incbin 'FAT16_BS.BIN' ; 26/12/2017 11718 000034A7 incbin 'RD5HDBS2.BIN' ; 20/04/2024 11719 TRDOS_FAT12_hd_bs: 11720 ;incbin 'FAT12_BS.BIN' ; 26/12/2017 11721 000036A7 incbin 'RD5HDBS1.BIN' ; 20/04/2024 11722 11723 TRDOS_TRFS1_chs_bs: 11724 000038A7 incbin 'TRFS1CHS.BIN' ; Singlix FS1 (CHS+LBA Disk) BS 11725 TRDOS_TRFS1_lba_bs: 11726 00003AA7 incbin 'TRFS1LBA.BIN' ; Singlix FS1 (LBA Disk) BS 11727 11728 00003CA7 00 db 0 11729 11730 hexchrs: 11731 00003CA8 303132333435363738- db '0123456789ABCDEF' 11731 00003CB1 39414243444546 11732 11733 ; 05/11/2020 11734 00003CB8 00 db 0 11735 11736 00003CB9 90 align 2 11737 11738 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 11739 11740 sectors: ; sectors per track (63) 11741 00003CBA 3F00 dw 63 11742 heads: ; number of heads (16 or 32 or 64) 11743 00003CBC 1000 dw 16 11744 cylinders: ; number of cylinders (16 to 1024) 11745 ;dw 1024 11746 ;dw 0 ; 16/10/2020 (double word) 11747 00003CBE 00040000 dd 1024 ; 05/11/2020 11748 11749 ; 05/11/2020 11750 11751 ;random: 11752 ; db 0 ; random write to file (0 = sequental) 11753 ;newdisk: 11754 ; db 0 11755 11756 FileSys_Names: ; 2003-2017 11757 ; (Valid FileSystems for TRDOS 386, SINGLIX, RETRO UNIX OS projects in 2017) 11758 00003CC2 464154313220202020- FS_FAT12: db "FAT12 " ; 01h = FAT12 11758 00003CCB 2020202020 11759 00003CD0 58454E495820202020- FS_XENIX: db "XENIX " ; 02h , XENIX System V root 11759 00003CD9 2020202020 11760 00003CDE 58454E495820757372- FS_XENIX_USR: db "XENIX usr " ; 03h , XENIX System V user 11760 00003CE7 2020202020 11761 00003CEC 464154313620283034- FS_FAT16: db "FAT16 (04h) " ; 04h = FAT16 < 32MB 11761 00003CF5 6829202020 11762 00003CFA 455854454E44454420- FS_EXT_CHS: db "EXTENDED (CHS)" ; 05h = Extended DOS Partition 11762 00003D03 2843485329 11763 00003D08 464154313620283036- FS_FAT16_BIG: db "FAT16 (06h) " ; 06h = FAT16 > 32MB, CHS mode 11763 00003D11 6829202020 11764 00003D16 4E5446532020202020- FS_NTFS: db "NTFS " ; 07h , WINDOWS NTFS Partition 11764 00003D1F 2020202020 11765 00003D24 464154333220284348- FS_FAT32_CHS: db "FAT32 (CHS) " ; 0Bh = FAT32, CHS mode 11765 00003D2D 5329202020 11766 00003D32 464154333220284C42- FS_FAT32_LBA: db "FAT32 (LBA) " ; 0Ch = FAT32, LBA mode 11766 00003D3B 4129202020 11767 00003D40 464154313620284C42- FS_FAT16_LBA: db "FAT16 (LBA) " ; 0Eh = FAT16, LBA mode 11767 00003D49 4129202020 11768 00003D4E 455854454E44454420- FS_EXT_LBA: db "EXTENDED (LBA)" ; 0Fh = Extented Partition, LBA mode 11768 00003D57 284C424129 11769 00003D5C 554E49582053595354- FS_UNIX_SYSV: db "UNIX SYSTEM V " ; 63h , SCO UNIX, UNIXWARE, OPENSERVER 11769 00003D65 454D205620 11770 00003D6A 524554524F20554E49- FS_RETROUNIX: db "RETRO UNIX " ; 71h , Retro UNIX 386 v2 Partition 11770 00003D73 5820202020 11771 00003D78 554E49582056372020- FS_UNIX_V7: db "UNIX V7 " ; 72h , UNIX v7 x86 Partition 11771 00003D81 2020202020 11772 00003D86 4C494E555820535741- FS_LINUXSWAP: db "LINUX SWAP " ; 82h , LINUX SWAP Partition 11772 00003D8F 5020202020 11773 00003D94 4C494E555820202020- FS_LINUX: db "LINUX " ; 83h , LINUX NATIVE (ext2) Partition 11773 00003D9D 2020202020 11774 00003DA2 4C494E555820455854- FS_LINUXEXT: db "LINUX EXTENDED" ; 85h , LINUX EXTENDED Partition 11774 00003DAB 454E444544 11775 00003DB0 524444202020202020- FS_TRDD: db "RDD " ; A0h , (Random Data Disk) LBA 11775 00003DB9 2020202020 11776 00003DBE 53494E474C49582046- FS_TRFS: db "SINGLIX FS1 " ; A1h , (32 bit, 512 bytes per sector) 11776 00003DC7 5331202020 11777 00003DCC 554E4B4E4F574E2046- FS_OTHERS: db "UNKNOWN FS " ; Another or Unknown File Systems 11777 00003DD5 5320202020 11778 11779 valid_partitions: ; (*) 11780 00003DDA 01020304050607 db 01h, 02h, 03h, 04h, 05h, 06h, 07h 11781 00003DE1 0B0C0E0F637172 db 0Bh, 0Ch, 0Eh, 0Fh, 63h, 71h, 72h 11782 00003DE8 828385A0A1 db 82h, 83h, 85h, 0A0h, 0A1h 11783 11784 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11785 ; messages 11786 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11787 11788 CHS_msg: ; 80 bytes per row 11789 00003DED 507265737320274327- db "Press 'C' to set cylinders then press '+,-' keys to change number of cylinders. " 11789 00003DF6 20746F207365742063- 11789 00003DFF 796C696E6465727320- 11789 00003E08 7468656E2070726573- 11789 00003E11 7320272B2C2D27206B- 11789 00003E1A 65797320746F206368- 11789 00003E23 616E6765206E756D62- 11789 00003E2C 6572206F662063796C- 11789 00003E35 696E646572732E20 11790 00003E3D 507265737320274827- db "Press 'H' to set heads then press '+,-' keys to change number of heads. " 11790 00003E46 20746F207365742068- 11790 00003E4F 65616473207468656E- 11790 00003E58 20707265737320272B- 11790 00003E61 2C2D27206B65797320- 11790 00003E6A 746F206368616E6765- 11790 00003E73 206E756D626572206F- 11790 00003E7C 662068656164732E20- 11790 00003E85 2020202020202020 11791 00003E8D 507265737320275327- db "Press 'S' to set sectors then press '+,-' keys to change numb of sectors/track. " 11791 00003E96 20746F207365742073- 11791 00003E9F 6563746F7273207468- 11791 00003EA8 656E20707265737320- 11791 00003EB1 272B2C2D27206B6579- 11791 00003EBA 7320746F206368616E- 11791 00003EC3 6765206E756D62206F- 11791 00003ECC 6620736563746F7273- 11791 00003ED5 2F747261636B2E20 11792 00003EDD 202020202020202020- db " " 11792 00003EE6 202020202020202020- 11792 00003EEF 202020202020202020- 11792 00003EF8 202020202020202020- 11792 00003F01 202020202020202020- 11792 00003F0A 202020202020202020- 11792 00003F13 202020202020202020- 11792 00003F1C 202020202020202020- 11792 00003F25 2020202020202020 11793 00003F2D 202020202020202020- db " " 11793 00003F36 202020202020202020- 11793 00003F3F 202020202020202020- 11793 00003F48 202020202020202020- 11793 00003F51 202020202020202020- 11793 00003F5A 202020202020202020- 11793 00003F63 202020202020202020- 11793 00003F6C 202020202020202020- 11793 00003F75 2020202020202020 11794 00003F7D 507265737320454E54- db "Press ENTER to use current CHS values. " 11794 00003F86 455220746F20757365- 11794 00003F8F 2063757272656E7420- 11794 00003F98 4348532076616C7565- 11794 00003FA1 732E20202020202020- 11794 00003FAA 202020202020202020- 11794 00003FB3 202020202020202020- 11794 00003FBC 202020202020202020- 11794 00003FC5 2020202020202020 11795 00003FCD 202020202020202020- db " " 11795 00003FD6 202020202020202020- 11795 00003FDF 202020202020202020- 11795 00003FE8 202020202020202020- 11795 00003FF1 202020202020202020- 11795 00003FFA 202020202020202020- 11795 00004003 202020202020202020- 11795 0000400C 202020202020202020- 11795 00004015 2020202020202020 11796 0000401D 507265737320455343- db "Press ESC to cancel. " 11796 00004026 20746F2063616E6365- 11796 0000402F 6C2E20202020202020- 11796 00004038 202020202020202020- 11796 00004041 202020202020202020- 11796 0000404A 202020202020202020- 11796 00004053 202020202020202020- 11796 0000405C 202020202020202020- 11796 00004065 2020202020202020 11797 0000406D 202020202020202020- db " " 11797 00004076 202020202020202020- 11797 0000407F 202020202020202020- 11797 00004088 202020202020202020- 11797 00004091 202020202020202020- 11797 0000409A 202020202020202020- 11797 000040A3 202020202020202020- 11797 000040AC 202020202020202020- 11797 000040B5 2020202020202020 11798 000040BD 00 db 0 11799 11800 TrDOS_Welcome: 11801 000040BE 0D0A db 0Dh, 0Ah 11802 ;db 'TR-DOS 386 Fixed Disk Partitioning Utility' 11803 000040C0 526574726F20444F53- db 'Retro DOS v5 Fixed Disk Partitioning Utility' 11803 000040C9 207635204669786564- 11803 000040D2 204469736B20506172- 11803 000040DB 746974696F6E696E67- 11803 000040E4 205574696C697479 11804 000040EC 0D0A db 0Dh, 0Ah 11805 ;db "v2.1.240504 (c) Erdogan TAN 2021-2024" 11806 000040EE 464449534B34207632- db "FDISK4 v2.0.260129 (c) Erdogan TAN 2021-2026" 11806 000040F7 2E302E323630313239- 11806 00004100 20286329204572646F- 11806 00004109 67616E2054414E2032- 11806 00004112 3032312D32303236 11807 0000411A 0D0A db 0Dh,0Ah 11808 0000411C 0D0A db 0Dh,0Ah 11809 0000411E 00 db 0 11810 TrDOS_Usage: 11811 0000411F 55736167653A206664- db 'Usage: fdisk4r5 ' 11811 00004128 69736B347235203C68- 11811 00004131 617264206469736B20- 11811 0000413A 6E616D653E20 11812 00004140 0D0A db 0Dh, 0Ah 11813 00004142 0D0A db 0Dh, 0Ah 11814 00004144 48617264206469736B- db "Hard disk names: " 11814 0000414D 206E616D65733A20 11815 00004155 0D0A db 0Dh, 0Ah 11816 00004157 0D0A db 0Dh, 0Ah 11817 00004159 20686430202E2E666F- db " hd0 ..for 1st hard disk " 11817 00004162 722031737420686172- 11817 0000416B 64206469736B20 11818 00004172 0D0A db 0Dh, 0Ah 11819 00004174 20686431202E2E666F- db " hd1 ..for 2nd hard disk " 11819 0000417D 7220326E6420686172- 11819 00004186 64206469736B20 11820 0000418D 0D0A db 0Dh, 0Ah 11821 0000418F 20686432202E2E666F- db " hd2 ..for 3rd hard disk " 11821 00004198 722033726420686172- 11821 000041A1 64206469736B20 11822 000041A8 0D0A db 0Dh, 0Ah 11823 000041AA 20686433202E2E666F- db " hd3 ..for 4th hard disk " 11823 000041B3 722034746820686172- 11823 000041BC 64206469736B20 11824 000041C3 0D0A00 db 0Dh, 0Ah, 0 11825 11826 TrDOS_Options: 11827 000041C6 53656C656374206861- db "Select hard disk number (1 to " 11827 000041CF 7264206469736B206E- 11827 000041D8 756D62657220283120- 11827 000041E1 746F20 11828 TrDOS_dnmax: 11829 000041E4 3429206F7220707265- db "4) or press ESC to exit ..." 11829 000041ED 73732045534320746F- 11829 000041F6 2065786974202E2E2E 11830 000041FF 0D0A00 db 0Dh, 0Ah, 0 11831 TrDOS_hdrow: 11832 00004202 0D0A db 0Dh, 0Ah 11833 00004204 28 db "(" 11834 TrDOS_hdrow_n: 11835 00004205 3029206864 db "0) hd" 11836 TrDOS_hdrow_i: 11837 0000420A 30202D204361706163- db "0 - Capacity : " 11837 00004213 697479203A20 11838 00004219 00 db 0 11839 TrDOS_hdrow_unit: 11840 0000421A 474220 db "GB " 11841 0000421D 0D0A00 db 0Dh, 0Ah, 0 11842 11843 TrDOS_hdrow_capacity: 11844 00004220 303030302000 db "0000 ", 0 11845 00004226 00 db 0 11846 11847 TrDOS_disksize: 11848 00004227 0D0A db 0Dh, 0Ah 11849 00004229 4469736B2073697A65- db "Disk size : " 11849 00004232 203A20 11850 00004235 00 db 0 11851 11852 ; 05/11/2020 11853 ;msg_fdisk_capacity_err: 11854 ; db 0Dh, 0Ah 11855 ; db "Huge disk !" 11856 ; db 0Dh, 0Ah 11857 ; db "This FDISK version (v3) can work with disk sizes up to " 11858 ; db 0 11859 11860 msg_any_key_esc_exit: 11861 00004236 0D0A db 0Dh, 0Ah 11862 00004238 507265737320455343- db "Press ESC to exit or press another key to continue..." 11862 00004241 20746F206578697420- 11862 0000424A 6F7220707265737320- 11862 00004253 616E6F74686572206B- 11862 0000425C 657920746F20636F6E- 11862 00004265 74696E75652E2E2E 11863 0000426D 00 db 0 11864 11865 msg_create_partition_h: 11866 0000426E 0D0A db 0Dh, 0Ah 11867 00004270 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11867 00004279 2D2D2D2D2D2D2D2D2D- 11867 00004282 2D2D2D2D2D2D2D2D2D- 11867 0000428B 2D2D2D2D2D2D2D2D2D- 11867 00004294 2D2D2D2D2D2D2D2D2D- 11867 0000429D 2D2D2D2D2D2D2D2D2D- 11867 000042A6 2D2D2D2D2D2D2D2D2D- 11867 000042AF 2D2D2D2D2D2D2D2D2D- 11867 000042B8 2D2D2D2D2D2D2D2D 11868 000042C0 202020202020202020- db " Create Partition " 11868 000042C9 202020202020202020- 11868 000042D2 202020202020202020- 11868 000042DB 202020204372656174- 11868 000042E4 652050617274697469- 11868 000042ED 6F6E20202020202020- 11868 000042F6 202020202020202020- 11868 000042FF 202020202020202020- 11868 00004308 2020202020202020 11869 00004310 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11869 00004319 2D2D2D2D2D2D2D2D2D- 11869 00004322 2D2D2D2D2D2D2D2D2D- 11869 0000432B 2D2D2D2D2D2D2D2D2D- 11869 00004334 2D2D2D2D2D2D2D2D2D- 11869 0000433D 2D2D2D2D2D2D2D2D2D- 11869 00004346 2D2D2D2D2D2D2D2D2D- 11869 0000434F 2D2D2D2D2D2D2D2D2D- 11869 00004358 2D2D2D2D2D2D2D2D 11870 00004360 0D0A00 db 0Dh, 0Ah, 0 11871 msg_create_partition_m: 11872 00004363 53656C65637420616E- db "Select an option: " 11872 0000436C 206F7074696F6E3A20 11873 00004375 0D0A db 0Dh, 0Ah 11874 00004377 0D0A db 0Dh, 0Ah 11875 00004379 202031292043726561- db " 1) Create DOS partition ", 0Dh, 0Ah 11875 00004382 746520444F53207061- 11875 0000438B 72746974696F6E200D- 11875 00004394 0A 11876 00004395 202032292043726561- db " 2) Create SINGLIX FS partition ", 0Dh, 0Ah 11876 0000439E 74652053494E474C49- 11876 000043A7 582046532070617274- 11876 000043B0 6974696F6E200D0A 11877 000043B8 202033292043726561- db " 3) Create RETRO UNIX partition ", 0Dh, 0Ah 11877 000043C1 746520524554524F20- 11877 000043CA 554E49582070617274- 11877 000043D3 6974696F6E200D0A 11878 000043DB 202034292043726561- db " 4) Create another type of partition ", 0Dh, 0Ah 11878 000043E4 746520616E6F746865- 11878 000043ED 722074797065206F66- 11878 000043F6 20706172746974696F- 11878 000043FF 6E200D0A 11879 00004403 0D0A db 0Dh, 0Ah 11880 00004405 507265737320455343- db "Press ESC or 0 to cancel .. " 11880 0000440E 206F72203020746F20- 11880 00004417 63616E63656C202E2E- 11880 00004420 20 11881 00004421 0D0A00 db 0Dh, 0Ah, 0 11882 11883 msg_create_primary_partition_h: 11884 00004424 0D0A db 0Dh, 0Ah 11885 00004426 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11885 0000442F 2D2D2D2D2D2D2D2D2D- 11885 00004438 2D2D2D2D2D2D2D2D2D- 11885 00004441 2D2D2D2D2D2D2D2D2D- 11885 0000444A 2D2D2D2D2D2D2D2D2D- 11885 00004453 2D2D2D2D2D2D2D2D2D- 11885 0000445C 2D2D2D2D2D2D2D2D2D- 11885 00004465 2D2D2D2D2D2D2D2D2D- 11885 0000446E 2D2D2D2D2D2D2D2D 11886 00004476 202020202020202020- db " Create Primary DOS Partition " 11886 0000447F 202020202020202020- 11886 00004488 202020202020202043- 11886 00004491 726561746520507269- 11886 0000449A 6D61727920444F5320- 11886 000044A3 506172746974696F6E- 11886 000044AC 202020202020202020- 11886 000044B5 202020202020202020- 11886 000044BE 2020202020202020 11887 000044C6 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11887 000044CF 2D2D2D2D2D2D2D2D2D- 11887 000044D8 2D2D2D2D2D2D2D2D2D- 11887 000044E1 2D2D2D2D2D2D2D2D2D- 11887 000044EA 2D2D2D2D2D2D2D2D2D- 11887 000044F3 2D2D2D2D2D2D2D2D2D- 11887 000044FC 2D2D2D2D2D2D2D2D2D- 11887 00004505 2D2D2D2D2D2D2D2D2D- 11887 0000450E 2D2D2D2D2D2D2D2D 11888 00004516 0D0A00 db 0Dh, 0Ah, 0 11889 11890 msg_create_dos_partition_h: 11891 00004519 0D0A db 0Dh, 0Ah 11892 0000451B 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11892 00004524 2D2D2D2D2D2D2D2D2D- 11892 0000452D 2D2D2D2D2D2D2D2D2D- 11892 00004536 2D2D2D2D2D2D2D2D2D- 11892 0000453F 2D2D2D2D2D2D2D2D2D- 11892 00004548 2D2D2D2D2D2D2D2D2D- 11892 00004551 2D2D2D2D2D2D2D2D2D- 11892 0000455A 2D2D2D2D2D2D2D2D2D- 11892 00004563 2D2D2D2D2D2D2D2D 11893 0000456B 202020202020202020- db " Create DOS Partition or Logical DOS Drive " 11893 00004574 202020202020202020- 11893 0000457D 204372656174652044- 11893 00004586 4F5320506172746974- 11893 0000458F 696F6E206F72204C6F- 11893 00004598 676963616C20444F53- 11893 000045A1 204472697665202020- 11893 000045AA 202020202020202020- 11893 000045B3 2020202020202020 11894 000045BB 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11894 000045C4 2D2D2D2D2D2D2D2D2D- 11894 000045CD 2D2D2D2D2D2D2D2D2D- 11894 000045D6 2D2D2D2D2D2D2D2D2D- 11894 000045DF 2D2D2D2D2D2D2D2D2D- 11894 000045E8 2D2D2D2D2D2D2D2D2D- 11894 000045F1 2D2D2D2D2D2D2D2D2D- 11894 000045FA 2D2D2D2D2D2D2D2D2D- 11894 00004603 2D2D2D2D2D2D2D2D 11895 0000460B 0D0A00 db 0Dh, 0Ah, 0 11896 11897 msg_create_ext_partition_h: 11898 0000460E 0D0A db 0Dh, 0Ah 11899 00004610 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11899 00004619 2D2D2D2D2D2D2D2D2D- 11899 00004622 2D2D2D2D2D2D2D2D2D- 11899 0000462B 2D2D2D2D2D2D2D2D2D- 11899 00004634 2D2D2D2D2D2D2D2D2D- 11899 0000463D 2D2D2D2D2D2D2D2D2D- 11899 00004646 2D2D2D2D2D2D2D2D2D- 11899 0000464F 2D2D2D2D2D2D2D2D2D- 11899 00004658 2D2D2D2D2D2D2D2D 11900 00004660 202020202020202020- db " Create Extended DOS Partition " 11900 00004669 202020202020202020- 11900 00004672 202020202020204372- 11900 0000467B 656174652045787465- 11900 00004684 6E64656420444F5320- 11900 0000468D 506172746974696F6E- 11900 00004696 202020202020202020- 11900 0000469F 202020202020202020- 11900 000046A8 2020202020202020 11901 000046B0 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11901 000046B9 2D2D2D2D2D2D2D2D2D- 11901 000046C2 2D2D2D2D2D2D2D2D2D- 11901 000046CB 2D2D2D2D2D2D2D2D2D- 11901 000046D4 2D2D2D2D2D2D2D2D2D- 11901 000046DD 2D2D2D2D2D2D2D2D2D- 11901 000046E6 2D2D2D2D2D2D2D2D2D- 11901 000046EF 2D2D2D2D2D2D2D2D2D- 11901 000046F8 2D2D2D2D2D2D2D2D 11902 00004700 0D0A00 db 0Dh, 0Ah, 0 11903 11904 msg_create_logical_drive_h: 11905 00004703 0D0A db 0Dh, 0Ah 11906 00004705 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11906 0000470E 2D2D2D2D2D2D2D2D2D- 11906 00004717 2D2D2D2D2D2D2D2D2D- 11906 00004720 2D2D2D2D2D2D2D2D2D- 11906 00004729 2D2D2D2D2D2D2D2D2D- 11906 00004732 2D2D2D2D2D2D2D2D2D- 11906 0000473B 2D2D2D2D2D2D2D2D2D- 11906 00004744 2D2D2D2D2D2D2D2D2D- 11906 0000474D 2D2D2D2D2D2D2D2D 11907 00004755 202020202020202020- db " Create Logical DOS Drive " 11907 0000475E 202020202020202020- 11907 00004767 202020202020202020- 11907 00004770 20437265617465204C- 11907 00004779 6F676963616C20444F- 11907 00004782 532044726976652020- 11907 0000478B 202020202020202020- 11907 00004794 202020202020202020- 11907 0000479D 2020202020202020 11908 000047A5 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11908 000047AE 2D2D2D2D2D2D2D2D2D- 11908 000047B7 2D2D2D2D2D2D2D2D2D- 11908 000047C0 2D2D2D2D2D2D2D2D2D- 11908 000047C9 2D2D2D2D2D2D2D2D2D- 11908 000047D2 2D2D2D2D2D2D2D2D2D- 11908 000047DB 2D2D2D2D2D2D2D2D2D- 11908 000047E4 2D2D2D2D2D2D2D2D2D- 11908 000047ED 2D2D2D2D2D2D2D2D 11909 000047F5 0D0A00 db 0Dh, 0Ah, 0 11910 11911 msg_create_nondos_partition_h: 11912 000047F8 0D0A db 0Dh, 0Ah 11913 000047FA 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11913 00004803 2D2D2D2D2D2D2D2D2D- 11913 0000480C 2D2D2D2D2D2D2D2D2D- 11913 00004815 2D2D2D2D2D2D2D2D2D- 11913 0000481E 2D2D2D2D2D2D2D2D2D- 11913 00004827 2D2D2D2D2D2D2D2D2D- 11913 00004830 2D2D2D2D2D2D2D2D2D- 11913 00004839 2D2D2D2D2D2D2D2D2D- 11913 00004842 2D2D2D2D2D2D2D2D 11914 0000484A 202020202020202020- db " Create NON-DOS Partition " 11914 00004853 202020202020202020- 11914 0000485C 202020202020202020- 11914 00004865 20437265617465204E- 11914 0000486E 4F4E2D444F53205061- 11914 00004877 72746974696F6E2020- 11914 00004880 202020202020202020- 11914 00004889 202020202020202020- 11914 00004892 2020202020202020 11915 0000489A 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 11915 000048A3 2D2D2D2D2D2D2D2D2D- 11915 000048AC 2D2D2D2D2D2D2D2D2D- 11915 000048B5 2D2D2D2D2D2D2D2D2D- 11915 000048BE 2D2D2D2D2D2D2D2D2D- 11915 000048C7 2D2D2D2D2D2D2D2D2D- 11915 000048D0 2D2D2D2D2D2D2D2D2D- 11915 000048D9 2D2D2D2D2D2D2D2D2D- 11915 000048E2 2D2D2D2D2D2D2D2D 11916 000048EA 0D0A00 db 0Dh, 0Ah, 0 11917 11918 msg_create_dos_partition_m: 11919 000048ED 53656C65637420616E- db "Select an option: " 11919 000048F6 206F7074696F6E3A20 11920 000048FF 0D0A db 0Dh, 0Ah 11921 00004901 0D0A db 0Dh, 0Ah 11922 00004903 202031292043726561- db " 1) Create Primary DOS partition ", 0Dh, 0Ah 11922 0000490C 7465205072696D6172- 11922 00004915 7920444F5320706172- 11922 0000491E 746974696F6E200D0A 11923 00004927 202032292043726561- db " 2) Create Extended DOS partition ", 0Dh, 0Ah 11923 00004930 746520457874656E64- 11923 00004939 656420444F53207061- 11923 00004942 72746974696F6E200D- 11923 0000494B 0A 11924 0000494C 202033292043726561- db " 3) Create Logical DOS drive(s) in Extended DOS partition ", 0Dh, 0Ah 11924 00004955 7465204C6F67696361- 11924 0000495E 6C20444F5320647269- 11924 00004967 766528732920696E20- 11924 00004970 457874656E64656420- 11924 00004979 444F53207061727469- 11924 00004982 74696F6E200D0A 11925 00004989 0D0A db 0Dh, 0Ah 11926 0000498B 507265737320455343- db "Press ESC or 0 to cancel .. " 11926 00004994 206F72203020746F20- 11926 0000499D 63616E63656C202E2E- 11926 000049A6 20 11927 000049A7 0D0A00 db 0Dh, 0Ah, 0 11928 11929 msg_create_trdos_partition_s: 11930 000049AA 53656C65637420616E- db "Select an option to set partition size: " 11930 000049B3 206F7074696F6E2074- 11930 000049BC 6F2073657420706172- 11930 000049C5 746974696F6E207369- 11930 000049CE 7A653A20 11931 000049D2 0D0A db 0Dh, 0Ah 11932 000049D4 0D0A db 0Dh, 0Ah 11933 000049D6 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 11933 000049DF 6E64657220636F756E- 11933 000049E8 740D0A 11934 000049EB 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 11934 000049F4 6D652070657263656E- 11934 000049FD 746167652028232325- 11934 00004A06 290D0A 11935 00004A09 202053292053656374- db " S) Sectors (number of 512 bytes)", 0Dh, 0Ah 11935 00004A12 6F727320286E756D62- 11935 00004A1B 6572206F6620353132- 11935 00004A24 206279746573290D0A 11936 00004A2D 20204B29204B696C6F- db " K) Kilo bytes (KB, 2*K sectors)", 0Dh, 0Ah 11936 00004A36 20627974657320284B- 11936 00004A3F 422C20322A4B207365- 11936 00004A48 63746F7273290D0A 11937 00004A50 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 11937 00004A59 20627974657320284D- 11937 00004A62 422C20322A31303234- 11937 00004A6B 2A4D20736563746F72- 11937 00004A74 73290D0A 11938 00004A78 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 11938 00004A81 206279746573202847- 11938 00004A8A 422C20322A31303234- 11938 00004A93 2A313032342A472073- 11938 00004A9C 6563746F7273290D0A 11939 00004AA5 0D0A db 0Dh, 0Ah 11940 00004AA7 507265737320535041- db "Press SPACE to use whole disk or press ENTER to set sector count .. " 11940 00004AB0 434520746F20757365- 11940 00004AB9 2077686F6C65206469- 11940 00004AC2 736B206F7220707265- 11940 00004ACB 737320454E54455220- 11940 00004AD4 746F20736574207365- 11940 00004ADD 63746F7220636F756E- 11940 00004AE6 74202E2E20 11941 msg_press_esc_to_cancel: 11942 00004AEB 0D0A db 0Dh, 0Ah 11943 00004AED 285072657373204553- db "(Press ESC to CANCEL) " 11943 00004AF6 4320746F2043414E43- 11943 00004AFF 454C2920 11944 00004B03 0D0A00 db 0Dh, 0Ah, 0 11945 11946 msg_use_whole_disk: 11947 00004B06 446F20796F75207761- db "Do you want to use WHOLE disk !? (Y/N)", 0 11947 00004B0F 6E7420746F20757365- 11947 00004B18 2057484F4C45206469- 11947 00004B21 736B20213F2028592F- 11947 00004B2A 4E2900 11948 11949 msg_use_all_space: 11950 00004B2D 446F20796F75207761- db "Do you want to use all of available space !? (Y/N)", 0 11950 00004B36 6E7420746F20757365- 11950 00004B3F 20616C6C206F662061- 11950 00004B48 7661696C61626C6520- 11950 00004B51 737061636520213F20- 11950 00004B5A 28592F4E2900 11951 11952 msg_use_entire_ep_space: 11953 00004B60 446F20796F75207761- db "Do you want to use entire extended partition space !? (Y/N)", 0 11953 00004B69 6E7420746F20757365- 11953 00004B72 20656E746972652065- 11953 00004B7B 7874656E6465642070- 11953 00004B84 6172746974696F6E20- 11953 00004B8D 737061636520213F20- 11953 00004B96 28592F4E2900 11954 11955 msg_partition_size: 11956 00004B9C 0D0A db 0Dh, 0Ah 11957 00004B9E 0D0A db 0Dh, 0Ah 11958 00004BA0 506172746974696F6E- db "Partition size (" 11958 00004BA9 2073697A652028 11959 msg_partition_size_x: 11960 00004BB0 3F29203A20 db "?) : " 11961 00004BB5 00 db 0 11962 11963 msg_partition_type: 11964 00004BB6 0D0A db 0Dh, 0Ah 11965 00004BB8 0D0A db 0Dh, 0Ah 11966 00004BBA 506172746974696F6E- db "Partition type : " 11966 00004BC3 2074797065203A20 11967 00004BCB 00 db 0 11968 11969 msg_ptype_num: 11970 00004BCC 3030680D0A00 db "00h", 0Dh, 0Ah, 0 11971 11972 msg_partition_type_error: 11973 00004BD2 506172746974696F6E- db "Partition size is not proper for selected partition type !" 11973 00004BDB 2073697A6520697320- 11973 00004BE4 6E6F742070726F7065- 11973 00004BED 7220666F722073656C- 11973 00004BF6 656374656420706172- 11973 00004BFF 746974696F6E207479- 11973 00004C08 70652021 11974 00004C0C 0D0A db 0Dh, 0Ah 11975 msg_any_key_to_retry: 11976 00004C0E 28507265737320616E- db "(Press any key to retry..)" 11976 00004C17 79206B657920746F20- 11976 00004C20 72657472792E2E29 11977 00004C28 0D0A00 db 0Dh, 0Ah, 0 11978 11979 msg_partition_size_overs: 11980 00004C2B 0D0A db 0Dh, 0Ah 11981 00004C2D 506172746974696F6E- db "Partition size overs the disk capacity !" 11981 00004C36 2073697A65206F7665- 11981 00004C3F 727320746865206469- 11981 00004C48 736B20636170616369- 11981 00004C51 74792021 11982 00004C55 0D0A db 0Dh, 0Ah 11983 00004C57 28507265737320454E- db "(Press ENTER to use WHOLE disk or press ESC key to retry..)" 11983 00004C60 54455220746F207573- 11983 00004C69 652057484F4C452064- 11983 00004C72 69736B206F72207072- 11983 00004C7B 65737320455343206B- 11983 00004C84 657920746F20726574- 11983 00004C8D 72792E2E29 11984 00004C92 0D0A00 db 0Dh, 0Ah, 0 11985 11986 msg_ext_partition_error: 11987 00004C95 457874656E64656420- db "Extended partition must be created after primary partition !" 11987 00004C9E 706172746974696F6E- 11987 00004CA7 206D75737420626520- 11987 00004CB0 637265617465642061- 11987 00004CB9 66746572207072696D- 11987 00004CC2 617279207061727469- 11987 00004CCB 74696F6E2021 11988 00004CD1 0D0A00 db 0Dh, 0Ah,0 11989 11990 msg_logical_drive_error: 11991 00004CD4 5072696D6172792061- db "Primary and extended partitions must be created before logical drive !" 11991 00004CDD 6E6420657874656E64- 11991 00004CE6 656420706172746974- 11991 00004CEF 696F6E73206D757374- 11991 00004CF8 206265206372656174- 11991 00004D01 6564206265666F7265- 11991 00004D0A 206C6F676963616C20- 11991 00004D13 64726976652021 11992 00004D1A 0D0A00 db 0Dh, 0Ah,0 11993 11994 msg_cylinder_boundary_set: 11995 00004D1D 0D0A db 0Dh, 0Ah 11996 00004D1F 446F20796F75207761- db "Do you want to adjust partition size to cylinder boundary ? (Y/N)" 11996 00004D28 6E7420746F2061646A- 11996 00004D31 757374207061727469- 11996 00004D3A 74696F6E2073697A65- 11996 00004D43 20746F2063796C696E- 11996 00004D4C 64657220626F756E64- 11996 00004D55 617279203F2028592F- 11996 00004D5E 4E29 11997 00004D60 00 db 0 11998 11999 ; 2019 - 2020 (hdimage.s) 12000 ;msg_selected_partition: 12001 ; db " PARTITION 0 " 12002 ; db "================================================================================" 12003 ; db " S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 12004 ; db "--------------------------------------------------------------------------------" 12005 ;pt_row: db " " 12006 ; db "================================================================================" 12007 ; db 0 12008 12009 ; 24/10/2020 (fdisk3.s) 12010 msg_selected_partition: 12011 00004D61 202020202020202020- db " PARTITION 0 " 12011 00004D6A 202020202020202020- 12011 00004D73 202020202020202020- 12011 00004D7C 202020202020504152- 12011 00004D85 544954494F4E203020- 12011 00004D8E 202020202020202020- 12011 00004D97 202020202020202020- 12011 00004DA0 202020202020202020- 12011 00004DA9 2020202020202020 12012 00004DB1 3D3D3D3D3D3D3D3D3D- db "================================================================================" 12012 00004DBA 3D3D3D3D3D3D3D3D3D- 12012 00004DC3 3D3D3D3D3D3D3D3D3D- 12012 00004DCC 3D3D3D3D3D3D3D3D3D- 12012 00004DD5 3D3D3D3D3D3D3D3D3D- 12012 00004DDE 3D3D3D3D3D3D3D3D3D- 12012 00004DE7 3D3D3D3D3D3D3D3D3D- 12012 00004DF0 3D3D3D3D3D3D3D3D3D- 12012 00004DF9 3D3D3D3D3D3D3D3D 12013 00004E01 202020202020205320- db " S BH BS BC FS EH ES EC START SECT SECTORS FILE SYSTEM " 12013 00004E0A 204248202042532020- 12013 00004E13 424320204653202045- 12013 00004E1C 482020455320204543- 12013 00004E25 202020535441525420- 12013 00004E2E 534543542020202053- 12013 00004E37 4543544F5253202020- 12013 00004E40 46494C452053595354- 12013 00004E49 454D202020202020 12014 00004E51 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 12014 00004E5A 2D2D2D2D2D2D2D2D2D- 12014 00004E63 2D2D2D2D2D2D2D2D2D- 12014 00004E6C 2D2D2D2D2D2D2D2D2D- 12014 00004E75 2D2D2D2D2D2D2D2D2D- 12014 00004E7E 2D2D2D2D2D2D2D2D2D- 12014 00004E87 2D2D2D2D2D2D2D2D2D- 12014 00004E90 2D2D2D2D2D2D2D2D2D- 12014 00004E99 2D2D2D2D2D2D2D2D 12015 00004EA1 202020202020202020- pt_row: db " " 12015 00004EAA 202020202020202020- 12015 00004EB3 202020202020202020- 12015 00004EBC 202020202020202020- 12015 00004EC5 202020202020202020- 12015 00004ECE 202020202020202020- 12015 00004ED7 202020202020202020- 12015 00004EE0 202020202020202020- 12015 00004EE9 2020202020202020 12016 00004EF1 3D3D3D3D3D3D3D3D3D- db "================================================================================" 12016 00004EFA 3D3D3D3D3D3D3D3D3D- 12016 00004F03 3D3D3D3D3D3D3D3D3D- 12016 00004F0C 3D3D3D3D3D3D3D3D3D- 12016 00004F15 3D3D3D3D3D3D3D3D3D- 12016 00004F1E 3D3D3D3D3D3D3D3D3D- 12016 00004F27 3D3D3D3D3D3D3D3D3D- 12016 00004F30 3D3D3D3D3D3D3D3D3D- 12016 00004F39 3D3D3D3D3D3D3D3D 12017 00004F41 00 db 0 12018 msg_boot_indicator: 12019 00004F42 0D0A db 0Dh, 0Ah 12020 00004F44 20202020426F6F7420- db " Boot Indicator : ", 0 ; "YES", "NO" 12020 00004F4D 496E64696361746F72- 12020 00004F56 203A2000 12021 msg_starting_head: 12022 00004F5A 0D0A db 0Dh, 0Ah 12023 00004F5C 202020202053746172- db " Starting Head : ", 0 12023 00004F65 74696E672048656164- 12023 00004F6E 203A2000 12024 msg_starting_sector: 12025 00004F72 0D0A db 0Dh, 0Ah 12026 00004F74 202020537461727469- db " Starting Sector : ", 0 12026 00004F7D 6E6720536563746F72- 12026 00004F86 203A2000 12027 msg_starting_cylinder: 12028 00004F8A 0D0A db 0Dh, 0Ah 12029 00004F8C 205374617274696E67- db " Starting Cylinder : ", 0 12029 00004F95 2043796C696E646572- 12029 00004F9E 203A2000 12030 msg_system_id: 12031 00004FA2 0D0A db 0Dh, 0Ah 12032 00004FA4 202020202020202020- db " System ID : ", 0 12032 00004FAD 53797374656D204944- 12032 00004FB6 203A2000 12033 msg_ending_head: 12034 00004FBA 0D0A db 0Dh, 0Ah 12035 00004FBC 20202020202020456E- db " Ending Head : ", 0 12035 00004FC5 64696E672048656164- 12035 00004FCE 203A2000 12036 msg_ending_sector: 12037 00004FD2 0D0A db 0Dh, 0Ah 12038 00004FD4 2020202020456E6469- db " Ending Sector : ", 0 12038 00004FDD 6E6720536563746F72- 12038 00004FE6 203A2000 12039 msg_ending_cylinder: 12040 00004FEA 0D0A db 0Dh, 0Ah 12041 00004FEC 202020456E64696E67- db " Ending Cylinder : ", 0 12041 00004FF5 2043796C696E646572- 12041 00004FFE 203A2000 12042 msg_relative_sectors: 12043 00005002 0D0A db 0Dh, 0Ah 12044 00005004 0D0A db 0Dh, 0Ah 12045 00005006 202052656C61746976- db " Relative Sectors : ", 0 12045 0000500F 6520536563746F7273- 12045 00005018 203A2000 12046 msg_total_sectors: 12047 0000501C 0D0A db 0Dh, 0Ah 12048 0000501E 2020202020546F7461- db " Total Sectors : ", 0 12048 00005027 6C20536563746F7273- 12048 00005030 203A2000 12049 12050 msg_format_stage: 12051 00005034 0D0A db 0Dh, 0Ah 12052 00005036 507265737320454E54- db "Press ENTER to FORMAT disk partition " 12052 0000503F 455220746F20464F52- 12052 00005048 4D4154206469736B20- 12052 00005051 706172746974696F6E- 12052 0000505A 20 12053 partition_num_chr: 12054 0000505B 30 db "0" 12055 0000505C 206F72207072657373- db " or press ESC to EXIT.." 12055 00005065 2045534320746F2045- 12055 0000506E 5849542E2E 12056 00005073 00 db 0 12057 msg_partition_edit: 12058 00005074 0D0A db 0Dh, 0Ah 12059 00005076 2E2E206F7220707265- db ".. or press SPACE to EDIT partition table." 12059 0000507F 737320535041434520- 12059 00005088 746F20454449542070- 12059 00005091 6172746974696F6E20- 12059 0000509A 7461626C652E 12060 000050A0 0D0A00 db 0Dh, 0Ah, 0 12061 12062 msg_edit_or_exit: 12063 000050A3 0D0A db 0Dh, 0Ah 12064 000050A5 507265737320454E54- db "Press ENTER to continue or press ESC to exit.." 12064 000050AE 455220746F20636F6E- 12064 000050B7 74696E7565206F7220- 12064 000050C0 707265737320455343- 12064 000050C9 20746F20657869742E- 12064 000050D2 2E 12065 000050D3 00 db 0 12066 12067 msg_overwrite_question1: 12068 000050D4 0D0A db 0Dh, 0Ah 12069 000050D6 446F20796F75207761- db 'Do you want to overwrite ' 12069 000050DF 6E7420746F206F7665- 12069 000050E8 72777269746520 12070 000050EF 27 db 27h 12071 000050F0 00 db 0 12072 12073 msg_overwrite_question2: 12074 000050F1 27 db 27h 12075 000050F2 2066696C6520 db ' file ' 12076 000050F8 00 db 0 12077 12078 msg_format_question: 12079 000050F9 0D0A db 0Dh, 0Ah 12080 000050FB 446F20796F75207761- db "Do you want to format partition " 12080 00005104 6E7420746F20666F72- 12080 0000510D 6D6174207061727469- 12080 00005116 74696F6E20 12081 partition_num_txt: 12082 0000511B 3020 db "0 " 12083 msg_yes_no: 12084 0000511D 285965732F4E6F293F- db '(Yes/No)? ', 0 12084 00005126 2000 12085 12086 msg_writing_mbr: 12087 00005128 57726974696E67206D- db "Writing masterboot sector...", 0 12087 00005131 6173746572626F6F74- 12087 0000513A 20736563746F722E2E- 12087 00005143 2E00 12088 12089 msg_writing_disk_sectors: 12090 00005145 57726974696E672064- db "Writing disk sector: ", 0 12090 0000514E 69736B20736563746F- 12090 00005157 723A2000 12091 12092 Msg_Writing_Boot_Sector: 12093 0000515B 57726974696E672074- db "Writing trdos boot sector...", 0 12093 00005164 72646F7320626F6F74- 12093 0000516D 20736563746F722E2E- 12093 00005176 2E00 12094 12095 Msg_Writing_Root_Dir: 12096 00005178 57726974696E672072- db "Writing root directory sectors...", 0 12096 00005181 6F6F74206469726563- 12096 0000518A 746F72792073656374- 12096 00005193 6F72732E2E2E00 12097 12098 Msg_Writing_Data_Sectors: 12099 0000519A 57726974696E672064- db "Writing data sector: ", 0 12099 000051A3 61746120736563746F- 12099 000051AC 723A2000 12100 12101 Sector_Str: 12102 000051B0 3030303030303000 db "0000000", 0 12103 Cursor_Pos: 12104 000051B8 0000 dw 0 12105 12106 Msg_Writing_FAT_Sectors: 12107 000051BA 57726974696E672046- db "Writing FAT sectors...", 0 12107 000051C3 415420736563746F72- 12107 000051CC 732E2E2E00 12108 12109 StrVolumeName: 12110 ;times 12 db 0 12111 000051D1 00 times 65 db 0 ; 05/01/2018 (fs1 volume name) 12112 12113 Msg_Volume_Name: 12114 00005212 0D0A db 0Dh, 0Ah 12115 00005214 0D0A db 0Dh, 0Ah 12116 00005216 566F6C756D65204E61- db "Volume Name: ", 0 12116 0000521F 6D653A2000 12117 12118 Msg_Volume_Serial: 12119 00005224 566F6C756D65205365- db "Volume Serial No: " 12119 0000522D 7269616C204E6F3A20 12120 Vol_Serial1: 12121 00005236 30303030 db "0000" 12122 0000523A 2D db "-" 12123 Vol_Serial2: 12124 0000523B 30303030 db "0000" 12125 0000523F 0D0A00 db 0Dh, 0Ah, 0 12126 12127 msg_cluster_count: 12128 00005242 436C75737465722043- db "Cluster Count: ", 0 12128 0000524B 6F756E743A2000 12129 cluster_count_str: 12130 00005252 30303030303030 db "0000000" 12131 00005259 0D0A00 db 0Dh, 0Ah, 0 12132 msg_formatting: 12133 0000525C 466F726D617474696E- db "Formatting ", 0 12133 00005265 672000 12134 format_percent_str: 12135 00005268 30303025 db "000%" 12136 0000526C 00 db 0 12137 12138 Msg_3dot_OK: 12139 0000526D 2E2E2E db "..." 12140 Msg_OK: 12141 00005270 204F4B2E db ' OK.' 12142 CRLF: 12143 00005274 0D0A00 db 0Dh, 0Ah, 0 12144 12145 Msg_Error: 12146 00005277 0D0A db 0Dh, 0Ah 12147 00005279 4572726F72202120 db 'Error ! ' 12148 00005281 28 db '(' 12149 error_code: 12150 00005282 3030 dw 3030h 12151 00005284 68 db 'h' 12152 00005285 2920 db ') ' 12153 00005287 0D0A db 0Dh, 0Ah 12154 00005289 00 db 0 12155 12156 msg_disk_sectors: 12157 0000528A 546F74616C20446973- db "Total Disk Sectors : ", 0 12157 00005293 6B20536563746F7273- 12157 0000529C 203A2000 12158 12159 str_disk_sectors: 12160 ;times 8 db 0 12161 000052A0 00 times 11 db 0 ; 27/10/2020 12162 12163 msg_ep_size: 12164 000052AB 457874656E64656420- db "Extended Partition Size in Sectors: ", 0 12164 000052B4 506172746974696F6E- 12164 000052BD 2053697A6520696E20- 12164 000052C6 536563746F72733A20- 12164 000052CF 00 12165 12166 msg_press_any_key: 12167 000052D0 0D0A db 0Dh, 0Ah 12168 000052D2 50726573732061206B- db "Press a key to continue..." 12168 000052DB 657920746F20636F6E- 12168 000052E4 74696E75652E2E2E 12169 000052EC 0D0A00 db 0Dh, 0Ah, 0 12170 12171 000052EF 90 align 2 12172 12173 ; Masterboot sector 12174 12175 MasterBootBuff: 12176 MasterBootCode: 12177 000052F0 00 times 446 db 0 12178 PartitionTable: 12179 000054AE 00 times 64 db 0 12180 MBIDCode: 12181 000054EE 0000 dw 0 12182 12183 PTable_Buffer: 12184 000054F0 00 times 64 db 0 12185 12186 00005530 286329204572646F67- db '(c) Erdogan TAN 2019-2026' 12186 00005539 616E2054414E203230- 12186 00005542 31392D32303236 12187 12188 ; 05/11/2020 12189 00005549 00 db 0 12190 12191 ; 2019 - 2020 (hdimage.s) 12192 ;p_table_header: 12193 ; db " ?BR PARTITION TABLE " 12194 ; db "================================================================================" 12195 ; db " P S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 12196 ; db "--------------------------------------------------------------------------------" 12197 ; db 0 12198 ;p_table_footer: 12199 ; db "================================================================================" 12200 ; db 0Dh, 0Ah, 0 12201 12202 ; 24/10/2020 (fdisk3.s) 12203 p_table_header: 12204 0000554A 202020202020202020- db " ?BR PARTITION TABLE " 12204 00005553 202020202020202020- 12204 0000555C 202020202020202020- 12204 00005565 2020203F4252205041- 12204 0000556E 52544954494F4E2054- 12204 00005577 41424C452020202020- 12204 00005580 202020202020202020- 12204 00005589 202020202020202020- 12204 00005592 2020202020202020 12205 0000559A 3D3D3D3D3D3D3D3D3D- db "================================================================================" 12205 000055A3 3D3D3D3D3D3D3D3D3D- 12205 000055AC 3D3D3D3D3D3D3D3D3D- 12205 000055B5 3D3D3D3D3D3D3D3D3D- 12205 000055BE 3D3D3D3D3D3D3D3D3D- 12205 000055C7 3D3D3D3D3D3D3D3D3D- 12205 000055D0 3D3D3D3D3D3D3D3D3D- 12205 000055D9 3D3D3D3D3D3D3D3D3D- 12205 000055E2 3D3D3D3D3D3D3D3D 12206 000055EA 202020502020205320- db " P S BH BS BC FS EH ES EC START SECT SECTORS FILE SYSTEM " 12206 000055F3 204248202042532020- 12206 000055FC 424320204653202045- 12206 00005605 482020455320204543- 12206 0000560E 202020535441525420- 12206 00005617 534543542020202053- 12206 00005620 4543544F5253202020- 12206 00005629 2046494C4520535953- 12206 00005632 54454D2020202020 12207 0000563A 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 12207 00005643 2D2D2D2D2D2D2D2D2D- 12207 0000564C 2D2D2D2D2D2D2D2D2D- 12207 00005655 2D2D2D2D2D2D2D2D2D- 12207 0000565E 2D2D2D2D2D2D2D2D2D- 12207 00005667 2D2D2D2D2D2D2D2D2D- 12207 00005670 2D2D2D2D2D2D2D2D2D- 12207 00005679 2D2D2D2D2D2D2D2D2D- 12207 00005682 2D2D2D2D2D2D2D2D 12208 0000568A 00 db 0 12209 p_table_footer: 12210 0000568B 3D3D3D3D3D3D3D3D3D- db "================================================================================" 12210 00005694 3D3D3D3D3D3D3D3D3D- 12210 0000569D 3D3D3D3D3D3D3D3D3D- 12210 000056A6 3D3D3D3D3D3D3D3D3D- 12210 000056AF 3D3D3D3D3D3D3D3D3D- 12210 000056B8 3D3D3D3D3D3D3D3D3D- 12210 000056C1 3D3D3D3D3D3D3D3D3D- 12210 000056CA 3D3D3D3D3D3D3D3D3D- 12210 000056D3 3D3D3D3D3D3D3D3D 12211 000056DB 0D0A00 db 0Dh, 0Ah, 0 12212 12213 mbr_editing_options: 12214 000056DE 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12215 000056E2 4D4252205061727469- db "MBR Partition Table Editing Options:" 12215 000056EB 74696F6E205461626C- 12215 000056F4 652045646974696E67- 12215 000056FD 204F7074696F6E733A 12216 00005706 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12217 0000570A 20202020202020312E- db " 1. Create Partition", 0Dh, 0Ah 12217 00005713 204372656174652050- 12217 0000571C 6172746974696F6E0D- 12217 00005725 0A 12218 00005726 20202020202020322E- db " 2. Set Active Partition", 0Dh, 0Ah 12218 0000572F 205365742041637469- 12218 00005738 766520506172746974- 12218 00005741 696F6E0D0A 12219 00005746 20202020202020332E- db " 3. Delete Partition", 0Dh, 0Ah 12219 0000574F 2044656C6574652050- 12219 00005758 6172746974696F6E0D- 12219 00005761 0A 12220 00005762 20202020202020342E- db " 4. Write Current Partition Table", 0Dh, 0Ah, 0 12220 0000576B 205772697465204375- 12220 00005774 7272656E7420506172- 12220 0000577D 746974696F6E205461- 12220 00005786 626C650D0A00 12221 12222 enter_option_number_msg: 12223 0000578C 0D0A db 0Dh, 0Ah 12224 0000578E 456E74657220746865- db "Enter the option number or press ESC to exit ...", 0Dh, 0Ah 12224 00005797 206F7074696F6E206E- 12224 000057A0 756D626572206F7220- 12224 000057A9 707265737320455343- 12224 000057B2 20746F206578697420- 12224 000057BB 2E2E2E0D0A 12225 ;db 0Dh, 0Ah, 0 12226 000057C0 00 db 0 12227 12228 msg_zero_partition_size: ; 19/02/2019 12229 000057C1 0D0A db 0Dh, 0Ah 12230 000057C3 506172746974696F6E- db "Partition size input must not be ZERO !", 0Dh, 0Ah 12230 000057CC 2073697A6520696E70- 12230 000057D5 7574206D757374206E- 12230 000057DE 6F74206265205A4552- 12230 000057E7 4F20210D0A 12231 000057EC 285072657373204553- db "(Press ESC to exit or press another key to retry..)", 0Dh, 0Ah 12231 000057F5 4320746F2065786974- 12231 000057FE 206F72207072657373- 12231 00005807 20616E6F7468657220- 12231 00005810 6B657920746F207265- 12231 00005819 7472792E2E290D0A 12232 00005821 00 db 0 12233 12234 msg_empty_pt: 12235 00005822 0D0A db 0Dh, 0Ah 12236 00005824 456D70747920706172- db "Empty partition table !", 0Dh, 0Ah 12236 0000582D 746974696F6E207461- 12236 00005836 626C6520210D0A 12237 0000583D 28412076616C696420- db "(A valid partition must be created at first..)", 0Dh, 0Ah 12237 00005846 706172746974696F6E- 12237 0000584F 206D75737420626520- 12237 00005858 637265617465642061- 12237 00005861 742066697273742E2E- 12237 0000586A 290D0A 12238 0000586D 00 db 0 12239 12240 msg_full_pt: 12241 0000586E 0D0A db 0Dh, 0Ah 12242 00005870 546865726520697320- db "There is not a free partition table entry ", 0 12242 00005879 6E6F74206120667265- 12242 00005882 652070617274697469- 12242 0000588B 6F6E207461626C6520- 12242 00005894 656E7472792000 12243 msg_to_create_new_p: 12244 0000589B 746F20637265617465- db "to create a new partition !", 0Dh, 0Ah 12244 000058A4 2061206E6577207061- 12244 000058AD 72746974696F6E2021- 12244 000058B6 0D0A 12245 000058B8 00 db 0 12246 msg_no_free_space: 12247 000058B9 0D0A db 0Dh, 0Ah 12248 000058BB 546865726520697320- db "There is not (enough) free space ", 0 12248 000058C4 6E6F742028656E6F75- 12248 000058CD 676829206672656520- 12248 000058D6 73706163652000 12249 12250 msg_enter_pn_to_del: 12251 000058DD 0D0A db 0Dh, 0Ah 12252 000058DF 456E74657220706172- db "Enter partition number to delete: " 12252 000058E8 746974696F6E206E75- 12252 000058F1 6D62657220746F2064- 12252 000058FA 656C6574653A20 12253 chr_del_pnum1: 12254 00005901 00 db 0 12255 00005902 0D0A00 db 0Dh, 0Ah, 0 12256 12257 msg_delete_partition_q: 12258 00005905 0D0A db 0Dh, 0Ah 12259 00005907 5741524E494E472120- db "WARNING! All of data in the selected partition will be lost", 0Dh, 0Ah 12259 00005910 416C6C206F66206461- 12259 00005919 746120696E20746865- 12259 00005922 2073656C6563746564- 12259 0000592B 20706172746974696F- 12259 00005934 6E2077696C6C206265- 12259 0000593D 206C6F73740D0A 12260 00005944 202020202020202020- db " after you write changed partition table to disk !!", 0Dh, 0Ah 12260 0000594D 616674657220796F75- 12260 00005956 207772697465206368- 12260 0000595F 616E67656420706172- 12260 00005968 746974696F6E207461- 12260 00005971 626C6520746F206469- 12260 0000597A 736B2021210D0A 12261 00005981 0D0A db 0Dh, 0Ah 12262 00005983 446F20796F75207761- db "Do you want to delete PARTITION " 12262 0000598C 6E7420746F2064656C- 12262 00005995 657465205041525449- 12262 0000599E 54494F4E20 12263 chr_del_pnum2: 12264 000059A3 30 db '0' 12265 000059A4 203F2028592F4E2920- db ' ? (Y/N) ', 0 12265 000059AD 00 12266 12267 _msg_YES: 12268 000059AE 20 db 20h 12269 msg_YES: 12270 000059AF 5945532000 db 'YES ', 0 12271 _msg_NO: 12272 000059B4 20 db 20h 12273 msg_NO: 12274 000059B5 4E4F2000 db 'NO ', 0 12275 12276 ; 11/02/2019 12277 msg_write_masterboot_sector: 12278 000059B9 0D0A db 0Dh, 0Ah 12279 000059BB 577269746520437572- db "Write Current Partition Table:" 12279 000059C4 72656E742050617274- 12279 000059CD 6974696F6E20546162- 12279 000059D6 6C653A 12280 000059D9 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12281 000059DD 20312E205772697465- db " 1. Write Partition Table only", 0Dh, 0Ah 12281 000059E6 20506172746974696F- 12281 000059EF 6E205461626C65206F- 12281 000059F8 6E6C790D0A 12282 000059FD 20322E205772697465- db " 2. Write Partition Table and Singlix Master Boot Code", 0Dh, 0Ah 12282 00005A06 20506172746974696F- 12282 00005A0F 6E205461626C652061- 12282 00005A18 6E642053696E676C69- 12282 00005A21 78204D617374657220- 12282 00005A2A 426F6F7420436F6465- 12282 00005A33 0D0A 12283 enter_opt_num_cancel_msg: 12284 00005A35 0D0A db 0Dh, 0Ah 12285 00005A37 456E74657220746865- db "Enter the option number or press ESC to cancel ...", 0 12285 00005A40 206F7074696F6E206E- 12285 00005A49 756D626572206F7220- 12285 00005A52 707265737320455343- 12285 00005A5B 20746F2063616E6365- 12285 00005A64 6C202E2E2E00 12286 12287 msg_writing_ptable: 12288 00005A6A 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12289 00005A6E 57726974696E672070- db "Writing partition table on disk ... ", 0 12289 00005A77 6172746974696F6E20- 12289 00005A80 7461626C65206F6E20- 12289 00005A89 6469736B202E2E2E20- 12289 00005A92 00 12290 _msg_OK: 12291 ;db 7 12292 00005A93 0D0A db 0Dh, 0Ah 12293 00005A95 4F4B2021 db "OK !" 12294 00005A99 0D0A00 db 0Dh, 0Ah, 0 12295 12296 option_input: 12297 00005A9C 205B205D00 db ' [ ]', 0 12298 12299 msg_enter_pn_to_act: 12300 00005AA1 0D0A db 0Dh, 0Ah 12301 00005AA3 456E74657220706172- db "Enter partition number to set as active: ", 0 12301 00005AAC 746974696F6E206E75- 12301 00005AB5 6D62657220746F2073- 12301 00005ABE 657420617320616374- 12301 00005AC7 6976653A2000 12302 12303 ; 04/05/2024 12304 ;trdos386_disk_chs_header: 12305 ; db 0Dh, 0Ah 12306 ; db " TRDOS 386 (SINGLIX) HARD DISK IMAGE " 12307 ; db 0 12308 12309 ;disk_chs_header: 12310 ; db 0Dh, 0Ah 12311 ; db " HARD DISK IMAGE " 12312 ; db 0 12313 12314 msg_partition_size_limit: 12315 00005ACD 0D0A db 0Dh, 0Ah 12316 00005ACF 506172746974696F6E- db "Partition size overs available free space !" 12316 00005AD8 2073697A65206F7665- 12316 00005AE1 727320617661696C61- 12316 00005AEA 626C65206672656520- 12316 00005AF3 73706163652021 12317 00005AFA 0D0A db 0Dh, 0Ah 12318 00005AFC 4D61782E2061766169- db "Max. available free space is ", 0 12318 00005B05 6C61626C6520667265- 12318 00005B0E 652073706163652069- 12318 00005B17 732000 12319 12320 msg_partition_size_limit_r: 12321 00005B1A 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12322 00005B1E 28507265737320454E- db "(Press ENTER to use all of available space or press ESC key to retry..) " 12322 00005B27 54455220746F207573- 12322 00005B30 6520616C6C206F6620- 12322 00005B39 617661696C61626C65- 12322 00005B42 207370616365206F72- 12322 00005B4B 207072657373204553- 12322 00005B54 43206B657920746F20- 12322 00005B5D 72657472792E2E2920 12323 00005B66 000A00 db 0D, 0Ah, 0 12324 12325 msg_cylinders: 12326 00005B69 2063796C696E646572- db " cylinders", 0 12326 00005B72 7300 12327 msg_sectors: 12328 00005B74 20736563746F727300 db " sectors", 0 12329 12330 ; 02/03/2019 12331 msg_megabytes: 12332 00005B7D 206D65676162797465 db " megabyte" 12333 msg_megabytes_s: 12334 00005B86 0000 db 0, 0 12335 12336 msg_inv_pte: 12337 00005B88 0D0A db 0Dh, 0Ah 12338 00005B8A 496E76616C69642070- db "Invalid partition table entry ! (P" 12338 00005B93 6172746974696F6E20- 12338 00005B9C 7461626C6520656E74- 12338 00005BA5 72792021202850 12339 00005BAC 3F290D0A inv_pte_num: db "?)", 0Dh, 0Ah 12340 00005BB0 28507265737320454E- db "(Press ENTER to DELETE or press ESC to EXIT..)" 12340 00005BB9 54455220746F204445- 12340 00005BC2 4C455445206F722070- 12340 00005BCB 726573732045534320- 12340 00005BD4 746F20455849542E2E- 12340 00005BDD 29 12341 00005BDE 0D0A00 db 0Dh, 0Ah, 0 12342 12343 msg_ext_partition_exists: 12344 00005BE1 457874656E64656420- db "Extended partition already exists !" 12344 00005BEA 706172746974696F6E- 12344 00005BF3 20616C726561647920- 12344 00005BFC 6578697374732021 12345 00005C04 0D0A00 db 0Dh, 0Ah, 0 12346 12347 msg_defective_pt: 12348 00005C07 0D0A db 0Dh, 0Ah 12349 00005C09 446566656374697665- db "Defective partition table !", 0 12349 00005C12 20706172746974696F- 12349 00005C1B 6E207461626C652021- 12349 00005C24 00 12350 12351 ; 27/02/2019 12352 msg_ext_part_del_error: 12353 00005C25 0D0A db 0Dh, 0Ah 12354 00005C27 457874656E64656420- db "Extended partition must be deleted after logical drive(s) !" 12354 00005C30 706172746974696F6E- 12354 00005C39 206D75737420626520- 12354 00005C42 64656C657465642061- 12354 00005C4B 66746572206C6F6769- 12354 00005C54 63616C206472697665- 12354 00005C5D 2873292021 12355 00005C62 0D0A00 db 0Dh, 0Ah, 0 12356 12357 msg_cancel_continue: 12358 00005C65 285072657373204553- db "(Press ESC to cancel or press another key to continue..)" 12358 00005C6E 4320746F2063616E63- 12358 00005C77 656C206F7220707265- 12358 00005C80 737320616E6F746865- 12358 00005C89 72206B657920746F20- 12358 00005C92 636F6E74696E75652E- 12358 00005C9B 2E29 12359 00005C9D 0D0A00 db 0Dh, 0Ah, 0 12360 12361 msg_delete_ldd: 12362 00005CA0 0D0A db 0Dh, 0Ah 12363 00005CA2 0D0A db 0Dh, 0Ah 12364 00005CA4 44656C657465204C6F- db "Delete Logical (DOS) Drive:" 12364 00005CAD 676963616C2028444F- 12364 00005CB6 53292044726976653A 12365 00005CBF 0D0A db 0Dh, 0Ah 12366 00005CC1 50726573732044454C- db "Press DELETE key to delete logical disk partition " 12366 00005CCA 455445206B65792074- 12366 00005CD3 6F2064656C65746520- 12366 00005CDC 6C6F676963616C2064- 12366 00005CE5 69736B207061727469- 12366 00005CEE 74696F6E20 12367 00005CF3 3F2E lddp_num: db "?." 12368 00005CF5 0D0A00 db 0Dh, 0Ah, 0 12369 12370 msg_delete_ext_part: 12371 00005CF8 0D0A db 0Dh, 0Ah 12372 00005CFA 0D0A db 0Dh, 0Ah 12373 00005CFC 44656C657465204578- db "Delete Extended (DOS) Partition:" 12373 00005D05 74656E646564202844- 12373 00005D0E 4F5329205061727469- 12373 00005D17 74696F6E3A 12374 00005D1C 0D0A db 0Dh, 0Ah 12375 00005D1E 507265737320454E54- db "Press ENTER to delete or press ESC to cancel.." 12375 00005D27 455220746F2064656C- 12375 00005D30 657465206F72207072- 12375 00005D39 657373204553432074- 12375 00005D42 6F2063616E63656C2E- 12375 00005D4B 2E 12376 00005D4C 0D0A00 db 0Dh, 0Ah, 0 12377 12378 str_display_ebr_pt: 12379 00005D4F 285072657373205350- db "(Press SPACE to edit EXTENDED Partition Table)", 0Dh, 0Ah, 0 12379 00005D58 41434520746F206564- 12379 00005D61 697420455854454E44- 12379 00005D6A 454420506172746974- 12379 00005D73 696F6E205461626C65- 12379 00005D7C 290D0A00 12380 12381 ebr_editing_options: 12382 00005D80 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12383 00005D84 457874656E64656420- db "Extended Partition Table Editing Options:" 12383 00005D8D 506172746974696F6E- 12383 00005D96 205461626C65204564- 12383 00005D9F 6974696E67204F7074- 12383 00005DA8 696F6E733A 12384 00005DAD 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 12385 00005DB1 20202020202020312E- db " 1. Create Logical DOS Drive", 0Dh, 0Ah 12385 00005DBA 20437265617465204C- 12385 00005DC3 6F676963616C20444F- 12385 00005DCC 532044726976650D0A 12386 00005DD5 20202020202020322E- db " 2. Delete Logical (DOS) Drive(s)",0Dh, 0Ah, 0 12386 00005DDE 2044656C657465204C- 12386 00005DE7 6F676963616C202844- 12386 00005DF0 4F5329204472697665- 12386 00005DF9 2873290D0A00 12387 12388 msg_delete_ldd_q: 12389 00005DFF 0D0A db 0Dh, 0Ah 12390 00005E01 5741524E494E47210D- db "WARNING!", 0Dh, 0Ah 12390 00005E0A 0A 12391 00005E0B 416C6C206F66206461- db "All of data in logical (DOS) drive(s) will be lost !!", 0Dh, 0Ah 12391 00005E14 746120696E206C6F67- 12391 00005E1D 6963616C2028444F53- 12391 00005E26 292064726976652873- 12391 00005E2F 292077696C6C206265- 12391 00005E38 206C6F73742021210D- 12391 00005E41 0A 12392 00005E42 0D0A db 0Dh, 0Ah 12393 00005E44 446F20796F75207761- db "Do you want to continue ? (Y/N) ", 0 12393 00005E4D 6E7420746F20636F6E- 12393 00005E56 74696E7565203F2028- 12393 00005E5F 592F4E292000 12394 12395 msg_create_ldd_max_error: 12396 00005E65 0D0A db 0Dh, 0Ah 12397 00005E67 50726F6772616D206C- db "Program limit for logical dos drive count is 4 !" 12397 00005E70 696D697420666F7220- 12397 00005E79 6C6F676963616C2064- 12397 00005E82 6F7320647269766520- 12397 00005E8B 636F756E7420697320- 12397 00005E94 342021 12398 00005E97 0D0A00 db 0Dh, 0Ah, 0 12399 12400 msg_c_ldd_unused_warning: 12401 00005E9A 0D0A db 0Dh, 0Ah 12402 00005E9C 546865726520697320- db "There is unused extended partition space after logical dos drive " 12402 00005EA5 756E75736564206578- 12402 00005EAE 74656E646564207061- 12402 00005EB7 72746974696F6E2073- 12402 00005EC0 706163652061667465- 12402 00005EC9 72206C6F676963616C- 12402 00005ED2 20646F732064726976- 12402 00005EDB 6520 12403 char_lddn: 12404 00005EDD 342021 db "4 !" 12405 00005EE0 0D0A db 0Dh, 0Ah 12406 00005EE2 285072657373204553- db "(Press ESC to add unused space or press ENTER to continue.)" 12406 00005EEB 4320746F2061646420- 12406 00005EF4 756E75736564207370- 12406 00005EFD 616365206F72207072- 12406 00005F06 65737320454E544552- 12406 00005F0F 20746F20636F6E7469- 12406 00005F18 6E75652E29 12407 00005F1D 0D0A00 db 0Dh, 0Ah, 0 12408 12409 msg_create_ldd_s: 12410 00005F20 53656C65637420616E- db "Select an option to set logical dos drive size: " 12410 00005F29 206F7074696F6E2074- 12410 00005F32 6F20736574206C6F67- 12410 00005F3B 6963616C20646F7320- 12410 00005F44 64726976652073697A- 12410 00005F4D 653A20 12411 00005F50 0D0A db 0Dh, 0Ah 12412 00005F52 0D0A db 0Dh, 0Ah 12413 00005F54 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 12413 00005F5D 6E64657220636F756E- 12413 00005F66 740D0A 12414 00005F69 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 12414 00005F72 6D652070657263656E- 12414 00005F7B 746167652028232325- 12414 00005F84 290D0A 12415 00005F87 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 12415 00005F90 20627974657320284D- 12415 00005F99 422C20322A31303234- 12415 00005FA2 2A4D20736563746F72- 12415 00005FAB 73290D0A 12416 00005FAF 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 12416 00005FB8 206279746573202847- 12416 00005FC1 422C20322A31303234- 12416 00005FCA 2A313032342A472073- 12416 00005FD3 6563746F7273290D0A 12417 00005FDC 0D0A db 0Dh, 0Ah 12418 00005FDE 507265737320535041- db "Press SPACE to use entire space or press ENTER to set Megabytes .. ", 0 12418 00005FE7 434520746F20757365- 12418 00005FF0 20656E746972652073- 12418 00005FF9 70616365206F722070- 12418 00006002 7265737320454E5445- 12418 0000600B 5220746F2073657420- 12418 00006014 4D6567616279746573- 12418 0000601D 202E2E2000 12419 12420 msg_c_part_error: 12421 00006022 0D0A db 0Dh, 0Ah 12422 ;db "No free space for a new primary partition", 0Dh, 0Ah, 0 12423 ; 21/03/2021 12424 00006024 4E6F20667265652073- db "No free space for a new primary partition !", 0Dh, 0Ah, 0 12424 0000602D 7061636520666F7220- 12424 00006036 61206E657720707269- 12424 0000603F 6D6172792070617274- 12424 00006048 6974696F6E20210D0A- 12424 00006051 00 12425 12426 ; 21/03/2021 12427 ;msg_c_ldd_error: 12428 ; db "and logical dos drives over program limit (4) !", 0Dh, 0Ah, 0 12429 12430 msg_c_ldd_q: 12431 00006052 0D0A db 0Dh, 0Ah 12432 00006054 446F20796F75207761- db "Do you want to create logical dos drive in extended dos partition " 12432 0000605D 6E7420746F20637265- 12432 00006066 617465206C6F676963- 12432 0000606F 616C20646F73206472- 12432 00006078 69766520696E206578- 12432 00006081 74656E64656420646F- 12432 0000608A 732070617274697469- 12432 00006093 6F6E20 12433 00006096 3F2028592F4E2900 db '? (Y/N)', 0 12434 12435 msg_c_ldd_nofspc_error: 12436 0000609E 0D0A db 0Dh, 0Ah 12437 000060A0 4E6F20667265652073- db "No free space for a new logical dos drive !", 0Dh, 0Ah, 0 12437 000060A9 7061636520666F7220- 12437 000060B2 61206E6577206C6F67- 12437 000060BB 6963616C20646F7320- 12437 000060C4 647269766520210D0A- 12437 000060CD 00 12438 12439 ; 12/10/2020 12440 msg_drv_not_ready: 12441 000060CE 0D0A db 0Dh, 0Ah 12442 000060D0 4469736B2064726976- db "Disk drive not ready or read error ! " 12442 000060D9 65206E6F7420726561- 12442 000060E2 6479206F7220726561- 12442 000060EB 64206572726F722021- 12442 000060F4 20 12443 000060F5 0D0A00 db 0Dh, 0Ah, 0 12444 12445 msg_not_any_disks: 12446 000060F8 0D0A db 0Dh, 0Ah 12447 000060FA 546865726520697320- db "There is not a hard disk (ready) ! " 12447 00006103 6E6F74206120686172- 12447 0000610C 64206469736B202872- 12447 00006115 6561647929202120 12448 0000611D 0D0A00 db 0Dh, 0Ah, 0 12449 12450 align 4 12451 12452 msg_sectors_crlf: 12453 00006120 20736563746F72 db " sector" 12454 msg_sectors_crlf_s: 12455 00006127 73 db "s" 12456 00006128 0D0A00 db 0Dh, 0Ah, 0 12457 12458 vname_length: 12459 0000612B 00 db 0 ; 05/01/2018 12460 12461 bs_oem_name: 12462 ;db 'TRDOS2.0', 0 12463 ; 04/05/2024 12464 0000612C 524554524F444F5300 db 'RETRODOS', 0 12465 00006135 90 align 2 12466 12467 no_name: 12468 00006136 4E4F204E414D452020- db 'NO NAME ', 0 12468 0000613F 202000 12469 12470 align 2 12471 12472 FDFORMAT_SECBUFFER: 12473 HDFORMAT_SECBUFFER: 12474 00006142 F6 times 512 db 0F6h 12475 HDFORMAT_FSINFO_BUFF: 12476 00006342 52526141 dd 41615252h ; FSI_LeadSig 12477 00006346 00 times 480 db 0 ; FSI_Reserved1 12478 00006526 72724161 dd 61417272h ; FSI_StrucSig 12479 0000652A FFFFFFFF dd 0FFFFFFFFh ; FSI_Free_Count 12480 0000652E 02000000 dd 000000002h ; FSI_Nxt_Free 12481 00006532 00 times 12 db 0 ; FSI_Reserved2 12482 0000653E 000055AA dd 0AA550000h ; FSI_TrailSig 12483 12484 ; 29/10/2020 12485 msg_100: 12486 00006542 31303000 db '100', 0 12487 12488 SizeOfFile equ $-100 12489 12490 ; 03/02/2019 12491 12492 ;============================================================================= 12493 ; uninitialized data 12494 ;============================================================================= 12495 12496 bss_start: 12497 12498 ABSOLUTE bss_start 12499 12500 ; 12/10/2020 12501 00006546 ?? DrvNum: resb 1 12502 00006547 ?? hdc: resb 1 12503 ;hs: resw 1 ; (bios/dos virtual) head*sectors ; 16/10/2020 12504 00006548 ?? rw: resb 1 12505 00006549 ?? rcnt: resb 1 ; 18/10/2020 12506 total_sectors: 12507 0000654A ???????? disksize: resd 1 12508 0000654E ???????? chs_limit: resd 1 12509 12510 ; 16/10/2020 12511 ;lba_cyls: resd 1 ; cylinder count calculated from LBA sectors 12512 00006552 ???? lba_chs_remain: resw 1 ; remain sectors after the last cylinder 12513 12514 alignb 2 12515 00006554 ???? old_sp: resw 1 12516 12517 HDFORMAT_FATBUFFER: 12518 HDFORMAT_EMPTY_BUFF: 12519 00006556 resb 512 12520 12521 00006756 ???????? data_start: resd 1 12522 0000675A ???????? data_sectors: resd 1 12523 0000675E ???????? cluster_count: resd 1 12524 00006762 ???? root_dir_secs: resw 1 12525 format_percent: ;resw 1 12526 00006764 ???????? resd 1 ; 16/03/2021 12527 00006768 ?? prev_percent: resb 1 12528 00006769 ?? rsvdbyte: resb 1 12529 12530 0000676A ???? alignb 4 12531 12532 ; 05/01/2018 12533 0000676C fs_volume_name: resb 64 12534 000067AC ???????? fs_volume_serial: resd 1 12535 000067B0 ???? DAT_FFBit: resw 1 12536 000067B2 ???? DAT_FFSector: resw 1 12537 ;resw 1 12538 000067B4 ???? DAT_LFBit: resw 1 12539 000067B6 ???? DAT_LFSector: resw 1 12540 ;resw 1 12541 12542 ;alignb 4 12543 12544 FS_MAT_Buffer: ; TRFS1 Master Allocation Table (05/01/2018) 12545 000067B8 ?????? MAT_Sign: resb 3 ; Offset 0 ; 'MAT' 12546 000067BB ?? MAT_Version: resb 1 ; 3 ; 0 12547 000067BC ???????? MAT_VolumeSize: resd 1 ; 4 ; FS1 Volume Size 12548 000067C0 ???????? MAT_BeginSector: resd 1 ; 8 ; FS1 Start Sector 12549 000067C4 ???????? DAT_Address: resd 1 ; 12 ; Offset (=2) 12550 000067C8 ???????? DAT_SectorCount: resd 1 ; 16 12551 000067CC ???????? MAT_FreeSectors: resd 1 ; 20 12552 000067D0 ???????? MAT_FirstFreeSector: resd 1 ; 24 12553 ;MAT_OS_Reserved: 12554 ; resb 9 12555 ;MAT_Unused: 12556 ; resb 112 12557 FS_DAT_Buffer: ; TRFS1 Disk Allocation Table (05/01/2018) 12558 FS_RDT_Buffer: ; TRFS1 Root Directory Description Table (05/01/2018) 12559 000067D4 resb 512 12560 ;alignb 4 12561 12562 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 12563 12564 ;total_sectors: resd 1 12565 000069D4 ???????? pType: resb 4 12566 000069D8 ???????? file_size: resd 1 12567 000069DC ???????? pp_StartSector: resd 1 12568 000069E0 ???????? pp_Sectors: resd 1 12569 000069E4 ?? wholedisk: resb 1 12570 000069E5 ?? pp_type: resb 1 ; Primary partition type (for this program) 12571 000069E6 ?? pp_type_user: resb 1 12572 000069E7 ?? chs_focus: resb 1 12573 000069E8 ???????? pSize_temp: resd 1 12574 000069EC ???????? pSize_multiplier: resd 1 12575 000069F0 ?? pSize_maxdigits: resb 1 12576 000069F1 ?? pSize_digitpos: resb 1 12577 msg_psize_unit: 12578 000069F2 ???? pSize_unit: resw 1 12579 000069F4 ?? resb 1 12580 ; 06/11/2020 12581 ;reserved_bytes: resb 3 ; for 11 bytes of numbers 12582 msg_partition_sectors: 12583 ;resb 8 12584 000069F5 resb 11 ; 06/11/2020 12585 00006A00 ?? resb 1 12586 00006A01 ?? format_q: resb 1 ; 03/02/2018 12587 12588 ;alignb 2 12589 00006A02 ?? pType_pos: resb 1 12590 00006A03 ?? pType_num: resb 1 12591 00006A04 ?? resb 1 12592 ;cylinder_boundary: 12593 00006A05 ?? resb 1 12594 ; 05/11/2020 12595 12596 alignb 2 12597 12598 00006A06 ?? GetChar: resb 1 ; 11/02/2019 12599 00006A07 ?? resb 1 ; 06/11/2020 12600 12601 hs: ; 17/10/2020 ; (bios/dos virtual) head*sectors 12602 00006A08 ???? min_sectors: resw 1 ; 08/02/2019 12603 00006A0A ???? resw 1 ; 06/11/2020 12604 00006A0C ???? pp_StartCylinder: resw 1 12605 00006A0E ???? resw 1 ; 06/11/2020 12606 00006A10 ???? pp_EndCylinder: resw 1 12607 00006A12 ???? resw 1 ; 06/11/2020 12608 12609 00006A14 ???????? ppn_Sectors: resd 1 ; 09/02/2019 12610 12611 00006A18 ???? input_col: resw 1 12612 00006A1A ?? No: resb 1 12613 00006A1B ?? Yes: resb 1 12614 12615 ; 26/02/2019 12616 00006A1C ?? ldrives: resb 1 12617 12618 ;sort_1: resb 1 12619 00006A1D ?? resb 1 ; 23/10/2020 12620 00006A1E ???????? sort: resb 4 12621 12622 ;max_sector: resb 8 12623 ebr_buffer: ; 26/02/2019 12624 00006A22 boot_record: resb 512 12625 12626 00006C22 ?? valid_input: resb 1 12627 00006C23 ?? resb 1 12628 12629 ; 26/02/2019 12630 00006C24 ???????? ep_StartSector: resd 1 12631 00006C28 ???????? ep_EndSector: resd 1 12632 00006C2C ???????? ep_Size: resd 1 12633 12634 ; 10/02/2019 12635 00006C30 ???????? valid_ppnums: resb 4 12636 12637 00006C34 ???? _i_: resw 1 12638 12639 freespace_count: ; resw 1 12640 00006C36 ?? resb 1 ; 12/03/2021 12641 12642 00006C37 ?? last_found_partition: resb 1 12643 00006C38 ?? p_type: resb 1 12644 12645 ; 30/10/2020 12646 ;p_sorted: 12647 ; resb 1 12648 ;ep_sorted: 12649 ; resb 1 12650 12651 00006C39 ?? _e_: resb 1 12652 12653 act_part_num: 12654 cre_part_num: 12655 00006C3A ?? del_part_num: resb 1 ; 10/02/2019 12656 12657 00006C3B ?? alignb 2 12658 12659 00006C3C pte_row: resb 80 12660 12661 00006C8C ?? _zero_: resb 1 12662 12663 ;alignb 2 12664 12665 00006C8D ?? resb 1 12666 12667 bss_clear_end: ; 15/02/2019 12668 12669 ; 05/11/2020 12670 12671 ; PARTITION DATA STRUCTURE 12672 ; 4 partitions 12673 ; 22 byte partition data structure per partition 12674 ; 88 bytes (4*22) 12675 12676 00006C8E ?? part_table_boot_ind: resb 1 12677 00006C8F ?? part_table_start_head: resb 1 12678 00006C90 ?? part_table_start_sector: resb 1 12679 ;part_table_start_cyl: resw 1 12680 00006C91 ???????? part_table_start_cyl: resd 1 12681 00006C95 ?? part_table_sys_id: resb 1 12682 00006C96 ?? part_table_end_head: resb 1 12683 00006C97 ?? part_table_end_sector: resb 1 12684 ;part_table_end_cyl: resw 1 12685 00006C98 ???????? part_table_end_cyl: resd 1 12686 ;part_table_rel_sec_lw: resw 1 12687 ;part_table_rel_sec_hw: resw 1 12688 00006C9C ???????? part_table_rel_sec: resd 1 12689 ;part_table_num_sec_lw: resw 1 12690 ;part_table_num_sec_hw: resw 1 12691 00006CA0 ???????? part_table_num_sec: resd 1 12692 12693 00006CA4 resb 66 ; 3*22 bytes 12694 12695 00006CE6 ?? pcount: resb 1 12696 00006CE7 ?? ppcount: resb 1 12697 00006CE8 ?? apcount: resb 1 12698 00006CE9 ?? epnumber: resb 1 12699 12700 ; 05/11/2020 12701 12702 ; LOGICAL PARTITION DATA STRUCTURE 12703 ; (for logical partitions in extended partition) 12704 12705 ; 1 extended partition 12706 ; 4 logical drives (22 bytes) 12707 ; 88 bytes (4*22) 12708 12709 00006CEA ?? ext_table_boot_ind: resb 1 12710 00006CEB ?? ext_table_start_head: resb 1 12711 00006CEC ?? ext_table_start_sector: resb 1 12712 ;ext_table_start_cyl: resw 1 12713 00006CED ???????? ext_table_start_cyl: resd 1 12714 00006CF1 ?? ext_table_sys_id: resb 1 12715 00006CF2 ?? ext_table_end_head: resb 1 12716 00006CF3 ?? ext_table_end_sector: resb 1 12717 ;ext_table_end_cyl: resw 1 12718 00006CF4 ???????? ext_table_end_cyl: resd 1 12719 ;ext_table_rel_sec_lw: resw 1 12720 ;ext_table_rel_sec_hw: resw 1 12721 00006CF8 ???????? ext_table_rel_sec: resd 1 12722 ;ext_table_num_sec_lw: resw 1 12723 ;ext_table_num_sec_hw: resw 1 12724 00006CFC ???????? ext_table_num_sec: resd 1 12725 12726 00006D00 resb 66 ; 3*22 bytes 12727 ; 05/11/2020 12728 12729 fspc: ; 5*11 words (for free space calculations) 12730 12731 ; Space 1 - unused cylinders before partition 0 12732 ; Space 2 - unused cylinders between partition 0 & 1 12733 ; Space 3 - unused cylinders between partition 1 & 2 12734 ; Space 4 - unused cylinders between partition 2 & 3 12735 ; Space 5 - unused cylinders after partition 3 12736 12737 00006D42 ???????? free_space.space: resd 1 12738 00006D46 ???????? free_space.start: resd 1 12739 00006D4A ???????? free_space.end: resd 1 12740 00006D4E ???????? free_space.sectors_unused: resd 1 12741 00006D52 ???????? free_space.startsector: resd 1 ; 13/02/2019 12742 00006D56 ???? free_space.percent_unused: resw 1 12743 12744 00006D58 resw 4*11 ; 4*22 bytes ; 05/11/2020 12745 12746 ; 05/11/2020 12747 ;c_cylinder: resd 1 12748 ; 18/02/2019 12749 ;c_cylinder: resw 1 12750 00006DB0 ???? c_fspc_offset: resw 1 12751 00006DB2 ?? cylinder_boundary: resb 1 12752 ;c_gap: resb 1 12753 00006DB3 ?? resb 1 12754 12755 ; 27/02/2019 12756 00006DB4 ldd_start: resd 4 12757 ; 03/03/2019 12758 00006DC4 ldd_size: resd 4 12759 ; 30/10/2020 12760 00006DD4 ???????? ep_free_sectors: resd 1 12761 12762 ; 05/11/2020 12763 00006DD8 ???????? lcylinders: resd 1 12764 ; 25/02/2019 12765 00006DDC ???? pte_address: resw 1 12766 ; 02/03/2019 12767 ;lcylinders: resw 1 12768 ; 01/11/2020 12769 00006DDE ???? endcyl: resw 1 12770 00006DE0 ???? resw 1 ; 13/03/2021 12771 12772 ;bss_clear_end: ; 18/02/2019 12773 12774 ; 11/10/2020 12775 ;gdp_buffer: resb 30 ; buffer for int 13h, ah = 48h 12776 00006DE2 gdp_buffer: resb 26 ; buffer for int 13h, ah = 48h 12777 12778 bss_end: