1 ; **************************************************************************** 2 ; FDISK3R5.ASM (FDISK3R5.COM) - Retro DOS v5 Hard Disk Partitioning Utility 3 ; fdisk3.s (for MSDOS/WINDOWS) 4 ; **************************************************************************** 5 ; Last Update: 29/01/2026 6 ; ---------------------------------------------------------------------------- 7 ; Beginning: 11/10/2020 8 ; ---------------------------------------------------------------------------- 9 ; Assembler: NASM version 2.15 10 ; ---------------------------------------------------------------------------- 11 ; Modified from 'FDISK3.ASM' (FDISK3.COM) source code by Erdogan Tan 12 ; (04/05/2024) - TRDOS 386 v2 fixed disk partitioning utility - 13 ; **************************************************************************** 14 ; nasm fdisk3r5.s -l fdisk3r5.txt -o FDISK3R5.COM -Z error.txt 15 16 ; Masterboot / Partition Table at Beginning+1BEh 17 ptBootable equ 0 18 ptBeginHead equ 1 19 ptBeginSector equ 2 20 ptBeginCylinder equ 3 21 ptFileSystemID equ 4 22 ptEndHead equ 5 23 ptEndSector equ 6 24 ptEndCylinder equ 7 25 ptStartSector equ 8 26 ptSectors equ 12 27 28 ; BIOS Disk Parameters 29 DPDiskNumber equ 0h 30 DPDType equ 1h 31 DPReturn equ 2h 32 DPHeads equ 3h 33 DPCylinders equ 4h 34 DPSecPerTrack equ 6h 35 DPDisks equ 7h 36 DPTableOff equ 8h 37 DPTableSeg equ 0Ah 38 DPNumOfSecs equ 0Ch 39 40 ; BIOS INT 13h Extensions (LBA extensions) 41 ; Just After DP Data (DPDiskNumber+) 42 DAP_PacketSize equ 10h ; If extensions present, this byte will be >=10h 43 DAP_Reserved1 equ 11h ; Reserved Byte 44 DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127 45 DAP_Reserved2 equ 13h ; Reserved Byte 46 DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET 47 DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1 48 ; C1= Selected Cylinder Number 49 ; H0= Number Of Heads (Maximum Head Number + 1) 50 ; H1= Selected Head Number 51 ; S0= Maximum Sector Number 52 ; S1= Selected Sector Number 53 ; QUAD WORD 54 ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh 55 ; QUAD WORD (Also, value in 0h must be 18h) 56 ; TR-DOS will not use 64 bit Flat Address 57 58 ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters" 59 ; Just After DP Data (DPDiskNumber+) 60 GetDParams_48h equ 20h ; Word. Data Lenght, must be 26 (1Ah) for short data. 61 GDP_48h_InfoFlag equ 22h ; Word 62 ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid. 63 GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders. 64 GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads. 65 GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track. 66 GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors. 67 GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector. 68 69 pTableOffset equ 1BEh ; 446 70 71 ; Convert LBA to CHS 72 ; 08/02/2019 73 74 ; LBA = ((C1*H0+H1)*S0)+S1-1 75 ; 76 ; C1 = Selected Cylinder Number 77 ; H0 = Number of Heads (Maximum Head Number + 1) 78 ; H1 = Selected Head Number 79 ; S0 = Maximum Sector Number 80 ; S1 = Selected Sector Number 81 ; 82 ; Phoenix, Enchanced Disk Drive Specicifications, v1.1, Page 8) 83 84 85 [BITS 16] 86 [ORG 100h] 87 88 ;cli 89 ;cld 90 ;push cs 91 ;pop ss 92 ;mov sp, 0FFFEh 93 ;sti 94 95 ;mov bx, SizeOfFile+100 96 97 00000000 BB[CC70] mov bx, bss_end 98 99 00000003 83C30F add bx, 15 100 00000006 D1EB shr bx, 1 101 00000008 D1EB shr bx, 1 102 0000000A D1EB shr bx, 1 103 0000000C D1EB shr bx, 1 104 0000000E B44A mov ah, 4Ah ; modify memory allocation 105 ;push cs 106 ;pop es 107 00000010 CD21 int 21h 108 109 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 110 ; clear BSS 111 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 112 ; 03/02/2019 113 114 ;mov cx, bss_end 115 00000012 B9[9C6F] mov cx, bss_clear_end ; 15/02/2019 116 117 00000015 BF[5A68] mov di, bss_start 118 00000018 29F9 sub cx, di 119 0000001A 41 inc cx 120 0000001B D1E9 shr cx, 1 121 0000001D 31C0 xor ax, ax 122 0000001F F3AB rep stosw 123 124 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 125 ; display program name & version 126 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 127 128 00000021 BE[8A43] mov si, TrDOS_Welcome 129 00000024 E8731B call print_msg 130 131 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 132 ; get hard disk name 133 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 134 ; 11/10/2020 135 136 00000027 BE8000 mov si, 80h ; PSP command tail 137 0000002A AC lodsb 138 0000002B 08C0 or al, al ; command tail length 139 0000002D 7431 jz short A_05 ; jump if zero 140 A_01: 141 0000002F AC lodsb 142 00000030 3C20 cmp al, ' ' ; is it SPACE ? 143 00000032 74FB je short A_01 144 00000034 722A jb short A_05 145 146 ; check disk name 147 148 00000036 3C68 cmp al, 'h' 149 00000038 751B jne short A_03 150 0000003A 803C64 cmp byte [si], 'd' 151 0000003D 7516 jne short A_03 152 0000003F 46 inc si 153 00000040 AC lodsb 154 00000041 3C30 cmp al, '0' 155 00000043 7406 je short A_02 156 00000045 720E jb short A_03 157 00000047 3C33 cmp al, '3' 158 00000049 770A ja short A_03 159 A_02: 160 0000004B 803C20 cmp byte [si], ' ' 161 0000004E 720B jb short A_04 162 00000050 7703 ja short A_03 163 00000052 46 inc si 164 00000053 EBF6 jmp short A_02 165 A_03: 166 00000055 BE[EB43] mov si, TrDOS_Usage 167 00000058 E94F07 jmp _p_exit 168 A_04: 169 0000005B 0450 add al, 80h - '0' 170 0000005D A2[5A68] mov [DrvNum], al ; 80h .. 83h 171 172 A_05: 173 174 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 175 ; get hard disk parameters 176 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 177 ; 11/10/2020 178 179 ; check bios int 13h extensions 180 00000060 B441 mov ah, 41h 181 00000062 BBAA55 mov bx, 55AAh 182 00000065 B280 mov dl, 80h 183 00000067 CD13 int 13h 184 00000069 720B jc short A_06 185 0000006B 81FB55AA cmp bx, 0AA55h 186 0000006F 7505 jne short A_06 187 188 00000071 C606[7231]01 mov byte [int13h_x], 1 189 A_06: 190 ;mov dl, 80h ; hd0 191 00000076 B408 mov ah, 08h ; return disk parameters 192 00000078 CD13 int 13h 193 0000007A 7313 jnc short A_10 194 A_07: 195 0000007C 803E[5A68]80 cmp byte [DrvNum], 80h ; hard disk name option ? 196 00000081 7206 jb short A_09 ; no, default 197 A_08: 198 00000083 BE[E063] mov si, msg_drv_not_ready ; drive not ready 199 00000086 E92107 jmp _p_exit 200 A_09: 201 00000089 BE[0A64] mov si, msg_not_any_disks ; there is not a hard disk 202 0000008C E91B07 jmp _p_exit 203 A_10: 204 0000008F 08E4 or ah, ah ; ah = 0 ? 205 00000091 75E9 jnz short A_07 ; no, there is an error ! 206 207 00000093 8816[5B68] mov [hdc], dl ; number of hard disks 208 209 00000097 A0[5A68] mov al, [DrvNum] 210 211 0000009A 3C80 cmp al, 80h 212 0000009C 7308 jnb short A_11 ; option 213 ; default 214 0000009E C606[5A68]80 mov byte [DrvNum], 80h 215 000000A3 E98F00 jmp A_14 216 A_11: 217 ; hard disk name option 218 000000A6 80C27F add dl, 7Fh 219 220 000000A9 38D0 cmp al, dl 221 000000AB 77D6 ja short A_08 222 223 000000AD 80FA80 cmp dl, 80h 224 000000B0 760C jna short A_13 ; hd0 parameters are ready 225 A_12: 226 000000B2 88C2 mov dl, al ; [DrvNum] 227 228 000000B4 B408 mov ah, 08h ; return (get) disk parameters 229 000000B6 CD13 int 13h 230 000000B8 72C2 jc short A_07 231 000000BA 08E4 or ah, ah 232 000000BC 75BE jnz short A_07 233 A_13: 234 000000BE 88C8 mov al, cl 235 000000C0 243F and al, 3Fh ; 63 236 000000C2 C0E906 shr cl, 6 237 000000C5 86E9 xchg ch, cl 238 000000C7 41 inc cx 239 000000C8 41 inc cx ; 15/10/2020 ; BIOS BugFix 240 ; (for reserved last cylinder) 241 000000C9 890E[8A3F] mov [cylinders], cx 242 ;mov word [cylinders+2], 0 ; 16/10/2020 243 000000CD FEC6 inc dh 244 000000CF 8836[883F] mov [heads], dh 245 000000D3 A2[863F] mov [sectors], al 246 000000D6 F6E6 mul dh 247 000000D8 A3[1C6D] mov [hs], ax ; heads*sectors ; 15/10/2020 248 000000DB F7E1 mul cx 249 000000DD A3[5E68] mov [disksize], ax 250 000000E0 8916[6068] mov [disksize+2], dx 251 000000E4 83E801 sub ax, 1 ; 17/10/2020 252 000000E7 83DA00 sbb dx, 0 253 000000EA A3[6268] mov [chs_limit], ax 254 000000ED 8916[6468] mov [chs_limit+2], dx 255 256 000000F1 803E[7231]01 cmp byte [int13h_x], 1 257 000000F6 0F82D700 jb A_20 258 259 000000FA BE[B070] mov si, gdp_buffer 260 ;mov word [si], 30 ; buffer length (minimum) 261 000000FD C7041A00 mov word [si], 26 ; buffer length (minimum) 262 00000101 B448 mov ah, 48h 263 00000103 8A16[5A68] mov dl, [DrvNum] 264 00000107 CD13 int 13h 265 00000109 0F82C400 jc A_20 266 0000010D 20E4 and ah, ah 267 0000010F 0F85BE00 jnz A_20 268 269 ; number of physical sectors 270 00000113 8B4410 mov ax, [si+16] 271 00000116 8B5412 mov dx, [si+18] 272 00000119 A3[5E68] mov [disksize], ax 273 0000011C 8916[6068] mov [disksize+2], dx 274 275 ; 15/10/2020 276 00000120 8B0E[1C6D] mov cx, [hs] 277 00000124 E8560B call div32 278 ; 16/10/2020 279 ;mov [lba_cyls], ax 280 ;mov [lba_cyls+2], dx 281 00000127 A3[8A3F] mov [cylinders], ax 282 0000012A 8916[8C3F] mov [cylinders+2], dx 283 0000012E 891E[6668] mov [lba_chs_remain], bx 284 285 00000132 E99C00 jmp A_20 286 A_14: 287 00000135 80FA01 cmp dl, 1 288 00000138 7684 jna short A_13 ; [DrvNum] = 80h 289 290 0000013A 80C230 add dl, '0' ; '2' to '4' 291 0000013D 8816[B044] mov byte [TrDOS_dnmax], dl 292 293 00000141 BE[9244] mov si, TrDOS_Options 294 00000144 E8531A call print_msg 295 296 ; check bios int 13h extensions 297 00000147 803E[7231]01 cmp byte [int13h_x], 1 298 0000014C 732D jnb short A_16 299 A_15: 300 0000014E 8A16[5A68] mov dl, [DrvNum] 301 00000152 B408 mov ah, 08h ; return disk parameters 302 00000154 CD13 int 13h 303 00000156 724D jc short A_17 304 00000158 08E4 or ah, ah 305 0000015A 7549 jnz short A_17 306 307 0000015C 88C8 mov al, cl 308 0000015E 243F and al, 3Fh ; 63 309 00000160 C0E906 shr cl, 6 310 00000163 86E9 xchg ch, cl 311 00000165 41 inc cx 312 00000166 FEC6 inc dh 313 00000168 F6E6 mul dh 314 0000016A F7E1 mul cx 315 316 ; dx:ax = disk size 317 318 0000016C E89D02 call display_hd_row 319 320 0000016F FE0E[5B68] dec byte [hdc] 321 00000173 7430 jz short A_17 322 00000175 FE06[5A68] inc byte [DrvNum] 323 00000179 EBD3 jmp short A_15 324 A_16: 325 0000017B BE[B070] mov si, gdp_buffer 326 ;mov word [si], 30 ; buffer length (minimum) 327 0000017E C7041A00 mov word [si], 26 ; buffer length (minimum) 328 00000182 B448 mov ah, 48h 329 00000184 8A16[5A68] mov dl, [DrvNum] 330 00000188 CD13 int 13h 331 0000018A 72C2 jc short A_15 332 0000018C 20E4 and ah, ah 333 0000018E 75BE jnz short A_15 334 335 ; number of phsical sectors 336 00000190 8B4410 mov ax, [si+16] 337 00000193 8B5412 mov dx, [si+18] 338 339 ; dx:ax = disk size 340 341 00000196 E87302 call display_hd_row 342 343 00000199 FE0E[5B68] dec byte [hdc] 344 0000019D 7406 jz short A_17 345 0000019F FE06[5A68] inc byte [DrvNum] 346 000001A3 EBD6 jmp short A_16 347 A_17: 348 000001A5 BE[8755] mov si, CRLF 349 000001A8 E8EF19 call print_msg 350 351 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 352 ; hard disk number input (getchar) 353 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 354 ; 11/10/2020 355 356 A_18: 357 000001AB 31C0 xor ax, ax 358 000001AD CD16 int 16h ; wait for keyboard command 359 360 000001AF 83F800 cmp ax, 0 ; CTRL+BREAK 361 000001B2 761A jna short A_19 362 363 000001B4 3C03 cmp al, 'C'-40h ; 3 364 000001B6 7416 je short A_19 ; CTRL+C 365 000001B8 3C1B cmp al, 27 ; ESCape 366 000001BA 7412 je short A_19 367 368 000001BC 3C31 cmp al, '1' ; "(1) hd0" 369 000001BE 72EB jb short A_18 ; retry 370 000001C0 3A06[B044] cmp al, [TrDOS_dnmax] ; ('2' to '4') 371 000001C4 77E5 ja short A_18 ; retry 372 000001C6 044F add al, 80h-'1' ; bios disk num (80h-83h) 373 000001C8 A2[5A68] mov [DrvNum], al 374 000001CB E9E4FE jmp A_12 ; get disk parameters 375 A_19: 376 000001CE E9DC05 jmp _exit ; Exit 377 378 A_20: 379 380 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 381 ; read masterboot sector 382 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 383 ; 12/10/2020 384 385 000001D1 BB[0256] mov bx, MasterBootBuff 386 000001D4 B90100 mov cx, 1 ; cylinder = 0 387 ; sector = 1 388 000001D7 B600 mov dh, 0 ; head = 0 389 000001D9 8A16[5A68] mov dl, [DrvNum] 390 000001DD B80102 mov ax, 0201h ; read one sector 391 000001E0 CD13 int 13h 392 000001E2 7306 jnc short A_21 393 394 000001E4 BE[E063] mov si, msg_drv_not_ready ; drive not ready 395 000001E7 E98700 jmp A_26 396 A_21: 397 398 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 399 ; display CHS values and disk size (LBA) and partition table 400 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 401 ; 12/10/2020 402 403 000001EA B80300 mov ax, 3 ; clear screen 404 000001ED CD10 int 10h 405 406 000001EF E81B21 call init_partition_table ; 13/10/2020 407 408 000001F2 E8241B call display_chs_table 409 410 000001F5 A1[5E68] mov ax, [disksize] 411 000001F8 8B16[6068] mov dx, [disksize+2] 412 413 000001FC 81FA0001 cmp dx, 256 ; >= 8GB 414 00000200 7315 jnb short A_22 415 416 ;mov cx, 2048 ; /2048 (2048 sectors = 1 MB) 417 ;div cx 418 419 ; shift dx:ax to 8 bits right (/256) 420 00000202 88E0 mov al, ah 421 00000204 88D4 mov ah, dl 422 00000206 C1E803 shr ax, 3 ; /8 423 ; result = (dx:ax)/2048 424 425 ; ax = 0 to 8191 426 427 00000209 C606[E644]4D mov byte [TrDOS_hdrow_unit], 'M' 428 0000020E EB11 jmp short A_23 429 430 431 A_29: ; 16/10/2020 432 00000210 E8A627 call partition_table_fix 433 00000213 73D5 jnc short A_21 434 435 00000215 CD20 int 20h 436 ;here: 437 ;jmp short here 438 439 A_22: 440 ; 1024 MB = 1GB (2097152 sectors) 441 ; DX/32 --> GB 442 00000217 89D0 mov ax, dx 443 00000219 C1E805 shr ax, 5 ; /32 444 445 ; ax = 8 to 2047 446 0000021C C606[E644]47 mov byte [TrDOS_hdrow_unit], 'G' 447 A_23: 448 ;xor dx, dx 449 00000221 BE[EC44] mov si, TrDOS_hdrow_capacity 450 00000224 E82402 call convert_to_decimal 451 452 00000227 BE[F344] mov si, TrDOS_disksize 453 0000022A E86D19 call print_msg 454 455 0000022D BE[EC44] mov si, TrDOS_hdrow_capacity 456 00000230 E86719 call print_msg 457 458 00000233 BE[E644] mov si, TrDOS_hdrow_unit 459 00000236 E86119 call print_msg 460 461 ; 16/10/2020 462 ;cmp word [lba_cyls+2], 0 463 00000239 833E[8C3F]00 cmp word [cylinders+2], 0 464 0000023E 7736 ja short A_27 ; Huge disk ! number of (lba) cylinders > 65335 465 ; Current FDISK version (v3) can not be used ! 466 467 00000240 BE[8755] mov si, CRLF 468 00000243 E85419 call print_msg 469 470 00000246 E8C225 call dpt_1 471 472 00000249 BE[8755] mov si, CRLF 473 0000024C E84B19 call print_msg 474 475 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 476 ; display edit or exit option, getchar 477 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 478 479 0000024F BE[B653] mov si, msg_edit_or_exit 480 00000252 E84519 call print_msg 481 A_24: 482 00000255 30E4 xor ah, ah 483 00000257 CD16 int 16h 484 485 00000259 3C0D cmp al, 13 ; CR (ENTER) key 486 0000025B 744A je short A_28 487 488 0000025D 3C1B cmp al, 27 ; ESCape key 489 0000025F 740D je short A_25 490 491 00000261 3C20 cmp al, 32 ; SPACE key 492 00000263 7442 je short A_28 493 494 00000265 3C03 cmp al, 3 ; CTRL+C 495 00000267 7405 je short A_25 496 497 00000269 83F800 cmp ax, 0 ; CTRL+BREAK 498 0000026C 77E7 ja short A_24 499 A_25: 500 0000026E BE[8755] mov si, CRLF 501 A_26: 502 00000271 E82619 call print_msg 503 504 00000274 CD20 int 20h 505 ;here: 506 ; jmp short here 507 508 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 509 ; display fdisk program disk capacity limit message and then exit 510 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 511 512 A_27: 513 ; 16/10/2020 514 ; 15/10/2020 515 ; Display FDISK (v3) capacity limit (error) message 516 517 00000276 B8FFFF mov ax, 65535 518 00000279 F726[1C6D] mul word [hs] 519 ; 1024 MB = 1GB (2097152 sectors) 520 ; DX/32 --> GB 521 0000027D 89D0 mov ax, dx 522 0000027F C1E805 shr ax, 5 ; /32 523 524 ; ax = 8 to 2047 525 00000282 C606[E644]47 mov byte [TrDOS_hdrow_unit], 'G' 526 ;mov byte [TrDOS_hdrow_unit+1], 'B' 527 00000287 C606[E844]2E mov byte [TrDOS_hdrow_unit+2], '.' 528 529 ;xor dx, dx 530 0000028C BE[EC44] mov si, TrDOS_hdrow_capacity 531 0000028F E8B901 call convert_to_decimal 532 533 00000292 BE[0245] mov si, msg_fdisk_capacity_err 534 00000295 E80219 call print_msg 535 536 00000298 BE[EC44] mov si, TrDOS_hdrow_capacity 537 0000029B E8FC18 call print_msg 538 539 0000029E BE[E644] mov si, TrDOS_hdrow_unit 540 000002A1 E8F618 call print_msg 541 542 000002A4 E90605 jmp _exit 543 544 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 545 ; check defective pte and then init extended partition table(s) 546 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 547 548 A_28: 549 000002A7 E8BE01 call check_defective_partition 550 000002AA 0F8262FF jc A_29 ; ds:si -> defective pte 551 552 ; 17/10/2020 553 ; 26/02/2019 554 000002AE 803E[E76F]00 cmp byte [epnumber], 0 555 000002B3 7603 jna short A_30 556 557 000002B5 E8112D call init_ext_partition_table 558 A_30: 559 ; 17/10/2020 560 ; 04/02/2019 561 ;xor al, al ; MBR/PRIMARY PARTITIONS 562 000002B8 E83825 call display_partition_table ; 12/03/2021 563 564 ; 17/10/2020 565 000002BB 803E[E46F]00 cmp byte [pcount], 0 566 000002C0 0F86F000 jna A_38 ; empty partition table 567 568 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 569 ; check CHS parms against start sector address and partition size 570 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 571 572 A_31: 573 ; Check disk parameters with current CHS settings 574 000002C4 31DB xor bx, bx 575 000002C6 31C9 xor cx, cx 576 A_32: 577 ; 17/10/2020 578 000002C8 80BF[A16F]00 cmp byte [part_table_sys_id+bx], 0 579 000002CD 767C jna short A_33 580 581 ; 27/10/2020 582 ;mov ax, [sectors] 583 ;mul word [heads] 584 ; dx = 0, ax = heads*sectors 585 586 000002CF 8B97[9F6F] mov dx, [part_table_start_cyl+bx] 587 ; 27/10/2020 588 000002D3 81FAFF03 cmp dx, 1023 ; fixed cylinder number (> 1023) 589 ; (partition's start sector is used for fixing) 590 000002D7 7772 ja short A_33 ; no need to check CHS parms here 591 ; (also, CHS to LBA calculation is not applicable) 592 000002D9 A1[1C6D] mov ax, [hs] ; heads*sectors 593 594 000002DC F7E2 mul dx 595 ; dx:ax = cylinder*heads*spt 596 000002DE 89C6 mov si, ax 597 000002E0 89D7 mov di, dx 598 000002E2 8A87[9D6F] mov al, [part_table_start_head+bx] 599 000002E6 F626[863F] mul byte [sectors] 600 000002EA 01C6 add si, ax 601 000002EC 83D700 adc di, 0 602 ; di:si = (cylinder*heads*spt) + head*spt 603 000002EF 8A87[9E6F] mov al, [part_table_start_sector+bx] 604 000002F3 30E4 xor ah, ah 605 000002F5 FEC8 dec al ; 1 -> 0 606 000002F7 01C6 add si, ax 607 000002F9 83D700 adc di, 0 608 ; di:si = (cylinder*heads*spt) + head*spt + sector - 1 609 ; (start sector as converted to LBA) 610 611 000002FC 3BBF[A86F] cmp di, [part_table_rel_sec_hw+bx] 612 00000300 7556 jne short A_34 ; Invalid ! 613 614 00000302 3BB7[A66F] cmp si, [part_table_rel_sec_lw+bx] 615 00000306 7550 jne short A_34 ; Invalid ! 616 ; di:si = partition's start sector (LBA) 617 618 ; 27/10/2020 619 ;mov ax, [sectors] 620 ;mul word [heads] 621 ; dx = 0, ax = heads*sectors 622 623 00000308 8B97[A46F] mov dx, [part_table_end_cyl+bx] 624 625 ; 27/10/2020 626 0000030C 81FAFF03 cmp dx, 1023 ; fixed cylinder number (> 1023) 627 ; (partition's end sector is used for fixing) 628 00000310 7739 ja short A_33 ; no need to check CHS parms here 629 ; (also, CHS to LBA calculation is not applicable) 630 00000312 A1[1C6D] mov ax, [hs] ; heads*sectors 631 632 00000315 F7E2 mul dx 633 ; dx:ax = cylinder*heads*spt 634 00000317 89C6 mov si, ax 635 00000319 89D7 mov di, dx 636 0000031B 8A87[A26F] mov al, [part_table_end_head+bx] 637 0000031F F626[863F] mul byte [sectors] 638 00000323 01C6 add si, ax 639 00000325 83D700 adc di, 0 640 ; di:si = (cylinder*heads*spt) + head*spt 641 00000328 8A87[A36F] mov al, [part_table_end_sector+bx] 642 0000032C 30E4 xor ah, ah 643 ;dec al ; 63 -> 62 644 0000032E 01C6 add si, ax 645 00000330 83D700 adc di, 0 646 ; di:si = (cylinder*heads*spt) + head*spt + sector 647 ; (end sector + 1 as converted to LBA) 648 00000333 8B87[AA6F] mov ax, [part_table_num_sec_lw+bx] 649 00000337 8B97[AC6F] mov dx, [part_table_num_sec_hw+bx] 650 651 0000033B 0387[A66F] add ax, [part_table_rel_sec_lw+bx] 652 0000033F 1397[A86F] adc dx, [part_table_rel_sec_hw+bx] 653 ; dx:ax = partition's end sector (LBA) + 1 654 655 00000343 39F0 cmp ax, si 656 00000345 7511 jne short A_34 ; Invalid ! 657 658 00000347 39FA cmp dx, di 659 00000349 750D jne short A_34 ; Invalid ! 660 A_33: 661 0000034B FEC1 inc cl 662 663 0000034D 80F904 cmp cl, 4 664 00000350 730E jnb short A_35 665 666 00000352 83C312 add bx, 18 ; partition table structure size 667 668 00000355 E970FF jmp A_32 669 A_34: 670 00000358 BE[195F] mov si, msg_defective_pt 671 0000035B E83C18 call print_msg 672 0000035E EB54 jmp short A_38 673 674 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 675 ; sort MBR partitions 676 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 677 678 A_35: 679 ; LBA and CHS values of all partitions are OK (here) 680 681 ; sort MBR (primary) partitions 682 683 00000360 E87B21 call sort_partition_table 684 685 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 686 ; Check partition (start, size) overlaps after sorting 687 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 688 689 ; Checking partition overlaps (via start and end cylinders) 690 691 00000363 31DB xor bx, bx 692 00000365 BA1200 mov dx, 18 693 A_36: 694 00000368 FEC3 inc bl 695 696 0000036A 8A87[2C6D] mov al, [bx+sort] 697 0000036E F6E2 mul dl 698 00000370 89C6 mov si, ax ; current 699 700 00000372 80BC[A16F]00 cmp byte [part_table_sys_id+si], 0 701 00000377 7636 jna short A_37 702 703 00000379 8A87[2B6D] mov al, [bx+sort-1] 704 0000037D F6E2 mul dl 705 0000037F 89C7 mov di, ax ; previous 706 707 00000381 8B85[A46F] mov ax, [part_table_end_cyl+di] 708 00000385 3B84[9F6F] cmp ax, [part_table_start_cyl+si] 709 00000389 7224 jb short A_37 710 ; 29/10/2020 711 0000038B 77CB ja short A_34 ; overlap ! 712 713 ; 17/10/2020 714 ;and ax, ax 715 ;jnz short A_34 ; overlap error (except empty entries) 716 717 ; 29/10/2020 718 ; same cylinder 719 ; check end-start sectors for overlap 720 721 0000038D 21C0 and ax, ax 722 0000038F 741E jz short A_37 ; empty pt entries 723 ; (previous pte is empty) 724 725 00000391 8B85[A66F] mov ax, [part_table_rel_sec_lw+di] ; previous 726 00000395 8B95[A86F] mov dx, [part_table_rel_sec_hw+di] 727 00000399 0385[AA6F] add ax, [part_table_num_sec_lw+di] 728 0000039D 1395[AC6F] adc dx, [part_table_num_sec_hw+di] 729 ;jc short A_34 730 ; dx:ax = end sector + 1 731 000003A1 3B94[A86F] cmp dx, [part_table_rel_sec_hw+si] ; current 732 000003A5 7208 jb short A_37 733 000003A7 77AF ja short A_34 ; overlap error ! 734 000003A9 3B84[A66F] cmp ax, [part_table_rel_sec_lw+si] 735 000003AD 73A9 jnb short A_34 ; overlap error ! 736 A_37: 737 000003AF 80FB03 cmp bl, 3 738 000003B2 72B4 jb short A_36 739 740 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 741 ; display partition table editing options 742 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 743 744 A_38: 745 000003B4 BE[F059] mov si, mbr_editing_options 746 000003B7 E8E017 call print_msg 747 748 000003BA BE[9E5A] mov si, enter_option_number_msg 749 000003BD E8DA17 call print_msg 750 751 000003C0 803E[2A6D]00 cmp byte [ldrives], 0 752 000003C5 760C jna short A_39 753 754 000003C7 BE[8755] mov si, CRLF 755 000003CA E8CD17 call print_msg 756 757 000003CD BE[6160] mov si, str_display_ebr_pt 758 000003D0 E8C717 call print_msg 759 A_39: 760 ;mov si, CRLF 761 ;call print_msg 762 763 A_40: 764 000003D3 30E4 xor ah, ah 765 000003D5 CD16 int 16h 766 767 000003D7 3C30 cmp al, '0' 768 000003D9 742A je short A_41 769 770 000003DB 3C31 cmp al, '1' 771 000003DD 0F84A600 je create_partition 772 000003E1 3C32 cmp al, '2' 773 000003E3 0F843701 je activate_partition 774 000003E7 3C33 cmp al, '3' 775 000003E9 0F84D001 je delete_partition 776 000003ED 3C34 cmp al, '4' 777 000003EF 0F84D302 je write_pt_mbr 778 779 000003F3 3C1B cmp al, 27 ; ESCape 780 000003F5 740E je short A_41 781 782 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 783 ; display (EPT) logical drives/partitions if 'SPACE' is pressed 784 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 785 786 ; 28/02/2019 787 000003F7 803E[2A6D]00 cmp byte [ldrives], 0 788 000003FC 76D5 jna short A_40 789 790 000003FE 3C20 cmp al, 20h ; SPACE 791 00000400 75D1 jne short A_40 792 793 00000402 E9E725 jmp display_extended_pt 794 795 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 796 ; exit if ESC key or '0' is pressed 797 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 798 799 A_41: 800 ; terminate 801 00000405 CD20 int 20h 802 803 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 804 ; display partition table again 805 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 806 807 A_42: 808 ; 24/02/2019 809 ;xor al, al ; MBR/PRIMARY PARTITIONS 810 00000407 E8E923 call display_partition_table ; 12/03/2021 811 0000040A EBA8 jmp short A_38 812 813 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 814 ; display a row for hard disk name, number and capacity 815 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 816 ; 11/10/2020 817 818 display_hd_row: 819 ; dx:ax = disk size 820 821 0000040C 81FA0001 cmp dx, 256 ; >= 8GB 822 00000410 730E jnb short dhdr_1 823 824 ;mov cx, 2048 ; /2048 (2048 sectors = 1 MB) 825 ;div cx 826 827 ; shift dx:ax to 8 bits right (/256) 828 00000412 88E0 mov al, ah 829 00000414 88D4 mov ah, dl 830 00000416 C1E803 shr ax, 3 ; /8 831 ; result = (dx:ax)/2048 832 833 ; ax = 0 to 8191 834 835 00000419 C606[E644]4D mov byte [TrDOS_hdrow_unit], 'M' 836 0000041E EB0A jmp short dhdr_2 837 838 dhdr_1: 839 ; 1024 MB = 1GB (2097152 sectors) 840 ; DX/32 --> GB 841 00000420 89D0 mov ax, dx 842 00000422 C1E805 shr ax, 5 ; /32 843 844 ; ax = 8 to 2047 845 00000425 C606[E644]47 mov byte [TrDOS_hdrow_unit], 'G' 846 dhdr_2: 847 ;xor dx, dx 848 0000042A BE[EC44] mov si, TrDOS_hdrow_capacity 849 0000042D E81B00 call convert_to_decimal 850 851 00000430 FE06[D144] inc byte [TrDOS_hdrow_n] ; next number for "(#)" 852 853 00000434 BE[CE44] mov si, TrDOS_hdrow 854 00000437 E86017 call print_msg 855 0000043A BE[EC44] mov si, TrDOS_hdrow_capacity ; db "#### ", 0 856 0000043D E85A17 call print_msg 857 00000440 BE[E644] mov si, TrDOS_hdrow_unit ; "GB" or "MB" 858 00000443 E85417 call print_msg 859 860 00000446 FE06[D644] inc byte [TrDOS_hdrow_i] ; next number for "hd#" 861 862 0000044A C3 retn 863 864 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 865 ; convert binary number to decimal character string 866 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 867 ; 11/10/2020 868 869 convert_to_decimal: 870 ; ax = binary number 871 ; si = decimal string start addr (max. 5 digits + space) 872 0000044B B90A00 mov cx, 10 873 0000044E 89E5 mov bp, sp 874 ctd_1: 875 00000450 31D2 xor dx, dx 876 00000452 F7F1 div cx 877 00000454 52 push dx ; 0 to 9 878 00000455 09C0 or ax, ax 879 00000457 75F7 jnz short ctd_1 880 ctd_2: 881 00000459 58 pop ax 882 0000045A 0430 add al, '0' 883 0000045C 8804 mov [si], al 884 0000045E 46 inc si 885 0000045F 39E5 cmp bp, sp 886 00000461 77F6 ja short ctd_2 887 ;mov byte [si], 20h ; space before size unit char 888 ;inc si 889 ;mov byte [si], 0 ; ASCIIZ string terminator (Z) 890 00000463 C7042000 mov word [si], 20h 891 00000467 C3 retn 892 893 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 894 ; check defective partition signature 895 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 896 ; 16/10/2020 897 898 check_defective_partition: 899 00000468 BB[9C6F] mov bx, part_table_boot_ind 900 0000046B 31F6 xor si, si 901 chk_dp_1: 902 0000046D 803FFF cmp byte [bx], 0FFh ; invalid/defective/partition sign 903 00000470 7509 jne short chk_dp_2 904 00000472 C1E604 shl si, 4 ; * 16 905 00000475 81C6[C057] add si, MasterBootBuff+446 906 00000479 F9 stc 907 0000047A C3 retn 908 chk_dp_2: 909 ;cmp bx, part_table_boot_ind+(18*4) 910 0000047B 83FE03 cmp si, 3 911 0000047E 7306 jnb short chk_dp_3 912 00000480 83C312 add bx, 18 913 00000483 46 inc si 914 00000484 EBE7 jmp short chk_dp_1 915 chk_dp_3: 916 ;sub si, si 917 00000486 C3 retn 918 919 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 920 ; create a disk partition (on MBR partition table) 921 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 922 ; 18/10/2020 923 924 create_partition: 925 ; 19/10/2020 926 ; 10/02/2019 (hdimage.s) 927 00000487 31C0 xor ax, ax 928 00000489 A2[F86C] mov byte [wholedisk], al ; 0 ; Reset wholedisk flag 929 930 ; 19/10/2020 931 0000048C 3806[E46F] cmp byte [pcount], al ; 0 ; number of (valid) partitions 932 00000490 7621 jna short cp_1 933 ;cp_0: 934 00000492 803E[E46F]04 cmp byte [pcount], 4 935 00000497 731D jnb short cp_2 ; full pt ! 936 937 ; al = 0 938 00000499 E8A620 call find_part_free_space 939 ; Following values are for the max. free space on disk 940 941 0000049C 21C9 and cx, cx 942 0000049E 7427 jz short cp_3 ; there is not free space on disk 943 944 ;mov [c_cylinders], cx ; count of free cylinders in the gap 945 000004A0 891E[8270] mov [c_fspc_offset], bx ; offset from beginning of 'fspc:' 946 ;mov [c_gap], al ; gap (space index) number of this free space 947 ; ; 0 -> before partition 1 (as PTE) 948 ; ; 1-2-3 -> between partitions 1 to 4 949 ; ; 4 -> after partition 4 (as PTE) 950 951 ; Start to job with non-aligned (full) free sectors of this max. space 952 953 000004A4 8B87[3870] mov ax, [free_space.sectors_unused+bx] 954 000004A8 8B97[3A70] mov dx, [free_space.sectors_unused+2+bx] 955 956 000004AC A3[F46C] mov [pp_Sectors], ax 957 000004AF 8916[F66C] mov [pp_Sectors+2], dx 958 cp_1: 959 000004B3 E9E907 jmp B_01 ; New/Empty disk, create partition menu 960 961 cp_2: 962 ; 13/02/2019 963 ; There is not a free pt entry to create a new partition 964 965 ;xor al, al ; MBR/PRIMARY PARTITIONS 966 000004B6 E83A23 call display_partition_table ; 12/03/2021 967 968 000004B9 BE[805B] mov si, msg_full_pt 969 000004BC E8DB16 call print_msg 970 000004BF BE[AD5B] mov si, msg_to_create_new_p 971 000004C2 E8D516 call print_msg 972 973 000004C5 EB67 jmp ap_0 974 cp_3: 975 ; 19/10/2020 976 000004C7 803E[E76F]00 cmp byte [epnumber], 0 977 000004CC 7708 ja short create_logical_drives 978 ;cp_4: 979 ; 15/02/2019 980 ; There is not (enough) free space to create a new partition 981 982 000004CE BE[CB5B] mov si, msg_no_free_space 983 000004D1 E8C616 call print_msg 984 000004D4 EB58 jmp ap_0 985 986 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 987 ; create logical -dos- drives 988 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 989 ; 19/10/2020 990 991 create_logical_drives: 992 ; 05/03/2019 993 000004D6 E89228 call check_ext_free_space 994 000004D9 723B jc short cld_5 995 cld_1: 996 ; 05/03/2019 997 000004DB 803E[2A6D]04 cmp byte [ldrives], 4 998 000004E0 7203 jb short cld_2 999 000004E2 E97525 jmp eetc_2 1000 cld_2: 1001 ; 01/11/2020 1002 000004E5 A3[A670] mov [ep_free_sectors], ax 1003 000004E8 8916[A870] mov [ep_free_sectors+2], dx 1004 1005 000004EC BE[6463] mov si, msg_c_ldd_q 1006 000004EF E8A816 call print_msg 1007 cld_3: 1008 000004F2 28E4 sub ah, ah 1009 000004F4 CD16 int 16h 1010 1011 000004F6 3C1B cmp al, 27 ; ESCAPE key 1012 ;je cp_esc 1013 000004F8 7419 je short cld_6 ; 19/10/2020 1014 000004FA 24DF and al, 0DFh 1015 000004FC 3C4E cmp al, 'N' 1016 000004FE 740D je short cld_4 1017 00000500 3C59 cmp al, 'Y' 1018 00000502 75EE jne short cld_3 1019 00000504 BE[C05C] mov si, _msg_YES 1020 00000507 E89016 call print_msg 1021 1022 0000050A E98025 jmp edit_ext_table_create_x 1023 cld_4: 1024 0000050D BE[C65C] mov si, _msg_NO 1025 00000510 E88716 call print_msg 1026 cld_6: 1027 ;jmp cp_esc 1028 ; 19/10/2020 1029 00000513 E9F1FE jmp A_42 1030 cld_5: 1031 00000516 BE[3463] mov si, msg_c_part_error 1032 00000519 E87E16 call print_msg 1033 1034 ; 21/03/2021 1035 ;cmp byte [ldrives], 3 1036 ;;jna short cld_2 1037 ; 21/03/2021 1038 ;jna short ap_0 1039 1040 ;mov si, msg_c_ldd_error 1041 ;call print_msg 1042 1043 0000051C EB10 jmp short ap_0 1044 1045 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1046 ; set active partition 1047 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1048 ; 19/10/2020 1049 1050 activate_partition: 1051 ; 12/02/2019 1052 ;xor al, al ; MBR/PRIMARY PARTITIONS 1053 0000051E E8D222 call display_partition_table ; 12/03/2021 1054 1055 00000521 803E[E46F]00 cmp byte [pcount], 0 1056 00000526 7713 ja short ap_1 1057 1058 00000528 BE[345B] mov si, msg_empty_pt 1059 0000052B E86C16 call print_msg 1060 ap_0: 1061 0000052E BE[E355] mov si, msg_press_any_key 1062 00000531 E86616 call print_msg 1063 1064 00000534 30E4 xor ah, ah 1065 00000536 CD16 int 16h 1066 ap_5: 1067 ;jmp ap_esc 1068 ; 19/10/2020 1069 00000538 E9CCFE jmp A_42 1070 1071 ap_1: 1072 ; Set valid_ppnums (MBR partition IDs) list 1073 0000053B BE[C057] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 1074 0000053E BB[3E6F] mov bx, valid_ppnums 1075 00000541 B104 mov cl, 4 1076 ap_2: 1077 00000543 8A4404 mov al, [si+ptFileSystemID] 1078 00000546 8807 mov [bx], al 1079 00000548 FEC9 dec cl 1080 0000054A 7406 jz short ap_3 1081 0000054C 43 inc bx 1082 0000054D 83C610 add si, 16 1083 00000550 EBF1 jmp short ap_2 1084 ap_3: 1085 00000552 BE[B35D] mov si, msg_enter_pn_to_act 1086 00000555 E84216 call print_msg 1087 ap_getchar: 1088 00000558 30E4 xor ah, ah 1089 0000055A CD16 int 16h 1090 1091 ; 19/10/2020 1092 0000055C 3C1B cmp al, 27 1093 ;je ap_esc 1094 0000055E 74D8 je short ap_5 1095 1096 ;cmp al, '0' 1097 ;;je ap_esc 1098 ;je short ap_5 1099 1100 00000560 3C31 cmp al, '1' 1101 00000562 72F4 jb short ap_getchar 1102 00000564 3C34 cmp al, '4' 1103 00000566 77F0 ja short ap_getchar 1104 1105 00000568 30E4 xor ah, ah 1106 0000056A 89C2 mov dx, ax 1107 1108 0000056C 80EA31 sub dl, '1' 1109 0000056F 89D6 mov si, dx 1110 00000571 38A4[3E6F] cmp byte [si+valid_ppnums], ah ; 0 1111 00000575 76E1 jna short ap_getchar ; Empty partition table entry, it is not shown 1112 1113 00000577 BB0700 mov bx, 07h 1114 0000057A B409 mov ah, 09h 1115 0000057C B90100 mov cx, 1 1116 0000057F CD10 int 10h 1117 1118 00000581 BE[C057] mov si, MasterBootBuff+pTableOffset 1119 00000584 BF[9C6F] mov di, part_table_boot_ind ; (**) 1120 1121 ; Clear all of possible active partition flags 1122 00000587 8834 mov [si], dh ; 0 1123 00000589 887410 mov [si+16], dh ; 0 1124 0000058C 887420 mov [si+32], dh ; 0 1125 0000058F 887430 mov [si+48], dh ; 0 1126 1127 ; This may not be needed !? 1128 ; (**) (Primary partitions structure/list) 1129 00000592 8835 mov [di], dh ; 0 1130 00000594 887512 mov [di+18], dh ; 0 1131 00000597 887524 mov [di+36], dh ; 0 1132 0000059A 887536 mov [di+54], dh ; 0 1133 1134 0000059D 20D2 and dl, dl 1135 0000059F 740D jz short ap_4 1136 1137 000005A1 89D0 mov ax, dx 1138 1139 000005A3 C0E004 shl al, 4 ; * 16 1140 000005A6 01C6 add si, ax 1141 1142 000005A8 B012 mov al, 18 1143 000005AA F6E2 mul dl ; 1 to 3 1144 000005AC 01C7 add di, ax 1145 ap_4: 1146 ; Then set active partition as requested by user 1147 000005AE C60480 mov byte [si], 80h 1148 000005B1 C60580 mov byte [di], 80h ; (**) 1149 1150 000005B4 BE[8755] mov si, CRLF ; Next line 1151 000005B7 E8E015 call print_msg 1152 1153 ; NOTE: Only the MBR buffer has been changed 1154 ; (Masterboot sector will not be updated unless/till 1155 ; MBR partition table -and MBR code- will be written 1156 ; to disk image as result of 'write part. table' command.) 1157 1158 ;; wait for 1 second 1159 ;mov ah, 02h 1160 ;int 1Ah 1161 ;mov [GetChar], dh 1162 ;ap_wait: 1163 ;mov ah, 02h 1164 ;int 1Ah 1165 ;cmp dh, [GetChar] 1166 ;je short ap_wait 1167 1168 ; 17/10/2020 1169 000005BA E94AFE jmp A_42 ; display partition table again 1170 1171 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1172 ; delete selected partition 1173 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1174 ; 19/10/2020 1175 1176 delete_partition: 1177 ; 10/02/2019 1178 ;xor al, al ; MBR/PRIMARY PARTITIONS 1179 000005BD E83322 call display_partition_table ; 12/03/2021 1180 1181 000005C0 803E[E46F]00 cmp byte [pcount], 0 1182 000005C5 7712 ja short dp_1 1183 1184 000005C7 BE[345B] mov si, msg_empty_pt 1185 000005CA E8CD15 call print_msg 1186 1187 000005CD BE[E355] mov si, msg_press_any_key 1188 000005D0 E8C715 call print_msg 1189 1190 000005D3 30E4 xor ah, ah 1191 000005D5 CD16 int 16h 1192 1193 000005D7 EB73 jmp short dp_esc 1194 1195 dp_1: 1196 ; Set valid_ppnums (MBR partition IDs) list 1197 000005D9 BE[C057] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 1198 000005DC BB[3E6F] mov bx, valid_ppnums 1199 000005DF B104 mov cl, 4 1200 dp_2: 1201 000005E1 8A4404 mov al, [si+ptFileSystemID] 1202 000005E4 8807 mov [bx], al 1203 000005E6 FEC9 dec cl 1204 000005E8 7406 jz short dp_3 1205 000005EA 43 inc bx 1206 000005EB 83C610 add si, 16 1207 000005EE EBF1 jmp short dp_2 1208 dp_3: 1209 000005F0 BE[EF5B] mov si, msg_enter_pn_to_del 1210 000005F3 E8A415 call print_msg 1211 dp_getchar1: 1212 000005F6 30E4 xor ah, ah 1213 000005F8 CD16 int 16h 1214 1215 ; 19/10/2020 1216 000005FA 3C1B cmp al, 27 1217 000005FC 744E je short dp_esc 1218 000005FE 3C30 cmp al, '0' 1219 00000600 744A je short dp_esc 1220 ;cmp al, '1' 1221 00000602 72F2 jb short dp_getchar1 1222 00000604 3C34 cmp al, '4' 1223 00000606 77EE ja short dp_getchar1 1224 1225 00000608 30FF xor bh, bh 1226 0000060A 88C3 mov bl, al 1227 ;dec bl 1228 0000060C 80EB31 sub bl, '1' 1229 0000060F 38BF[3E6F] cmp byte [bx+valid_ppnums], bh ; 0 ; 12/02/2019 1230 00000613 76E1 jna short dp_getchar1 ; Empty partition table entry, it is not shown 1231 1232 00000615 881E[496F] mov [del_part_num], bl ; Selected partition number to be deleted. 1233 00000619 A2[135C] mov [chr_del_pnum1], al ; Partition number for "Enter ..." text 1234 0000061C A2[B55C] mov [chr_del_pnum2], al ; Partition number for "Do you want ..." text 1235 1236 0000061F BE[135C] mov si, chr_del_pnum1 ; write partition number (user input) 1237 00000622 E87515 call print_msg 1238 1239 ;xor al, al 1240 00000625 A2[135C] mov [chr_del_pnum1], al ; 0 ; reset 1241 1242 00000628 BE[175C] mov si, msg_delete_partition_q ; question for deleting (with warning) 1243 0000062B E86C15 call print_msg 1244 1245 dp_getchar2: 1246 0000062E 30E4 xor ah, ah 1247 00000630 CD16 int 16h 1248 1249 00000632 3C1B cmp al, 27 1250 00000634 7416 je short dp_esc 1251 1252 00000636 24DF and al, 0DFh 1253 00000638 3C59 cmp al, 'Y' 1254 0000063A 7413 je short dp_yes 1255 0000063C 3C4E cmp al, 'N' 1256 0000063E 75EE jne short dp_getchar2 1257 dp_no: 1258 00000640 BE[C75C] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 1259 00000643 E85415 call print_msg 1260 1261 00000646 BE[8755] mov si, CRLF ; Next line 1262 00000649 E84E15 call print_msg 1263 1264 ;jmp short dp_esc 1265 1266 ;cp_esc: 1267 ;ap_esc: 1268 ;wptmbr_esc: 1269 dp_esc: 1270 ;xor al, al ; MBR/PRIMARY PARTITIONS 1271 ;call display_partition_table 1272 ;jmp A_38 ; 17/10/2020 1273 1274 ; 19/10/2020 1275 0000064C E9B8FD jmp A_42 1276 1277 dp_yes: 1278 0000064F BE[C15C] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 1279 00000652 E84515 call print_msg 1280 1281 00000655 BF[C057] mov di, MasterBootBuff+pTableOffset 1282 00000658 A0[496F] mov al, [del_part_num] 1283 0000065B 20C0 and al, al 1284 0000065D 7406 jz short dp_4 1285 0000065F 98 cbw 1286 ;xor ah, ah 1287 00000660 C0E004 shl al, 4 ; * 16 1288 00000663 01C7 add di, ax 1289 dp_4: 1290 00000665 BE[8755] mov si, CRLF ; Next line 1291 00000668 E82F15 call print_msg 1292 1293 ; 27/02/2019 1294 0000066B 807D0405 cmp byte [di+ptFileSystemID], 05h ; EXTENDED (CHS) 1295 ;jne short dp_5 1296 0000066F 7406 je short dp_6 1297 ; 24/10/2020 1298 00000671 807D040F cmp byte [di+ptFileSystemID], 0Fh ; EXTENDED (LBA) 1299 00000675 7545 jne short dp_5 1300 dp_6: 1301 00000677 3806[2A6D] cmp byte [ldrives], al ; 0 1302 0000067B 763F jna short dp_5 1303 1304 0000067D BE[375F] mov si, msg_ext_part_del_error 1305 00000680 E81715 call print_msg 1306 00000683 BE[775F] mov si, msg_cancel_continue 1307 00000686 E81115 call print_msg 1308 1309 00000689 30E4 xor ah, ah 1310 0000068B CD16 int 16h 1311 1312 0000068D 3C1B cmp al, 27 ; ESCape 1313 0000068F 74BB je short dp_esc 1314 1315 00000691 E8442A call delete_logical_drives 1316 1317 ; 28/02/2019 1318 00000694 803E[2A6D]01 cmp byte [ldrives], 1 1319 00000699 73B1 jnb short dp_esc 1320 1321 ;xor al, al ; MBR/PRIMARY PARTITIONS 1322 0000069B E85521 call display_partition_table ; 12/03/2021 1323 1324 0000069E BE[0A60] mov si, msg_delete_ext_part 1325 000006A1 E8F614 call print_msg 1326 1327 dp_ask_again: 1328 000006A4 28E4 sub ah, ah 1329 000006A6 CD16 int 16h 1330 1331 000006A8 3C1B cmp al, 27 ; ESCape 1332 000006AA 74A0 je short dp_esc 1333 1334 000006AC 3C0D cmp al, 13 ; ENTER/CR 1335 000006AE 75F4 jne short dp_ask_again 1336 1337 000006B0 BF[C057] mov di, MasterBootBuff+pTableOffset 1338 000006B3 A0[496F] mov al, [del_part_num] 1339 000006B6 98 cbw 1340 000006B7 C0E004 shl al, 4 ; * 16 1341 000006BA 01C7 add di, ax 1342 dp_5: 1343 000006BC 31C0 xor ax, ax 1344 1345 ; clear partition table entry in MBR buffer 1346 000006BE B90800 mov cx, 8 1347 000006C1 F3AB rep stosw 1348 1349 ; NOTE: Only the MBR buffer will be cleared 1350 ; (Masterboot sector will not be updated unless/till 1351 ; MBR partition table -and MBR code- will be written 1352 ; to disk image as result of 'write part. table' command.) 1353 1354 000006C3 E924FB jmp A_21 ; 17/10/2020 1355 1356 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1357 ; write partition table (and MBR code) onto disk 1358 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1359 ; 18/10/2020 1360 1361 write_pt_mbr: 1362 ; 18/10/2020 (fdisk3.s) 1363 ; 11/02/2019 (hdimage.s) 1364 ;xor al, al ; MBR/PRIMARY PARTITIONS 1365 000006C6 E82A21 call display_partition_table ; 12/03/2021 1366 1367 000006C9 BE[CB5C] mov si, msg_write_masterboot_sector 1368 000006CC E8CB14 call print_msg 1369 1370 000006CF A2[1A6D] mov [GetChar], al ; 0 1371 1372 000006D2 BE[AE5D] mov si, option_input 1373 000006D5 E8C214 call print_msg 1374 1375 000006D8 B403 mov ah, 3 1376 ;mov bx, 7 1377 000006DA CD10 int 10h ; Return Cursor Position 1378 ; DL = Column 1379 1380 000006DC FECA dec dl ; previous char ; ']' 1381 000006DE FECA dec dl ; previous char ; '[ ]' 1382 1383 000006E0 B402 mov ah, 2 1384 ;mov bx, 7 1385 000006E2 CD10 int 10h ; Set Cursor Position 1386 1387 ; write char at current cursor position 1388 1389 000006E4 B030 mov al, '0' ; Write default char 1390 1391 ;;mov bx, 07h 1392 000006E6 B409 mov ah, 09h 1393 000006E8 B90100 mov cx, 1 1394 000006EB CD10 int 10h 1395 1396 wptmbr_getchar: 1397 000006ED 30E4 xor ah, ah 1398 000006EF CD16 int 16h 1399 1400 000006F1 3C1B cmp al, 1Bh ; 27 1401 ;je wptmbr_esc ; 19/10/2020 1402 000006F3 0F8410FD je A_42 1403 1404 000006F7 3C0D cmp al, 0Dh ; 13 1405 000006F9 7414 je short wptmbr_1 1406 1407 000006FB 3C31 cmp al, '1' 1408 000006FD 72EE jb short wptmbr_getchar 1409 1410 000006FF 3C32 cmp al, '2' 1411 00000701 77EA ja short wptmbr_getchar 1412 1413 00000703 A2[1A6D] mov [GetChar], al 1414 1415 ;;mov bx, 07h 1416 00000706 B409 mov ah, 09h 1417 00000708 B90100 mov cx, 1 1418 0000070B CD10 int 10h 1419 0000070D EBDE jmp short wptmbr_getchar 1420 1421 wptmbr_1: 1422 0000070F 803E[1A6D]00 cmp byte [GetChar], 0 1423 00000714 76D7 jna short wptmbr_getchar 1424 1425 00000716 BE[7C5D] mov si, msg_writing_ptable 1426 00000719 E87E14 call print_msg 1427 1428 0000071C 803E[1A6D]32 cmp byte [GetChar], '2' 1429 00000721 751F jne short wptmbr_2 ; Do not write Singlix MBR code 1430 1431 ; Write CHS parameters in Singlix (FS specific) MBR 1432 1433 00000723 BE[7331] mov si, TRDOS386_MASTERBOOT_SECTOR 1434 00000726 B9DF00 mov cx, 446/2 ; Copy Singlix FS 1 MBR code 1435 ; except Partition Table 1436 00000729 BF[0256] mov di, MasterBootBuff 1437 0000072C F3A5 rep movsw 1438 1439 ; This (Below) is not needed; because, if MBR magicword 1440 ; would not be 0AA55h, we would not be able to come here! 1441 ;;add di, 64 ; skip partition table 1442 ;;mov ax, 0AA55h 1443 ;;stosw 1444 ;mov word [MBIDCode], 0AA55h 1445 1446 ; 12/02/2019 1447 ; Copy CHS parameters to Singlix MBR (on disk) 1448 1449 0000072E BF[A657] mov di, MasterBootBuff+420 1450 1451 00000731 A1[8A3F] mov ax, [cylinders] 1452 00000734 AB stosw ; cylinders 1453 00000735 A1[883F] mov ax, [heads] 1454 00000738 AB stosw ; heads 1455 00000739 A1[863F] mov ax, [sectors] 1456 0000073C AB stosw ; sectors 1457 1458 ; 13/03/2021 1459 ; copy 32 bit disk size (total LBA sectors) to MBR offset 426 1460 0000073D BE[5E68] mov si, disksize 1461 00000740 A5 movsw 1462 00000741 A5 movsw 1463 1464 wptmbr_2: 1465 ;xor ax, ax ; 0 1466 ;xor dx, dx ; 0 1467 ;; DX_AX = Masterboot Sector = 0 1468 ;mov bx, MasterBootBuff 1469 ;; ES:BX = Sector Buffer 1470 ;call write_hd_sector 1471 ;jc short print_error_code 1472 ; ! display error msg and then exit ! 1473 1474 00000742 C606[5D68]05 mov byte [rcnt], 5 ; retry count 1475 1476 00000747 BB[0256] mov bx, MasterBootBuff 1477 1478 0000074A B90100 mov cx, 1 ; cylinder = 0 1479 ; sector = 1 1480 0000074D B600 mov dh, 0 ; head = 0 1481 0000074F 8A16[5A68] mov dl, [DrvNum] 1482 wptmbr_3: 1483 00000753 B80103 mov ax, 0301h ; write one sector 1484 00000756 CD13 int 13h 1485 00000758 730C jnc short wptmbr_4 1486 1487 0000075A FE0E[5D68] dec byte [rcnt] 1488 0000075E 7431 jz short print_error_code 1489 1490 00000760 30E4 xor ah, ah 1491 ;mov dl, [DrvNum] 1492 00000762 CD13 int 13h ; BIOS Service func (ah) = 0 1493 ; Reset disk system 1494 00000764 EBED jmp short wptmbr_3 1495 1496 wptmbr_4: 1497 00000766 BE[A55D] mov si, _msg_OK 1498 00000769 E82E14 call print_msg 1499 1500 ; wait for 1 second 1501 0000076C B402 mov ah, 02h 1502 0000076E CD1A int 1Ah 1503 00000770 8836[1A6D] mov [GetChar], dh 1504 wptmbr_wait: 1505 00000774 B402 mov ah, 02h 1506 00000776 CD1A int 1Ah 1507 00000778 3A36[1A6D] cmp dh, [GetChar] 1508 0000077C 74F6 je short wptmbr_wait 1509 1510 0000077E BE[E355] mov si, msg_press_any_key 1511 00000781 E81614 call print_msg 1512 1513 00000784 30E4 xor ah, ah ; "Press any key to continue" 1514 00000786 CD16 int 16h 1515 1516 00000788 BE[8755] mov si, CRLF 1517 0000078B E80C14 call print_msg 1518 1519 ;jmp wptmbr_esc 1520 ; 19/10/2020 1521 0000078E E976FC jmp A_42 1522 1523 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1524 ; print error message and exit 1525 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1526 ; 18/10/2020 (fdisk3.s) 1527 1528 print_error_code: 1529 ; 25/02/2019 (hdimage.s) 1530 1531 00000791 88E0 mov al, ah ; error code 1532 00000793 E8DA14 call bin_to_hex 1533 00000796 A3[9555] mov [error_code], ax 1534 1535 00000799 BE[8755] mov si, CRLF 1536 0000079C E8FB13 call print_msg 1537 1538 0000079F BE[8A55] mov si, Msg_Error 1539 000007A2 E8F513 call print_msg 1540 1541 000007A5 CD20 int 20h ; Exit 1542 1543 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1544 ; exit, print_msg & exit 1545 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1546 ; 19/10/2020 1547 1548 _crlf_exit: 1549 000007A7 BE[8755] mov si, CRLF 1550 _p_exit: 1551 ; 11/10/2020 1552 000007AA E8ED13 call print_msg 1553 _exit: 1554 000007AD B8004C mov ax, 4C00h ; terminate 1555 000007B0 CD21 int 21h 1556 1557 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1558 ; display create partition menu & get partition type input 1559 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1560 ; 19/10/2020 1561 1562 create_partition_input: 1563 ; 15/02/2019 1564 ; clear screen 1565 000007B2 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1566 000007B5 CD10 int 10h 1567 1568 000007B7 BE[8145] mov si, msg_create_partition_h ; header 1569 000007BA E8DD13 call print_msg 1570 000007BD BE[7646] mov si, msg_create_partition_m ; menu 1571 000007C0 E8D713 call print_msg 1572 cpi_1: 1573 000007C3 30E4 xor ah, ah 1574 000007C5 CD16 int 16h 1575 000007C7 3C1B cmp al, 27 ; ESC key 1576 000007C9 7445 je short cpi_4 ; 25/02/2019 1577 000007CB 3C30 cmp al, '0' 1578 000007CD 7441 je short cpi_4 ; 25/02/2019 1579 000007CF 72F2 jb short cpi_1 1580 000007D1 3C34 cmp al, '4' 1581 000007D3 77EE ja short cpi_1 1582 1583 000007D5 30E4 xor ah, ah 1584 000007D7 2C30 sub al, '0' 1585 1586 ;mov [pp_type], al 1587 1588 ;mov byte [pp_type_user], 0 1589 1590 000007D9 3C01 cmp al, 1 ; DOS partition 1591 000007DB 7536 jne short cpi_5 ; ah = 0 1592 ; (al = 2 -> singlix, al = 3 -> retro unix) 1593 cpi_2: 1594 ; clear screen 1595 000007DD B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1596 000007E0 CD10 int 10h 1597 1598 000007E2 BE[2C48] mov si, msg_create_dos_partition_h ; header 1599 000007E5 E8B213 call print_msg 1600 000007E8 BE[004C] mov si, msg_create_dos_partition_m ; menu 1601 000007EB E8AC13 call print_msg 1602 cpi_3: 1603 000007EE 30E4 xor ah, ah 1604 000007F0 CD16 int 16h 1605 000007F2 3C1B cmp al, 27 ; ESC key 1606 000007F4 741A je short cpi_4 1607 000007F6 3C30 cmp al, '0' 1608 000007F8 7416 je short cpi_4 1609 000007FA 72F2 jb short cpi_3 1610 000007FC 3C33 cmp al, '3' 1611 000007FE 77EE ja short cpi_3 1612 1613 00000800 30E4 xor ah, ah 1614 00000802 2C30 sub al, '0' 1615 00000804 3C01 cmp al, 1 1616 00000806 7424 je short cpi_6 ; ah = 0 (al = primary dos partition) 1617 1618 ;mov byte [pp_type], 5 1619 1620 00000808 3C02 cmp al, 2 1621 0000080A 7621 jna short cpi_7 1622 1623 0000080C B80600 mov ax, 6 ; ah = 0 (al = logical dos drive/partition) 1624 0000080F C3 retn 1625 1626 cpi_4: 1627 00000810 31C0 xor ax, ax ; ah = 0 (al = 0 -> ESCape/Cancel) 1628 00000812 C3 retn 1629 cpi_5: 1630 00000813 3C04 cmp al, 4 ; option num. for partition type (user) input 1631 00000815 7515 jne short cpi_6 1632 1633 00000817 E82B18 call partition_type_input 1634 1635 ; 29/10/2020 1636 0000081A 08C0 or al, al 1637 ;jz short cpi_6 ; invalid (zero) input or ESC key 1638 0000081C 74F2 jz short cpi_4 1639 1640 0000081E B404 mov ah, 4 ; user/another type partition flag 1641 ; al = Partition ID 1642 00000820 50 push ax 1643 00000821 BE[E355] mov si, msg_press_any_key 1644 00000824 E87313 call print_msg 1645 00000827 28E4 sub ah, ah 1646 00000829 CD16 int 16h 1647 0000082B 58 pop ax 1648 cpi_6: 1649 0000082C C3 retn 1650 cpi_7: 1651 0000082D B80500 mov ax, 5 ; ah = 0 (al = extended dos partition) 1652 00000830 C3 retn 1653 1654 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1655 ; create primary (dos or non-dos) partition 1656 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1657 ; 19/10/2020 1658 ; (This procedure must be called after 'find_part_free_space') 1659 1660 create_primary_partition: 1661 ; 16/02/2019 1662 1663 ; INPUT: 1664 ; none 1665 ; (CHS parameters and free space calculation result will be used.) 1666 ; 1667 ; OUTPUT: 1668 ; Partition table in MBR buffer will be updated. 1669 ; 1670 ; (Modified registers: ax, bx, cx, dx, si, di) 1671 1672 ; Create primary dos or non-dos partition, 1673 ; make partition table entry 1674 1675 ; 19/10/2020 1676 00000831 803E[E46F]00 cmp byte [pcount], 0 ; count of (valid) partitions 1677 00000836 770A ja short cpp_0 1678 1679 ; cylinder = 0, head = 1, sector = 1 1680 ; LBA = (((cylinder*heads)+head)*sectors)+sector-1 1681 1682 00000838 BE[C057] mov si, MasterBootBuff+pTableOffset 1683 1684 0000083B A1[863F] mov ax, [sectors] ; LBA = 17 or 63 1685 0000083E 31D2 xor dx, dx 1686 00000840 EB56 jmp short cpp_4 1687 cpp_0: 1688 ; 16/02/2019 1689 00000842 E86F1F call get_first_free_pte 1690 ; CX = First free PTE number, 0 to 3 1691 ; (CX = 3 if there is not a free PTE, and CF = 1) 1692 ; ((But CF = 1 is not possible here because pcount < 4)) 1693 ; SI = PTE address/offset in MBR buffer 1694 1695 ;mov si, MasterBootBuff+pTableOffset 1696 ;shl cl, 4 ; * 16 1697 ;add si, cx 1698 1699 ; 18/02/2019 1700 00000845 8B3E[8270] mov di, [c_fspc_offset] 1701 00000849 8B9D[3270] mov bx, [di+free_space.start] 1702 0000084D A0[883F] mov al, [heads] 1703 00000850 F626[863F] mul byte [sectors] 1704 00000854 F7E3 mul bx 1705 ; DX:AX = LBA of start cylinder, head 0, sector 1 1706 1707 00000856 8A0E[8470] mov cl, [cylinder_boundary] 1708 1709 ;cmp cl, 0 ; Default (partition size unit is one of C, G, M) 1710 ; boundary alignment is forced as default 1711 ;je short cpp_4 1712 1713 ; 20/02/2019 1714 ;and cl, cl 1715 ;jz short cpp_1 1716 1717 0000085A 80F959 cmp cl, 'Y' 1718 0000085D 7439 je short cpp_4 ; cylinder boundary option (answer) = YES 1719 1720 0000085F 80F94E cmp cl, 'N' 1721 00000862 750A jne short cpp_1 ; cylinder boundary option (answer) = YES/NO 1722 1723 ; cylinder boundary option (answer) = NO 1724 00000864 8B85[3C70] mov ax, [di+free_space.startsector] 1725 00000868 8B95[3E70] mov dx, [di+free_space.startsector+2] 1726 0000086C EB2A jmp short cpp_4 1727 cpp_1: 1728 ;cmp cl, 27 ; ESCape 1729 ;jne short cpp_4 ; 'Y' 1730 1731 ; check cylinder boundary alignment of the start sector 1732 1733 ; if start sector is not aligned, end sector must not be aligned 1734 ; (this rule is valid for ESCape key from the user) 1735 1736 0000086E C606[8470]59 mov byte [cylinder_boundary], 'Y' ; YES for end sector check 1737 1738 00000873 8B8D[3C70] mov cx, [di+free_space.startsector] 1739 1740 00000877 09DB or bx, bx 1741 1742 00000879 8B9D[3E70] mov bx, [di+free_space.startsector+2] 1743 1744 0000087D 7508 jnz short cpp_2 ; start cylinder > 0 1745 1746 ;and bx, bx 1747 ;jnz short cpp_3 1748 1749 0000087F 3B0E[863F] cmp cx, [sectors] 1750 00000883 7413 je short cpp_4 ; start sector is as aligned 1751 00000885 EB08 jmp short cpp_3 1752 cpp_2: 1753 00000887 39C8 cmp ax, cx 1754 00000889 7504 jne short cpp_3 1755 0000088B 39DA cmp dx, bx 1756 0000088D 7409 je short cpp_4 1757 cpp_3: 1758 0000088F 89C8 mov ax, cx 1759 00000891 89DA mov dx, bx 1760 00000893 C606[8470]4E mov byte [cylinder_boundary], 'N' 1761 cpp_4: 1762 00000898 894408 mov [si+ptStartSector], ax 1763 0000089B 89540A mov [si+ptStartSector+2], dx 1764 1765 ; save start sector (for partition formatting procedure) 1766 0000089E A3[F06C] mov [pp_StartSector], ax 1767 000008A1 8916[F26C] mov [pp_StartSector+2], dx 1768 1769 ; 14/03/2021 1770 000008A5 8B0E[226D] mov cx, [ppn_Sectors] 1771 000008A9 8B1E[246D] mov bx, [ppn_Sectors+2] 1772 1773 ; 19/10/2020 1774 000008AD 803E[E46F]00 cmp byte [pcount], 0 1775 000008B2 775E ja short cpp_5 1776 1777 ;xor cx, cx 1778 ;mov [si+ptBeginCylinder], cx ; 0 1779 ;inc cl ; 1 1780 ;mov [si+ptBeginSector], cl ; 1 1781 ;mov [si+ptBeginHead], cl ; 1 1782 ; 14/03/2021 1783 000008B4 C744030000 mov word [si+ptBeginCylinder], 0 1784 000008B9 C6440201 mov byte [si+ptBeginSector], 1 1785 000008BD C6440101 mov byte [si+ptBeginHead], 1 1786 1787 ; set active partition flag 1788 ;mov byte [si+ptBootable], 80h ; bootable/active partition 1789 000008C1 C60480 mov byte [si], 80h ; bootable/active partition 1790 1791 ; 14/03/2021 1792 ; 18/02/2019 1793 ;mov cx, [ppn_Sectors] 1794 ;mov bx, [ppn_Sectors+2] 1795 1796 000008C4 803E[F86C]00 cmp byte [wholedisk], 0 1797 000008C9 0F865401 jna cpp_12 1798 1799 ; 26/10/2020 1800 000008CD 01C8 add ax, cx 1801 000008CF 11DA adc dx, bx 1802 000008D1 83E801 sub ax, 1 1803 000008D4 83DA00 sbb dx, 0 1804 1805 ; 24/10/2020 1806 000008D7 3B16[6468] cmp dx, [chs_limit+2] 1807 000008DB 7217 jb short cpp_17 1808 000008DD 7706 ja short cpp_16 1809 000008DF 3B06[6268] cmp ax, [chs_limit] 1810 000008E3 760F jna short cpp_17 1811 cpp_16: 1812 000008E5 C64405FE mov byte [si+ptEndHead], 0FEh 1813 000008E9 C64406FF mov byte [si+ptEndSector], 0FFh 1814 000008ED C64407FF mov byte [si+ptEndCylinder], 0FFh 1815 000008F1 E9C801 jmp cpp_15 1816 cpp_17: 1817 000008F4 A0[883F] mov al, [heads] 1818 000008F7 FEC8 dec al 1819 000008F9 884405 mov [si+ptEndHead], al 1820 000008FC A0[863F] mov al, [sectors] 1821 000008FF 884406 mov [si+ptEndSector], al 1822 00000902 A1[8A3F] mov ax, [cylinders] 1823 00000905 48 dec ax 1824 00000906 884407 mov [si+ptEndCylinder], al 1825 00000909 C0E406 shl ah, 6 1826 0000090C 086406 or [si+ptEndSector], ah 1827 1828 ;jmp cpp_16 1829 0000090F E9AA01 jmp cpp_15 ; 06/03/2019 1830 cpp_5: 1831 ; 18/02/2019 1832 00000912 803E[8470]59 cmp byte [cylinder_boundary], 'Y' 1833 00000917 753D jne short cpp_7 1834 1835 00000919 30DB xor bl, bl ; head = 0 1836 1837 0000091B 8B8D[3270] mov cx, [di+free_space.start] 1838 1839 ; 06/03/2019 1840 ;or ax, ax 1841 ;jnz short cpp_6 1842 1843 ;and cx, cx ; start cylinder = 0 ? 1844 ;jnz short cpp_6 1845 1846 0000091F 09C8 or ax, cx 1847 ;jnz short cpp_6 1848 00000921 740B jz short cpp_24 ; 31/10/2020 1849 1850 ; 31/10/2020 1851 00000923 A0[863F] mov al, [sectors] 1852 00000926 F626[883F] mul byte [heads] 1853 0000092A F7E1 mul cx 1854 ; dx:ax = LBA sector address 1855 ; bl = head = 0 1856 ; cx = cylinder number 1857 ; ax = sector number 1858 0000092C EB07 jmp short cpp_6 1859 cpp_24: 1860 0000092E A1[863F] mov ax, [sectors] 1861 ; cylinder 0, head 1, sector 1 (LBA = 17 or 63) 1862 00000931 FEC3 inc bl ; head = 1 1863 00000933 31D2 xor dx, dx ; 0 1864 cpp_6: 1865 ; 31/10/2020 1866 00000935 894408 mov [si+ptStartSector], ax 1867 00000938 89540A mov [si+ptStartSector+2], dx 1868 1869 0000093B A3[F06C] mov [pp_StartSector], ax 1870 0000093E 8916[F26C] mov [pp_StartSector+2], dx 1871 1872 00000942 09C9 or cx, cx ; start cylinder ? 1873 00000944 7508 jnz short cpp_25 ; > 0 1874 1875 ;and bl, bl ; head = 0 ? 1876 ;jz short cpp_25 1877 1878 ; cylinder = 0, head = 1, dx:ax = [sectors] 1879 1880 ;sub [pp_Sectors], ax 1881 ;sbb [pp_Sectors+2], cx ; 0 1882 1883 00000946 2906[226D] sub [ppn_Sectors], ax 1884 0000094A 190E[246D] sbb [ppn_Sectors+2], cx ; 0 1885 cpp_25: 1886 0000094E 89C8 mov ax, cx 1887 ; 29/10/2020 1888 00000950 C6440201 mov byte [si+ptBeginSector], 1 ; sector = 1 1889 00000954 EB16 jmp short cpp_8 1890 cpp_7: 1891 ; 18/02/2019 1892 1893 ; [wholedisk] = 0 1894 1895 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 1896 ; (DOS partition size will be changed -down- to 65535 sectors, 1897 ; if it is 65536 sectors.) 1898 1899 00000956 E87301 call fix_32mb_dos_psize 1900 ; bx:cx = [ppn_sectors] = partition size 1901 ; dx:ax = start sector's LBA 1902 1903 ;cylinder = LBA / (heads_per_cylinder * sectors_per_track) 1904 ;temp = LBA % (heads_per_cylinder * sectors_per_track) 1905 ;head = temp / sectors_per_track 1906 ;sector = temp % sectors_per_track + 1 1907 1908 ; Convert LBA sector address to CHS parameters 1909 00000959 8B0E[863F] mov cx, [sectors] 1910 0000095D E81D03 call div32 1911 ; BX = Sector number - 1 1912 00000960 FEC3 inc bl ; sector number (1 based) 1913 00000962 885C02 mov [si+ptBeginSector], bl 1914 ; DX_AX = cylinders * heads + head 1915 00000965 8B0E[883F] mov cx, [heads] 1916 00000969 E81103 call div32 1917 ; ax = cylinder 1918 ; bl = head 1919 cpp_8: 1920 ; 24/10/2020 1921 ;mov bh, 1 ; [si+ptBeginSector] 1922 0000096C 3DFF03 cmp ax, 1023 ; CHS limit 1923 0000096F 7609 jna short cpp_18 1924 ; > CHS limit 1925 00000971 B8FF03 mov ax, 1023 ; cylinder 1926 00000974 B3FE mov bl, 0FEh ; 254 (head) 1927 ;mov bh, 3Fh ; 63 (sector) 1928 ; 26/10/2020 1929 00000976 C644023F mov byte [si+ptBeginSector], 3Fh 1930 cpp_18: 1931 ; BL = Head number 1932 0000097A 885C01 mov [si+ptBeginHead], bl 1933 ; AX = Cylinder number 1934 ;and ax, 1023 1935 0000097D 884403 mov [si+ptBeginCylinder], al 1936 00000980 C0E406 shl ah, 6 1937 ; 24/10/2020 1938 ;or ah, bh ; bh = sector number 1939 ; 26/10/2020 1940 00000983 086402 or [si+ptBeginSector], ah 1941 ;mov [si+ptBeginSector], ah 1942 1943 ; clear active partition flag (for now) 1944 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 1945 00000986 C60400 mov byte [si], 0 ; not bootable/active partition 1946 1947 ;mov di, [c_fspc_offset] 1948 1949 00000989 803E[8470]59 cmp byte [cylinder_boundary], 'Y' 1950 0000098E 0F858000 jne cpp_11 1951 1952 00000992 8A0E[883F] mov cl, [heads] 1953 00000996 A0[863F] mov al, [sectors] 1954 00000999 88C5 mov ch, al 1955 0000099B F6E1 mul cl 1956 ; ax = heads*sectors 1957 1958 0000099D 8B9D[3470] mov bx, [di+free_space.end] ; end cylinder of the partition 1959 1960 000009A1 803E[F86C]00 cmp byte [wholedisk], 0 ; entire free space ? 1961 000009A6 7721 ja short cpp_10 1962 1963 000009A8 89C3 mov bx, ax 1964 000009AA A1[226D] mov ax, [ppn_Sectors] 1965 000009AD 8B16[246D] mov dx, [ppn_Sectors+2] 1966 000009B1 0306[F06C] add ax, [pp_StartSector] 1967 000009B5 1316[F26C] adc dx, [pp_StartSector+2] 1968 000009B9 83E801 sub ax, 1 1969 000009BC 83DA00 sbb dx, 0 1970 ; dx:ax = end sector 1971 000009BF F7F3 div bx 1972 ; ax = cylinder number 1973 ; 31/10/2020 1974 ;and dx, dx 1975 ;jz short cpp_9 1976 ;inc ax ; + 1 (because of remainder > 0) 1977 cpp_9: 1978 000009C1 93 xchg ax, bx 1979 ; bx = end cylinder 1980 ; ax = heads*sectors 1981 ; free space limit check 1982 000009C2 3B9D[3470] cmp bx, [di+free_space.end] 1983 000009C6 7601 jna short cpp_10 ; ok 1984 ; end cylinder is out of free space 1985 000009C8 4B dec bx ; decrease end cylinder number 1986 cpp_10: 1987 000009C9 F7E3 mul bx 1988 ; dx:ax = (end cylinder)*heads*sectors 1989 000009CB 52 push dx ; ** 1990 000009CC 50 push ax ; * 1991 1992 ; 24/10/2020 1993 000009CD 81FBFF03 cmp bx, 1023 ; CHS limit 1994 000009D1 7606 jna short cpp_19 1995 ; > CHS limit 1996 000009D3 BBFF03 mov bx, 1023 ; cylinder 1997 ;mov cl, 0FFh ; 255 (head+1) 1998 ;mov ch, 3Fh ; 63 (sector) 1999 000009D6 B9FF3F mov cx, 3FFFh 2000 cpp_19: 2001 000009D9 FEC9 dec cl ; heads - 1 = end head 2002 2003 000009DB 884C05 mov [si+ptEndHead], cl 2004 ; 26/10/2020 2005 ;mov al, [sectors] 2006 ; 31/10/2020 2007 000009DE 88E8 mov al, ch 2008 000009E0 885C07 mov [si+ptEndCylinder], bl 2009 ;mov bl, al 2010 ;shl bh, 6 ; shift high bytes (2 bits) of end cyl num 2011 ; ; to 6 bits left 2012 ;or bh, bl ; combine high bits of end cyl num and end sector 2013 000009E3 C0E706 shl bh, 6 2014 000009E6 08EF or bh, ch ; ch = end sector (= sectors) 2015 000009E8 887C06 mov [si+ptEndSector], bh 2016 2017 ; 24/10/2020 2018 ;mov bl, [sectors] 2019 ;xor bh, bh ; clear bh 2020 000009EB 8B1E[863F] mov bx, [sectors] ; 17 or 63 2021 2022 000009EF FECB dec bl ; sectors - 1 ; 22/02/2019 2023 000009F1 F6E1 mul cl ; sectors * [end head] 2024 000009F3 5A pop dx ; * 2025 ; 22/02/2019 2026 000009F4 31C9 xor cx, cx 2027 000009F6 01D0 add ax, dx 2028 000009F8 5A pop dx ; ** 2029 000009F9 11CA adc dx, cx ; 0 2030 000009FB 01D8 add ax, bx 2031 000009FD 11CA adc dx, cx ; 0 2032 ; dx:ax = ((([end cylinder]*heads)+[end head])*sectors)+sectors-1 2033 2034 ; calculate aligned partition size in sectors 2035 000009FF 89C1 mov cx, ax 2036 00000A01 89D3 mov bx, dx 2037 00000A03 83C101 add cx, 1 2038 00000A06 83D300 adc bx, 0 2039 00000A09 2B4C08 sub cx, [si+ptStartSector] 2040 00000A0C 1B5C0A sbb bx, [si+ptStartSector+2] 2041 ; bx:cx = partition size 2042 ;mov [ppn_Sectors], cx 2043 ;mov [ppn_Sectors+2], bx 2044 ;jmp cpp_16 2045 00000A0F E9AA00 jmp cpp_15 ; 06/03/2019 2046 cpp_11: 2047 ; 20/02/2019 2048 00000A12 8B0E[226D] mov cx, [ppn_Sectors] 2049 00000A16 8B1E[246D] mov bx, [ppn_Sectors+2] 2050 2051 ;;mov ax, [di+free_space.startsector] 2052 ;;mov ax, [di+free_space.startsector+2] 2053 ;mov ax, [si+ptStartSector] 2054 ;mov dx, [si+ptStartSector+2] 2055 00000A1A A1[F06C] mov ax, [pp_StartSector] 2056 00000A1D 8B16[F26C] mov dx, [pp_StartSector+2] 2057 cpp_12: 2058 ; 18/02/2019 2059 2060 ; [wholedisk] = 0 2061 2062 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 2063 ; (DOS partition size will be changed -down- to 65535 sectors, 2064 ; if it is 65536 sectors.) 2065 2066 00000A21 E8A800 call fix_32mb_dos_psize 2067 ; bx:cx = [ppn_sectors] = partition size 2068 ; dx:ax = start sector's LBA 2069 2070 00000A24 01C8 add ax, cx 2071 00000A26 11DA adc dx, bx 2072 2073 ; Convert LBA sector address to CHS parameters 2074 00000A28 83E801 sub ax, 1 ; locate on to end sector of the partition 2075 00000A2B 83DA00 sbb dx, 0 2076 2077 ; 06/03/2019 2078 00000A2E 803E[8470]59 cmp byte [cylinder_boundary],'Y' 2079 ;jne short cpp_15 2080 00000A33 754D jne short cpp_14 2081 2082 00000A35 89C1 mov cx, ax 2083 00000A37 A0[883F] mov al, [heads] 2084 00000A3A F626[863F] mul byte [sectors] 2085 00000A3E 89C7 mov di, ax ; [heads]*[sectors] 2086 00000A40 91 xchg ax, cx 2087 ; cx = heads*spt 2088 2089 00000A41 E83902 call div32 2090 ; dx = 0 2091 ; ax = end cylinder 2092 ; bx = remainder 2093 ;and bx, bx 2094 ;jz short cpp_13 2095 ;inc ax 2096 ;cpp_13: 2097 ;cmp ax, [cylinders] 2098 ;jb short cpp_14 2099 ;dec ax 2100 ;cpp_14: 2101 2102 ; 26/10/2020 2103 00000A44 3DFF03 cmp ax, 1023 2104 00000A47 760E jna short cpp_20 2105 2106 00000A49 C64405FE mov byte [si+ptEndHead], 0FEh 2107 00000A4D C64406FF mov byte [si+ptEndSector], 0FFh 2108 00000A51 C64407FF mov byte [si+ptEndCylinder], 0FFh 2109 00000A55 EB1A jmp short cpp_21 2110 cpp_20: 2111 00000A57 8B1E[883F] mov bx, [heads] 2112 00000A5B FECB dec bl 2113 00000A5D 885C05 mov [si+ptEndHead], bl 2114 00000A60 8B0E[863F] mov cx, [sectors] 2115 00000A64 88E2 mov dl, ah 2116 00000A66 C0E206 shl dl, 6 2117 00000A69 08CA or dl, cl 2118 00000A6B 885406 mov [si+ptEndSector], dl 2119 00000A6E 884407 mov [si+ptEndCylinder], al 2120 ;mul di ; [cylinders]*[heads]*[sectors] 2121 ;;sub di, cx ; ([heads] - 1) * [sectors] 2122 ;add ax, di 2123 ;adc dx, 0 2124 ;;add ax, cx 2125 ;;adc dx, 0 2126 cpp_21: 2127 00000A71 40 inc ax 2128 00000A72 F7E7 mul di ; result = start LBA of next cylinder 2129 ; dx:ax = end sector LBA + 1 (as cyl. boundary aligned) 2130 00000A74 2B06[F06C] sub ax, [pp_StartSector] 2131 00000A78 1B16[F26C] sbb dx, [pp_StartSector+2] 2132 2133 00000A7C 89C1 mov cx, ax 2134 00000A7E 89D3 mov bx, dx 2135 ;jmp short cpp_16 2136 00000A80 EB3A jmp short cpp_15 2137 ;cpp_15: 2138 cpp_14: 2139 00000A82 8B0E[863F] mov cx, [sectors] 2140 00000A86 E8F401 call div32 2141 ; BX = Sector number - 1 2142 00000A89 FEC3 inc bl ; sector number (1 based) 2143 00000A8B 885C06 mov [si+ptEndSector], bl 2144 ; DX_AX = cylinders * heads + head 2145 00000A8E 8B0E[883F] mov cx, [heads] 2146 00000A92 E8E801 call div32 2147 ; BX = Head number 2148 00000A95 885C05 mov [si+ptEndHead], bl 2149 ; AX = Cylinder number 2150 ;and ax, 1023 2151 2152 ; 26/10/2020 2153 00000A98 3DFF03 cmp ax, 1023 2154 00000A9B 760E jna short cpp_22 2155 2156 00000A9D C64405FE mov byte [si+ptEndHead], 0FEh 2157 00000AA1 C64406FF mov byte [si+ptEndSector], 0FFh 2158 00000AA5 C64407FF mov byte [si+ptEndCylinder], 0FFh 2159 00000AA9 EB09 jmp short cpp_23 2160 cpp_22: 2161 00000AAB 884407 mov [si+ptEndCylinder], al 2162 ; 18/02/2019 2163 00000AAE C0E406 shl ah, 6 2164 00000AB1 086406 or [si+ptEndSector], ah 2165 cpp_23: 2166 00000AB4 8B0E[226D] mov cx, [ppn_Sectors] 2167 00000AB8 8B1E[246D] mov bx, [ppn_Sectors+2] 2168 ;cpp_16: 2169 cpp_15: 2170 00000ABC 894C0C mov [si+ptSectors], cx 2171 00000ABF 895C0E mov [si+ptSectors+2], bx 2172 2173 ; set partition ID after checking DOS FAT limits 2174 00000AC2 E8EF00 call set_partition_id 2175 ; al = partition ID 2176 2177 00000AC5 A2[F96C] mov [pp_type], al 2178 2179 00000AC8 884404 mov [si+ptFileSystemID], al 2180 2181 00000ACB C3 retn 2182 2183 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2184 ; decrease DOS partition size when it is (exact) 65536 sectors 2185 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2186 ; 18/02/2019 2187 2188 fix_32mb_dos_psize: ; call this if [wholedisk] = 0 2189 2190 ; Purpose: 2191 ; If a DOS partition's size is 65536 sectors 2192 ; MSDOS 3.3 can not use it. (FAT 16 partition ID = 06h) 2193 ; Decreasing partition size to 65535 sectors will ensure 2194 ; MSDOS 3.3 compatibility (FAT 16 partition ID will be 04h). 2195 2196 ; INPUT: 2197 ; BX:CX = partition size in sectors 2198 ; [pp_type] = partition type dos, non-dos, user input 2199 ; 2200 ; OUTPUT: 2201 ; Partition size will be changed to 65535 sectors, if 2202 ; - partition size is 65536 sectors and 2203 ; - [pp_type] is 1 (DOS) 2204 ; 2205 ; [ppn_Sectors] = 65535 (if it will be changed) 2206 ; 2207 ; (Modified registers: cx, bx) 2208 2209 ;mov cx, [ppn_Sectors] 2210 ;mov bx, [ppn_Sectors+2] 2211 2212 00000ACC 803E[F96C]01 cmp byte [pp_type], 1 ; DOS partition 2213 00000AD1 7513 jne short psfx_0 ; non-dos partition or user input 2214 ; nothing to do ! 2215 00000AD3 09C9 or cx, cx 2216 00000AD5 750F jnz short psfx_0 ; <> 65536 sectors 2217 00000AD7 83FB01 cmp bx, 1 2218 00000ADA 750A jne short psfx_0 2219 00000ADC 4B dec bx 2220 ;mov [wholedisk], bx ; 0 2221 00000ADD 49 dec cx ; bx:cx = 65535 2222 00000ADE 890E[226D] mov [ppn_Sectors], cx 2223 00000AE2 891E[246D] mov [ppn_Sectors+2], bx 2224 psfx_0: 2225 00000AE6 C3 retn 2226 2227 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2228 ; create extended dos partition 2229 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2230 ; 24/10/2020 (fdisk3.s) 2231 2232 ; 16/02/2019 (hdimage.s) 2233 ; (This procedure must be called after 'find_part_free_space') 2234 2235 create_extended_partition: 2236 ; 15/02/2019 2237 2238 ; INPUT: 2239 ; none 2240 ; (CHS parameters and free space calculation result will be used.) 2241 ; 2242 ; OUTPUT: 2243 ; Partition table in MBR buffer will be updated. 2244 ; 2245 ; (Modified registers: ax, bx, cx, dx, si, di) 2246 2247 ; Create extended dos partition, make partition table entry 2248 ; (Extended partition will be created on cylinder bounds.) 2249 2250 ; 16/02/2019 2251 00000AE7 E8CA1C call get_first_free_pte 2252 ; CX = First free PTE number, 0 to 3 2253 ; (CX = 3 if there is not a free PTE, and CF = 1) 2254 ; ((But CF = 1 is not possible here because pcount < 4)) 2255 ; SI = PTE addres/offset in MBR buffer 2256 2257 ;mov si, MasterBootBuff+pTableOffset 2258 ;shl cl, 4 ; * 16 2259 ;add si, cx 2260 2261 00000AEA 8B1E[8270] mov bx, [c_fspc_offset] 2262 2263 00000AEE 8B87[3270] mov ax, [bx+free_space.start] 2264 2265 ; 24/10/2020 2266 00000AF2 89C7 mov di, ax 2267 ;mov cx, 1 2268 00000AF4 B101 mov cl, 1 ; head (ch) = 0, sector (cl) = 1 2269 2270 00000AF6 3DFF03 cmp ax, 1023 2271 00000AF9 7606 jna short cep_4 2272 2273 ; partition start > CHS limit 2274 00000AFB B8FF03 mov ax, 1023 2275 ;mov ch, 254 2276 ;mov cl, 63 2277 00000AFE B93FFE mov cx, 0FE3Fh 2278 cep_4: 2279 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 2280 ;mov [si], ch ; 0 ; not bootable/active partition 2281 ; 26/10/2020 2282 00000B01 C60400 mov byte [si], 0 2283 00000B04 886C01 mov [si+ptBeginHead], ch 2284 00000B07 C0E406 shl ah, 6 2285 00000B0A 08E1 or cl, ah 2286 00000B0C 884C02 mov [si+ptBeginSector], cl ; Sector 1 2287 00000B0F 884403 mov [si+ptBeginCylinder], al 2288 2289 00000B12 A0[883F] mov al, [heads] 2290 00000B15 F626[863F] mul byte [sectors] 2291 ; ax = heads*sectors 2292 00000B19 F7E7 mul di ; AX * cylinder count before start cylinder 2293 ; DX:AX = LBA of cylinder DI, head 0, sector 1 2294 2295 00000B1B 894408 mov [si+ptStartSector], ax 2296 00000B1E 89540A mov [si+ptStartSector+2], dx 2297 2298 ; This is not needed for extended partition. 2299 ; 16/02/2019 2300 ;mov [pp_StartSector], ax 2301 ;mov [pp_StartSector+2], dx 2302 2303 ; 16/02/2019 2304 00000B21 803E[F86C]00 cmp byte [wholedisk], 0 2305 00000B26 772A ja short cep_2 ; all of free space will be used 2306 ; ([bx+free_space.end] will be end cyl) 2307 2308 ; calculate cylinder count (from partition size input) 2309 00000B28 A0[883F] mov al, [heads] 2310 00000B2B F626[863F] mul byte [sectors] 2311 00000B2F 89C1 mov cx, ax 2312 00000B31 A1[226D] mov ax, [ppn_Sectors] 2313 00000B34 8B16[246D] mov dx, [ppn_Sectors+2] 2314 00000B38 E84201 call div32 2315 ; ax = cylinders 2316 ; bx = remainder 2317 00000B3B 21DB and bx, bx 2318 00000B3D 7401 jz short cep_1 2319 2320 00000B3F 40 inc ax ; round up 2321 cep_1: 2322 ; 16/02/2019 2323 ; DI = extended partition's start cylinder 2324 00000B40 89C2 mov dx, ax ; cylinder count 2325 00000B42 01FA add dx, di ; result is end cyl + 1 2326 00000B44 4A dec dx ; decrease number for current end cylinder 2327 00000B45 8B1E[8270] mov bx, [c_fspc_offset] 2328 00000B49 3B97[3470] cmp dx, [bx+free_space.end] 2329 00000B4D 7607 jna short cep_3 2330 ; 24/10/2020 2331 ;dec ax ; decrease cylinder count down to the limit 2332 00000B4F 4A dec dx ; decrease end cylinder down to the limit 2333 00000B50 EB04 jmp short cep_3 2334 cep_2: 2335 00000B52 8B97[3470] mov dx, [bx+free_space.end] 2336 ;mov ax, [bx+free_space.space] 2337 cep_3: 2338 ; 24/10/2020 2339 00000B56 89D0 mov ax, dx ; end cylinder 2340 00000B58 B305 mov bl, 05h ; Extended Partition ID (CHS) 2341 00000B5A 3DFF03 cmp ax, 1023 2342 00000B5D 760A jna short cep_5 2343 2344 ; partition end > CHS limit 2345 00000B5F B8FF03 mov ax, 1023 2346 ;mov ch, 254 2347 ;mov cl, 63 2348 00000B62 B93FFE mov cx, 0FE3Fh 2349 00000B65 B30F mov bl, 0Fh ; Extended Partition ID (LBA) 2350 00000B67 EB0A jmp short cep_6 2351 cep_5: 2352 00000B69 8A2E[883F] mov ch, [heads] 2353 00000B6D FECD dec ch 2354 00000B6F 8A0E[863F] mov cl, [sectors] 2355 cep_6: 2356 00000B73 886C05 mov [si+ptEndHead], ch 2357 ; 24/10/2020 2358 ; ax = (chs limit compatible) end cylinder (<= 1023) 2359 ; 23/02/2019 2360 ;mov bl, dh 2361 ;shl bl, 6 2362 ;or bl, cl 2363 00000B76 C0E406 shl ah, 6 2364 00000B79 08E1 or cl, ah 2365 ;mov [si+ptEndSector], bl 2366 00000B7B 884C06 mov [si+ptEndSector], cl 2367 ;mov [si+ptEndCylinder], dl 2368 00000B7E 884407 mov [si+ptEndCylinder], al 2369 ; dx = (lba compatible) end cylinder (up to 65535) 2370 2371 ;mov al, [heads] 2372 ; 26/10/2020 2373 ;;mul cl 2374 ;mul byte [sectors] 2375 00000B81 8A2E[883F] mov ch, [heads] 2376 00000B85 A0[863F] mov al, [sectors] 2377 00000B88 F6E5 mul ch 2378 ; ax = heads*sectors 2379 00000B8A F7E2 mul dx ; AX * cylinder count before end cylinder 2380 ; DX:AX = LBA of cylinder DX, head 0, sector 1 2381 00000B8C 52 push dx 2382 00000B8D 50 push ax 2383 00000B8E 88E8 mov al, ch 2384 00000B90 FEC8 dec al ; 26/10/2020 ; [heads] - 1 2385 00000B92 8B0E[863F] mov cx, [sectors] ; 63 or 17 2386 00000B96 F6E1 mul cl 2387 ; ax = (heads-1)*sectors 2388 00000B98 5A pop dx 2389 00000B99 01D0 add ax, dx 2390 00000B9B 5A pop dx 2391 00000B9C 83D200 adc dx, 0 2392 ; dx:ax = ((end cylinder)*heads)+(heads-1)*sectors 2393 00000B9F 01C8 add ax, cx 2394 00000BA1 83D200 adc dx, 0 2395 ; dx:ax = (((end cylinder)*heads)+(heads-1)*sectors) + sectors 2396 ; dx:ax = LBA of the partition's end sector + 1 2397 00000BA4 2B4408 sub ax, [si+ptStartSector] 2398 00000BA7 1B540A sbb dx, [si+ptStartSector+2] 2399 2400 00000BAA 89440C mov [si+ptSectors], ax 2401 00000BAD 89540E mov [si+ptSectors+2], dx 2402 2403 ;mov [pp_type], al 2404 2405 ;mov byte [si+ptFileSystemID], 5 2406 ; 24/10/2020 2407 00000BB0 885C04 mov [si+ptFileSystemID], bl ; 05h or 0Fh 2408 2409 00000BB3 C3 retn 2410 2411 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2412 ; set DOS (and non-dos) partition ID according to partition size 2413 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2414 ; 23/10/2020 2415 2416 set_partition_id: 2417 ; 23/10/2020 (fdisk3.s) 2418 ; input: 2419 ; si = partition table offset 2420 ; bx:cx = partition size 2421 2422 ; 18/02/2019 (hdimage.s) 2423 ;mov cx, [ppn_Sectors] 2424 ;mov bx, [ppn_Sectors+2] 2425 2426 00000BB4 A0[F96C] mov al, [pp_type] 2427 2428 ;cmp byte [pp_type], 1 2429 00000BB7 3C01 cmp al, 1 ; primary DOS (FAT12, FAT16, FAT32) 2430 00000BB9 7519 jne short spid_2 ; singlix, runix or user type 2431 2432 ;mov al, 1 ; FAT12 2433 2434 00000BBB 09DB or bx, bx 2435 00000BBD 750A jnz short spid_1 2436 2437 00000BBF 81F9A87F cmp cx, 32680 2438 ;jna short spid_8 ; FAT12 file system 2439 00000BC3 761C jna short spid_19 ; 23/10/2020 2440 2441 00000BC5 B004 mov al, 4 ; FAT16 (< 32MB) 2442 2443 00000BC7 EB39 jmp short spid_8 ; FAT16 (CHS) file system 2444 2445 spid_1: 2446 00000BC9 B00B mov al, 0Bh ; FAT32 (CHS) 2447 2448 00000BCB 83FB10 cmp bx, 10h 2449 00000BCE 7332 jnb short spid_8 ; FAT32 (CHS) file system 2450 2451 00000BD0 B006 mov al, 6 ; FAT16 (>= 32MB) 2452 2453 00000BD2 EB2E jmp short spid_8 ; FAT16 big (CHS) file system 2454 2455 spid_2: 2456 ;cmp byte [pp_type], 2 ; Singlix FS 2457 00000BD4 3C02 cmp al, 2 2458 00000BD6 7503 jne short spid_3 2459 00000BD8 B0A1 mov al, 0A1h 2460 ;jmp short spid_8 2461 00000BDA C3 retn ; 23/10/2020 2462 spid_3: 2463 ;cmp byte [pp_type], 3 ; Retro Unix FS 2464 00000BDB 3C03 cmp al, 3 2465 00000BDD 7503 jne short spid_4 2466 00000BDF B071 mov al, 71h 2467 ;jmp short spid_8 2468 spid_19: 2469 00000BE1 C3 retn 2470 2471 spid_4: 2472 ; another partition type (user input) 2473 2474 ; [pp_type] = 4 2475 2476 00000BE2 A0[FA6C] mov al, [pp_type_user] 2477 2478 ; Check FAT12 fs size validation 2479 2480 00000BE5 3C01 cmp al, 1 ; FAT12 2481 00000BE7 7737 ja short spid_9 2482 2483 00000BE9 21DB and bx, bx 2484 00000BEB 750A jnz short spid_6 2485 2486 00000BED 81F9A87F cmp cx, 32680 2487 ;jna short spid_8 2488 00000BF1 76EE jna short spid_19 ; 23/10/2020 2489 spid_5: 2490 00000BF3 B004 mov al, 4 ; FAT16 (<= 32MB) 2491 00000BF5 EB0B jmp short spid_8 2492 spid_6: 2493 ;;cmp bx, 10h ; 512MB (16*32MB) 2494 ; 15/03/2021 2495 00000BF7 83FB40 cmp bx, 40h ; 2GB (64*32MB) 2496 00000BFA 7304 jnb short spid_7 2497 2498 00000BFC B006 mov al, 6 2499 00000BFE EB02 jmp short spid_8 2500 spid_7: 2501 00000C00 B00B mov al, 0Bh ; FAT32 (CHS) partition 2502 spid_8: 2503 ; 23/10/2020 2504 ; check the partition's end sector against CHS limit and 2505 ; convert partition ID if the partition overs CHS limit 2506 ;cmp al, 1 ; FAT12 fs 2507 ;je short spid_19 ; nothing to do (for FAT12 fs) 2508 00000C02 034C08 add cx, [si+ptStartSector] 2509 00000C05 135C0A adc bx, [si+ptStartSector+2] 2510 00000C08 3B1E[6468] cmp bx, [chs_limit+2] ; 07/11/2020 2511 00000C0C 72D3 jb short spid_19 ; partition's end sector is in CHS limit 2512 00000C0E 7706 ja short spid_17 ; out of CHS limit 2513 00000C10 3B0E[6268] cmp cx, [chs_limit] 2514 00000C14 76CB jna short spid_19 ; partition's end sector is in CHS limit 2515 spid_17: 2516 ; out of CHS limit, partition ID conversion is needed 2517 00000C16 3C0B cmp al, 0Bh ; FAT32 CHS 2518 00000C18 7203 jb short spid_18 2519 00000C1A B00C mov al, 0Ch ; FAT 32 LBA 2520 00000C1C C3 retn 2521 spid_18: 2522 00000C1D B00E mov al, 0Eh ; FAT16 LBA 2523 00000C1F C3 retn 2524 spid_9: 2525 00000C20 3C04 cmp al, 4 ; FAT16 (< 32 MB) 2526 00000C22 750C jne short spid_10 2527 2528 00000C24 09DB or bx, bx 2529 00000C26 75CF jnz short spid_6 2530 2531 ; 15/03/2021 2532 00000C28 81F93610 cmp cx, 4150 ; 4085 + 32 + 32 + 1 2533 00000C2C 7217 jb short spid_12 2534 2535 ;retn ; FAT16 (< 32 MB) partition 2536 00000C2E EBD2 jmp short spid_8 ; 23/10/2020 2537 2538 spid_10: 2539 00000C30 3C06 cmp al, 6 ; FAT 16 big partition 2540 00000C32 7514 jne short spid_13 ; Extended partition or another type 2541 2542 00000C34 21DB and bx, bx 2543 00000C36 7407 jz short spid_11 2544 2545 ;cmp bx, 10h ; 512MB (16*32MB) 2546 ; 15/03/2021 2547 00000C38 83FB40 cmp bx, 40h ; 2GB (64*32MB) 2548 00000C3B 73C3 jnb short spid_7 2549 2550 ;retn 2551 00000C3D EBC3 jmp short spid_8 ; 23/10/2020 2552 2553 spid_11: 2554 ;cmp ax, 4150 ; 4085 + 32 + 32 + 1 2555 00000C3F 81F93610 cmp cx, 4150 ; 14/09/2020 (BugFix) 2556 00000C43 73AE jnb short spid_5 2557 spid_12: 2558 00000C45 B001 mov al, 1 ; FAT12 partition 2559 spid_16: 2560 00000C47 C3 retn 2561 spid_13: 2562 ; 14/09/2020 2563 00000C48 3C0B cmp al, 0Bh ; FAT 32 (CHS) partition 2564 00000C4A 7420 je short spid_15 ; FAT 32 CHS 2565 00000C4C 3C0C cmp al, 0Ch 2566 00000C4E 750C jne short spid_14 2567 ; FAT 32 LBA 2568 00000C50 21DB and bx, bx ; < 33 MB 2569 00000C52 74EB jz short spid_11 ; force to FAT 16 CHS or FAT 12 2570 00000C54 83FB10 cmp bx, 10h ; 512 MB 2571 ;jnb short spid_8 ; OK, FAT 32 LBA has been confirmed 2572 00000C57 73EE jnb short spid_16 ; 23/10/2020 2573 00000C59 B00E mov al, 0Eh ; force to FAT 16 LBA 2574 00000C5B C3 retn 2575 spid_14: 2576 ; 14/09/2020 2577 00000C5C 3C0E cmp al, 0Eh 2578 ;jne short spid_8 ; non-dos or extended partition 2579 00000C5E 75E7 jne short spid_16 ; 23/10/2020 2580 ; FAT 16 LBA 2581 00000C60 09DB or bx, bx 2582 00000C62 74DB jz short spid_11 2583 ; 23/10/2020 2584 00000C64 83FB20 cmp bx, 20h ; 1 GB 2585 00000C67 72DE jb short spid_16 2586 00000C69 B00C mov al, 0Ch ; FAT 32 LBA 2587 00000C6B C3 retn 2588 spid_15: 2589 ; Minimum size of FAT 32 FS = 65525 + 512 + 512 + 32 2590 ; >= 66581 sectors (or >= 65525 data clusters) 2591 00000C6C 83FB01 cmp bx, 1 2592 00000C6F 72CE jb short spid_11 ; invalid! (< 33 MB) 2593 00000C71 778F ja short spid_8 2594 00000C73 81F91504 cmp cx, 1045 2595 ;jb short spid_16 ; invalid! (< 33 MB) 2596 ;retn 2597 ;jmp short spid_8 ; 23/10/2020 2598 00000C77 7389 jnb short spid_8 2599 ;spid_16: 2600 00000C79 B006 mov al, 6 2601 ;retn 2602 00000C7B EB85 jmp short spid_8 ; 23/10/2020 2603 2604 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2605 ; 32 bit division by using 16 bit registers 2606 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2607 2608 div32: 2609 ; DX_AX/CX 2610 ; Result: DX_AX, BX (remainder) 2611 00000C7D 89C3 mov bx, ax 2612 ;or dx, ax ; * DX_AX = 0 ? 2613 ;jz short div32_retn ; yes, do not divide! 2614 00000C7F 89D0 mov ax, dx 2615 00000C81 31D2 xor dx, dx 2616 00000C83 F7F1 div cx ; at first, divide DX 2617 ; remainder is in DX 2618 00000C85 93 xchg ax, bx ; now quotient is in BX 2619 ; and initial AX value is in AX 2620 00000C86 F7F1 div cx ; now, DX_AX has been divided and 2621 ; AX has quotient 2622 ; DX has remainder 2623 00000C88 87D3 xchg dx, bx ; finally, BX has remainder 2624 ;div32_retn: 2625 00000C8A C3 retn 2626 2627 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2628 ; 32 bit multiplication by using 16 bit registers 2629 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2630 2631 mul32: 2632 ; DX_AX*CX 2633 ; Result: BX_DX_AX 2634 00000C8B 51 push cx 2635 00000C8C 89D3 mov bx, dx 2636 00000C8E F7E1 mul cx 2637 00000C90 93 xchg ax, bx 2638 00000C91 52 push dx 2639 00000C92 F7E1 mul cx 2640 00000C94 59 pop cx 2641 00000C95 01C8 add ax, cx 2642 00000C97 83D200 adc dx, 0 2643 00000C9A 93 xchg bx, ax 2644 00000C9B 87D3 xchg dx, bx 2645 00000C9D 59 pop cx 2646 00000C9E C3 retn 2647 2648 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2649 ; creeate new partition input menu 2650 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2651 2652 B_01: 2653 ; 06/03/2019 2654 00000C9F C606[066D]4D mov byte [pSize_unit], 'M' ; default (for 'whole' disk/space) 2655 ; 15/02/2019 2656 00000CA4 E80BFB call create_partition_input 2657 B_02: 2658 00000CA7 21C0 and ax, ax 2659 ;jz _crlf_exit ; 0 = none or not a valid input 2660 00000CA9 0F845AF7 jz A_42 ; 25/02/2019 2661 2662 ;or ah, ah 2663 ;jz short B_03 2664 2665 ; 23/02/2019 2666 00000CAD 80FC04 cmp ah, 4 ; user's partition type input ? 2667 00000CB0 7505 jne short B_03 ; no 2668 2669 ; 29/10/2020 2670 ; (ah = 0) 2671 ;or al, al 2672 ;jz A_42 ; invalid partition type input 2673 ; ; or ESC key has been pressed 2674 2675 ; user type input 2676 00000CB2 A2[FA6C] mov [pp_type_user], al 2677 00000CB5 88E0 mov al, ah ; mov al, 4 2678 B_03: 2679 00000CB7 A2[F96C] mov [pp_type], al 2680 2681 ; clear screen 2682 00000CBA B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 2683 00000CBD CD10 int 10h 2684 2685 00000CBF A0[F96C] mov al, [pp_type] 2686 00000CC2 3C01 cmp al, 1 2687 00000CC4 7705 ja short B_04 2688 2689 00000CC6 BE[2C48] mov si, msg_create_dos_partition_h ; header 2690 00000CC9 EB70 jmp short B_09 2691 B_04: 2692 00000CCB 3C05 cmp al, 5 2693 00000CCD 7269 jb short B_08 2694 ;ja short B_07 2695 00000CCF 7741 ja short B_58 ; 26/10/2020 2696 2697 ; 23/02/2019 2698 00000CD1 BE[2149] mov si, msg_create_ext_partition_h 2699 00000CD4 E8C30E call print_msg 2700 2701 ; 24/02/2019 2702 00000CD7 803E[E76F]00 cmp byte [epnumber], 0 2703 00000CDC 7613 jna short B_05 2704 2705 00000CDE BE[F35E] mov si, msg_ext_partition_exists 2706 00000CE1 E8B60E call print_msg 2707 2708 00000CE4 BE[E355] mov si, msg_press_any_key 2709 00000CE7 E8B00E call print_msg 2710 2711 00000CEA 30E4 xor ah, ah 2712 00000CEC CD16 int 16h 2713 2714 00000CEE E916F7 jmp A_42 2715 B_05: 2716 00000CF1 803E[E56F]00 cmp byte [ppcount], 0 ; primary partition count 2717 00000CF6 7746 ja short B_10 2718 2719 ; 09/02/2019 2720 00000CF8 BE[A84F] mov si, msg_ext_partition_error 2721 00000CFB E89C0E call print_msg 2722 B_06: 2723 00000CFE BE[E355] mov si, msg_press_any_key 2724 00000D01 E8960E call print_msg 2725 2726 00000D04 30E4 xor ah, ah 2727 00000D06 CD16 int 16h 2728 2729 00000D08 C606[F96C]01 mov byte [pp_type], 1 2730 2731 00000D0D E8CDFA call cpi_2 ; 15/02/2019 2732 00000D10 EB95 jmp short B_02 2733 2734 B_58: 2735 ; 26/10/2020 2736 00000D12 803E[5A68]80 cmp byte [DrvNum], 80h ; hd0 ? 2737 00000D17 7707 ja short B_59 ; Do not check primary dos partition count 2738 ; The second hard disk may contain extended partition without 2739 ; a primary dos partition 2740 00000D19 803E[E56F]00 cmp byte [ppcount], 0 ; primary dos partition count 2741 00000D1E 760A jna short B_07 2742 B_59: 2743 00000D20 803E[E76F]00 cmp byte [epnumber], 0 2744 ; is there an extended partition ? 2745 00000D25 7603 jna short B_07 ; no 2746 00000D27 E9ACF7 jmp create_logical_drives 2747 B_07: 2748 00000D2A BE[164A] mov si, msg_create_logical_drive_h 2749 00000D2D E86A0E call print_msg 2750 2751 00000D30 BE[E74F] mov si, msg_logical_drive_error 2752 00000D33 E8640E call print_msg 2753 00000D36 EBC6 jmp short B_06 2754 2755 ; mov si, msg_use_entire_ep_space 2756 ; jmp short B_12 2757 2758 B_08: 2759 00000D38 BE[0B4B] mov si, msg_create_nondos_partition_h 2760 B_09: 2761 00000D3B E85C0E call print_msg 2762 B_10: 2763 ; 15/02/2019 2764 ;cmp byte [newdisk], 0 2765 ;ja short B_11 2766 2767 00000D3E 803E[E46F]00 cmp byte [pcount], 0 ; (valid) partition count 2768 00000D43 7605 jna short B_11 2769 2770 00000D45 BE[404E] mov si, msg_use_all_space 2771 00000D48 EB03 jmp short B_12 2772 B_11: 2773 00000D4A BE[194E] mov si, msg_use_whole_disk ; partition size: whole disk 2774 B_12: 2775 00000D4D E84A0E call print_msg 2776 B_13: 2777 00000D50 30E4 xor ah, ah 2778 00000D52 CD16 int 16h 2779 2780 00000D54 3C1B cmp al, 27 ; ESCAPE key 2781 ;;je _crlf_exit 2782 00000D56 0F84ADF6 je A_42 ; 25/02/2019 2783 00000D5A 24DF and al, 0DFh 2784 00000D5C 3C4E cmp al, 'N' 2785 00000D5E 740D je short B_14 ;02/03/2019 2786 00000D60 3C59 cmp al, 'Y' 2787 00000D62 75EC jne short B_13 2788 2789 00000D64 FE06[F86C] inc byte [wholedisk] 2790 2791 ; 02/03/2019 2792 00000D68 BE[C05C] mov si, _msg_YES 2793 ;call print_msg 2794 00000D6B EB03 jmp short B_15 2795 B_14: 2796 00000D6D BE[C65C] mov si, _msg_NO 2797 B_15: ; 06/03/2019 2798 00000D70 E8270E call print_msg 2799 2800 ; 15/02/2019 2801 00000D73 29DB sub bx, bx 2802 ;cmp byte [newdisk], bl ; 0 2803 ;ja short B_16 ; 23/02/2019 2804 ; 19/10/2020 2805 ;cmp byte [pcount], 0 2806 ; 03/11/2020 2807 00000D75 381E[E46F] cmp byte [pcount], bl ; 0 2808 00000D79 7608 jna short B_16 ; [pcount] = 0 (newdisk, empty pt) 2809 00000D7B 381E[F86C] cmp byte [wholedisk], bl ; 0 2810 00000D7F 0F871C01 ja B_27 ; 23/02/2019 2811 B_16: 2812 ; 08/02/2019 2813 ;sub bx, bx 2814 00000D83 A1[5E68] mov ax, [total_sectors] 2815 00000D86 8B16[6068] mov dx, [total_sectors+2] 2816 00000D8A 2B06[863F] sub ax, [sectors] 2817 00000D8E 19DA sbb dx, bx ; sbb dx, 0 2818 2819 00000D90 A3[F46C] mov [pp_Sectors], ax ; = [total_sectors] - [sectors] 2820 00000D93 8916[F66C] mov [pp_Sectors+2], dx ; = [total_sectors+2] - carry bit 2821 B_17: 2822 00000D97 381E[F86C] cmp byte [wholedisk], bl ; 0 2823 00000D9B 0F870701 ja B_28 ; 09/02/2019 2824 B_18: 2825 ; clear screen 2826 00000D9F B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 2827 00000DA2 CD10 int 10h 2828 2829 ; 04/11/2020 2830 00000DA4 803E[F96C]01 cmp byte [pp_type], 1 ; primary dos partition ? 2831 00000DA9 7405 je short B_61 2832 ; "Create Partition" 2833 00000DAB BE[8145] mov si, msg_create_partition_h 2834 00000DAE EB03 jmp short B_62 2835 B_61: 2836 ; "Create DOS partition" 2837 00000DB0 BE[2C48] mov si, msg_create_dos_partition_h ; header 2838 B_62: 2839 00000DB3 E8E40D call print_msg 2840 00000DB6 BE[BD4C] mov si, msg_create_trdos_partition_s ; size options 2841 00000DB9 E8DE0D call print_msg 2842 B_19: 2843 00000DBC 30E4 xor ah, ah 2844 00000DBE CD16 int 16h 2845 2846 ; 24/02/2019 2847 00000DC0 3C1B cmp al, 27 ; ESCAPE key 2848 00000DC2 0F8441F6 je A_42 ; Cancel 2849 2850 00000DC6 3C20 cmp al, 32 ; SPACE key 2851 00000DC8 7521 jne short B_21 2852 2853 ; Entire space 2854 00000DCA A1[F46C] mov ax, [pp_Sectors] 2855 00000DCD 8B16[F66C] mov dx, [pp_Sectors+2] 2856 2857 00000DD1 C606[F86C]01 mov byte [wholedisk], 1 ; 09/02/2019 2858 00000DD6 EB5A jmp short B_23 2859 2860 B_60: ; 31/10/2020 2861 00000DD8 75C5 jnz short B_18 ; ESCape (return to options menu) 2862 ; partition size input is ZERO ! 2863 B_20: 2864 ; ZERO partition size message 2865 00000DDA BE[D35A] mov si, msg_zero_partition_size 2866 00000DDD E8BA0D call print_msg 2867 2868 00000DE0 30E4 xor ah, ah 2869 00000DE2 CD16 int 16h 2870 00000DE4 3C1B cmp al, 27 ; ESCAPE key 2871 00000DE6 75B7 jne short B_18 ; Retry 2872 2873 ; 19/10/2020 2874 00000DE8 E9BCF9 jmp _crlf_exit ; exit 2875 2876 B_21: 2877 00000DEB C606[066D]25 mov byte [pSize_unit], '%' 2878 00000DF0 3C25 cmp al, '%' 2879 00000DF2 7422 je short B_22 2880 00000DF4 C606[066D]53 mov byte [pSize_unit], 'S' 2881 00000DF9 3C0D cmp al, 13 ; 0Dh, Carriage Return key 2882 00000DFB 7419 je short B_22 2883 00000DFD 24DF and al, 0DFh 2884 00000DFF 3C53 cmp al, 'S' 2885 00000E01 7413 je short B_22 2886 00000E03 A2[066D] mov [pSize_unit], al 2887 00000E06 3C4B cmp al, 'K' 2888 00000E08 740C je short B_22 2889 00000E0A 3C4D cmp al, 'M' 2890 00000E0C 7408 je short B_22 2891 00000E0E 3C47 cmp al, 'G' 2892 00000E10 7404 je short B_22 2893 00000E12 3C43 cmp al, 'C' 2894 00000E14 75A6 jne short B_19 2895 B_22: 2896 00000E16 C606[3B64]73 mov byte [msg_sectors_crlf_s], 's' ; " sectors" 2897 2898 00000E1B E8EC0F call partition_size_input 2899 ;jc _crlf_exit ; exit if partition size input is 0 2900 ;jc short B_20 2901 ; 29/10/2020 2902 ;jnc short B_60 2903 ;jz short B_20 ; partition size input is ZERO ! 2904 ;jmp short B_18 ; ESCape (return to options menu) 2905 ; 31/10/2020 2906 00000E1E 72B8 jc short B_60 ; ESC or zero partition size 2907 ;B_60: 2908 00000E20 21DB and bx, bx ; bx_dx_ax = partition size 2909 ;jnz short B_29 2910 ; 23/02/2019 2911 00000E22 7540 jnz short B_24 ; invalid! (use maximum available sectors) 2912 2913 ; 08/02/2019 2914 00000E24 09D2 or dx, dx 2915 00000E26 750A jnz short B_23 ; proper size (for now) 2916 2917 00000E28 8B1E[1C6D] mov bx, [min_sectors] ; minimum sectors 2918 00000E2C 39C3 cmp bx, ax 2919 00000E2E 7602 jna short B_23 ; proper size (for now) 2920 2921 ; invalid! (use minimum sectors or sectors per cylinder) 2922 00000E30 89D8 mov ax, bx 2923 B_23: 2924 ; 09/02/2019 2925 ; save dx,ax 2926 00000E32 8916[246D] mov [ppn_Sectors+2], dx 2927 00000E36 A3[226D] mov [ppn_Sectors], ax 2928 2929 ; write partition size 2930 ;push dx 2931 ;push ax 2932 ;mov si, msg_partition_sectors + 7 ; max. 8 digits 2933 ; 06/11/2020 2934 00000E39 BE[136D] mov si, msg_partition_sectors + 10 ; max. 11 digits 2935 00000E3C E81A0E call bin_to_decimal 2936 ; ds:si = beginning of decimal number text 2937 00000E3F E8580D call print_msg 2938 00000E42 BE[3464] mov si, msg_sectors_crlf 2939 00000E45 E8520D call print_msg 2940 ;pop ax 2941 ;pop dx 2942 2943 00000E48 803E[F86C]00 cmp byte [wholedisk], 0 2944 00000E4D 775E ja short B_29 ; 09/02/2019 2945 2946 ; restore ax,dx 2947 00000E4F A1[226D] mov ax, [ppn_Sectors] 2948 00000E52 8B16[246D] mov dx, [ppn_Sectors+2] 2949 2950 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2951 ; select whole disk 2952 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2953 2954 ; select whole disk 2955 ; if partition size > disk size 2956 00000E56 3B16[F66C] cmp dx, [pp_Sectors+2] 2957 00000E5A 7708 ja short B_24 2958 00000E5C 724F jb short B_29 2959 00000E5E 3B06[F46C] cmp ax, [pp_Sectors] 2960 00000E62 7649 jna short B_29 2961 B_24: 2962 ;cmp byte [newdisk], 0 2963 ;jna short B_30 2964 ; 19/10/2020 2965 00000E64 803E[E46F]00 cmp byte [pcount], 0 2966 00000E69 7767 ja short B_30 2967 2968 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2969 ; "use whole disk or go to back" question 2970 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2971 2972 00000E6B BE[3E4F] mov si, msg_partition_size_overs 2973 B_25: 2974 00000E6E E8290D call print_msg 2975 B_26: 2976 00000E71 30E4 xor ah, ah 2977 00000E73 CD16 int 16h 2978 2979 00000E75 3C1B cmp al, 27 ; ESCAPE key 2980 ;je B_01 2981 00000E77 0F8424FF je B_18 ; 09/02/2019 2982 00000E7B 3C0D cmp al, 13 ; ENTER (Carriage Return) key 2983 00000E7D 75F2 jne short B_26 2984 2985 00000E7F FE06[F86C] inc byte [wholedisk] 2986 2987 ; 24/02/2019 2988 ;cmp byte [newdisk], 0 2989 ;ja short B_27 2990 00000E83 803E[E46F]00 cmp byte [pcount], 0 ; (valid) partition count 2991 00000E88 7615 jna short B_27 ; no 2992 2993 00000E8A 8B1E[8270] mov bx, [c_fspc_offset] 2994 00000E8E 8B87[3870] mov ax, [free_space.sectors_unused+bx] 2995 00000E92 8B97[3A70] mov dx, [free_space.sectors_unused+bx+2] 2996 00000E96 A3[F46C] mov [pp_Sectors], ax 2997 00000E99 8916[F66C] mov [pp_Sectors+2], dx 2998 00000E9D EB07 jmp short B_28 2999 B_27: 3000 ; 09/02/2019 3001 00000E9F 8B16[F66C] mov dx, [pp_Sectors+2] 3002 00000EA3 A1[F46C] mov ax, [pp_Sectors] 3003 B_28: 3004 00000EA6 8916[246D] mov [ppn_Sectors+2], dx 3005 00000EAA A3[226D] mov [ppn_Sectors], ax 3006 B_29: 3007 00000EAD 803E[F96C]05 cmp byte [pp_type], 5 3008 00000EB2 0F853601 jne B_51 3009 3010 00000EB6 803E[E56F]00 cmp byte [ppcount], 0 ; primary partition count 3011 00000EBB 0F87C500 ja B_45 3012 3013 00000EBF BE[A84F] mov si, msg_ext_partition_error 3014 00000EC2 E8D50C call print_msg 3015 00000EC5 BE[214F] mov si, msg_any_key_to_retry 3016 00000EC8 E8CF0C call print_msg 3017 3018 ; 09/02/2019 3019 00000ECB 30E4 xor ah, ah 3020 00000ECD CD16 int 16h 3021 3022 ;jmp B_01 3023 00000ECF E90BF9 jmp cpi_2 3024 3025 B_30: 3026 ; clear screen 3027 00000ED2 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 3028 00000ED5 CD10 int 10h 3029 3030 00000ED7 BE[2C48] mov si, msg_create_dos_partition_h ; header 3031 00000EDA E8BD0C call print_msg 3032 3033 00000EDD BE[DF5D] mov si, msg_partition_size_limit 3034 00000EE0 E8B70C call print_msg 3035 3036 00000EE3 8B1E[8270] mov bx, [c_fspc_offset] 3037 3038 00000EE7 803E[066D]53 cmp byte [pSize_unit], 'S' 3039 00000EEC 7415 je short B_31 3040 00000EEE 803E[066D]4B cmp byte [pSize_unit], 'K' 3041 00000EF3 740E je short B_31 3042 3043 00000EF5 803E[066D]25 cmp byte [pSize_unit], '%' 3044 00000EFA 7469 je short B_41 3045 3046 00000EFC 803E[066D]43 cmp byte [pSize_unit], 'C' 3047 00000F01 7479 je B_44 3048 B_31: 3049 ; 'S', 'K' 3050 00000F03 81C3[3870] add bx, free_space.sectors_unused 3051 00000F07 8B07 mov ax, [bx] 3052 00000F09 8B5702 mov dx, [bx+2] 3053 3054 00000F0C B90A00 mov cx, 10 3055 00000F0F 89E5 mov bp, sp 3056 B_32: 3057 00000F11 E869FD call div32 3058 00000F14 53 push bx 3059 00000F15 09D2 or dx, dx 3060 00000F17 75F8 jnz short B_32 3061 00000F19 83F809 cmp ax, 9 3062 00000F1C 77F3 ja short B_32 3063 B_33: 3064 00000F1E BB0700 mov bx, 07h 3065 00000F21 09C0 or ax, ax 3066 00000F23 7501 jnz short B_35 3067 B_34: 3068 00000F25 58 pop ax 3069 B_35: 3070 00000F26 0430 add al, '0' 3071 B_36: 3072 00000F28 B40E mov ah, 0Eh 3073 ;mov bx, 07h 3074 00000F2A CD10 int 10h ; write character (as tty) 3075 3076 00000F2C 39EC cmp sp, bp 3077 00000F2E 72F5 jb short B_34 3078 3079 00000F30 803E[066D]53 cmp byte [pSize_unit], 'S' 3080 00000F35 7422 je short B_38 3081 00000F37 803E[066D]4B cmp byte [pSize_unit], 'K' 3082 00000F3C 741B je short B_38 3083 3084 00000F3E 803E[066D]25 cmp byte [pSize_unit], '%' 3085 00000F43 7508 jne short B_37 3086 3087 ; 24/02/2019 3088 00000F45 3C25 cmp al, '%' 3089 00000F47 7416 je short B_40 3090 00000F49 B025 mov al, '%' 3091 00000F4B EBDB jmp short B_36 3092 B_37: 3093 00000F4D 803E[066D]43 cmp byte [pSize_unit], 'C' 3094 00000F52 7505 jne short B_38 3095 3096 00000F54 BE[7B5E] mov si, msg_cylinders 3097 00000F57 EB03 jmp short B_39 3098 B_38: 3099 00000F59 BE[865E] mov si, msg_sectors 3100 B_39: 3101 00000F5C E83B0C call print_msg 3102 B_40: 3103 00000F5F BE[2C5E] mov si, msg_partition_size_limit_r 3104 ;call print_msg 3105 3106 00000F62 E909FF jmp B_25 3107 3108 B_41: 3109 ; '%' 3110 00000F65 81C3[3670] add bx, free_space.percent_unused 3111 00000F69 8B07 mov ax, [bx] 3112 B_42: 3113 00000F6B 89E5 mov bp, sp 3114 00000F6D B90A00 mov cx, 10 3115 B_43: 3116 00000F70 31D2 xor dx, dx 3117 ;mov cx, 10 3118 00000F72 F7F1 div cx 3119 00000F74 52 push dx 3120 00000F75 83F809 cmp ax, 9 3121 00000F78 77F6 ja short B_43 3122 00000F7A EBA2 jmp short B_33 3123 B_44: 3124 ; 'C' 3125 00000F7C 81C3[3070] add bx, free_space.space 3126 00000F80 8B07 mov ax, [bx] 3127 00000F82 EBE7 jmp short B_42 3128 3129 B_45: 3130 ; 23/02/2019 3131 00000F84 8B1E[8270] mov bx, [c_fspc_offset] 3132 00000F88 8B87[3270] mov ax, [bx+free_space.start] 3133 3134 ; set free space start cylinder to 1 if it is 0 3135 00000F8C 09C0 or ax, ax 3136 00000F8E 750F jnz short B_46 3137 3138 00000F90 B005 mov al, 5 ; Get free space for extended partition 3139 00000F92 E8AD15 call find_part_free_space 3140 3141 00000F95 891E[8270] mov [c_fspc_offset], bx 3142 3143 ; 19/10/2020 3144 00000F99 21C9 and cx, cx 3145 00000F9B 0F8428F5 jz cp_3 ; there is not free space on disk 3146 B_46: 3147 ; 24/02/2019 3148 00000F9F E81100 call partition_size_fixup_x 3149 00000FA2 0F822CFF jc B_30 3150 3151 ; 16/02/2019 3152 00000FA6 E83EFB call create_extended_partition 3153 ; must be called after 'find_part_free_space'. 3154 ; 24/02/2019 3155 00000FA9 E87C11 call show_selected_partition 3156 00000FAC E9BE00 jmp C_02 3157 3158 partition_size_fixup: 3159 ; 24/02/2019 3160 00000FAF 8B1E[8270] mov bx, [c_fspc_offset] 3161 partition_size_fixup_x: 3162 ; 19/10/2020 3163 3164 ;cmp byte [newdisk], 0 3165 ;ja short B_50 3166 3167 00000FB3 803E[E46F]00 cmp byte [pcount], 0 ; (valid) partition count 3168 00000FB8 7631 jna short B_50 3169 3170 00000FBA 81C3[3870] add bx, free_space.sectors_unused 3171 00000FBE 8B07 mov ax, [bx] 3172 00000FC0 8B5702 mov dx, [bx+2] 3173 3174 00000FC3 3B16[246D] cmp dx, [ppn_Sectors+2] 3175 00000FC7 7222 jb short B_50 ; 24/02/2019 3176 00000FC9 7708 ja short B_47 3177 00000FCB 3B06[226D] cmp ax, [ppn_Sectors] 3178 00000FCF 721A jb short B_50 ; 24/02/2019 3179 00000FD1 7411 je short B_49 3180 3181 B_47: 3182 ; 19/02/2019 3183 00000FD3 A1[226D] mov ax, [ppn_Sectors] 3184 B_48: 3185 00000FD6 8B16[246D] mov dx, [ppn_Sectors+2] 3186 3187 ; 18/02/2019 3188 3189 ; check for best fit 3190 ; (leave max. available space to next time if 3191 ; another space/gap fits to partition size request.) 3192 3193 00000FDA E87D17 call find_enough_free_sectors 3194 ; CX = Free space index (0 to 4) 3195 ; DX:AX = First available space which fits to request 3196 ;mov bx, cx 3197 ;shl bl, 4 ; * 16 ; * Free space structure size 3198 ;mov [c_fspc_offset], bx 3199 3200 ; 22/02/2019 3201 00000FDD C0E104 shl cl, 4 3202 00000FE0 890E[8270] mov [c_fspc_offset], cx 3203 3204 ;add bx, free_space.sectors_unused 3205 ;mov ax, [bx] 3206 ;mov dx, [bx+2] 3207 B_49: 3208 ; Save max. available space 3209 00000FE4 A3[F46C] mov [pp_Sectors], ax 3210 00000FE7 8916[F66C] mov [pp_Sectors+2], dx 3211 B_50: 3212 00000FEB C3 retn 3213 3214 B_51: 3215 ; 24/02/2019 3216 00000FEC E8C0FF call partition_size_fixup 3217 00000FEF 0F82DFFE jc B_30 3218 3219 ; 16/02/2019 3220 ; Force cylinder boundary alignment except 3221 ; sectors ('S') and kilobytes ('K') as sizing unit. 3222 3223 00000FF3 C606[8470]59 mov byte [cylinder_boundary], 'Y' ; Default 3224 ; sizing unit is one of 3225 ; 'cylinders','megabytes','gigabytes' 3226 ; and boundary alignment is yes for them. 3227 00000FF8 A0[066D] mov al, [pSize_unit] 3228 3229 ;cmp byte [pSize_unit], 'S' ; Sectors 3230 00000FFB 3C53 cmp al, 'S' 3231 00000FFD 7404 je short B_52 3232 3233 ;cmp byte [pSize_unit], 'K' ; Kilobytes 3234 00000FFF 3C4B cmp al, 'K' 3235 00001001 752F jne short B_56 3236 B_52: 3237 ; Sizing unit is one of 'sectors' and/or 'kilobytes' 3238 ; and bound aligment will be applied if the answer will be yes. 3239 3240 00001003 BE[3050] mov si, msg_cylinder_boundary_set 3241 00001006 E8910B call print_msg 3242 B_53: 3243 00001009 30E4 xor ah, ah 3244 0000100B CD16 int 16h 3245 ; Cylinder boundary adjusting 3246 0000100D 3C0D cmp al, 13 ; ENTER key 3247 0000100F 74F2 je short B_52 3248 00001011 3C1B cmp al, 27 ; ESCAPE key 3249 00001013 741A je short B_55 ; Align end of the partition only 3250 ; if start of the partition is aligned 3251 ; or it starts at cyl 0, head 1, sect 17 or 63. 3252 ; (End of the partition will be extended to 3253 ; end sector of it's last cylinder if the size 3254 ; will not over [pp_Sectors] value.) 3255 00001015 24DF and al, 0DFh 3256 3257 ; 22/02/2019 3258 00001017 3C59 cmp al, 'Y' 3259 00001019 7508 jne short B_54 3260 3261 0000101B BE[C05C] mov si, _msg_YES 3262 0000101E E8790B call print_msg 3263 3264 ;mov al, 'Y' 3265 ;jmp short B_55 3266 00001021 EB0F jmp short B_56 3267 B_54: 3268 00001023 3C4E cmp al, 'N' 3269 00001025 75E2 jne short B_53 3270 3271 00001027 BE[C65C] mov si, _msg_NO 3272 0000102A E86D0B call print_msg 3273 3274 0000102D B04E mov al, 'N' 3275 ; do not align partition to cylinder boundary 3276 B_55: 3277 0000102F A2[8470] mov [cylinder_boundary], al 3278 B_56: 3279 00001032 E8FCF7 call create_primary_partition 3280 3281 ; 18/02/2019 3282 ;cmp byte [newdisk], 0 3283 ;jna short B_57 3284 3285 ; 19/10/2020 3286 00001035 803E[E46F]00 cmp byte [pcount], 0 3287 0000103A 770E ja short B_57 3288 3289 0000103C 31C0 xor ax, ax ; 0 3290 0000103E 31D2 xor dx, dx ; 0 3291 ; DX_AX = Masterboot Sector = 0 3292 00001040 BB[0256] mov bx, MasterBootBuff 3293 ; ES:BX = Sector Buffer 3294 00001043 E8B90B call write_hd_sector 3295 00001046 0F8247F7 jc print_error_code ; 18/10/2020 3296 B_57: 3297 ; DS:SI = Partition Table Entry address 3298 ; 25/02/2019 3299 0000104A 8936[AA70] mov [pte_address], si ; save PTE address 3300 0000104E E8D710 call show_selected_partition 3301 3302 ;jmp C_01 3303 3304 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3305 ; format question 3306 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3307 3308 C_01: 3309 ;mov si, CRLF 3310 ;call print_msg 3311 3312 00001051 C606[156D]01 mov byte [format_q], 1 3313 3314 00001056 A0[F96C] mov al, [pp_type] 3315 00001059 3C01 cmp al, 1 ; FAT12 (CHS) 3316 0000105B 741D je short C_03 3317 0000105D 3C04 cmp al, 4 ; FAT16 CHS 3318 0000105F 7419 je short C_03 3319 00001061 3C06 cmp al, 6 ; FAT16 BIG CHS 3320 00001063 7415 je short C_03 3321 00001065 3C0B cmp al, 0Bh ; FAT32 CHS 3322 00001067 7411 je short C_03 3323 00001069 3CA1 cmp al, 0A1h ; SINGLIX FS1 3324 0000106B 740D je short C_03 3325 3326 ;cmp al, 71h 3327 ;je short C_03 ; RETRO UNIX 386 3328 3329 ;dec byte [format_q] ; 0 3330 C_02: 3331 0000106D C606[156D]00 mov byte [format_q], 0 ; 24/02/2019 3332 3333 ; NON-DOS partition! 3334 ; Ask for editing PT or exit (continue without formatting) 3335 00001072 BE[B653] mov si, msg_edit_or_exit 3336 00001075 E8220B call print_msg 3337 00001078 EB06 jmp short C_04 3338 C_03: 3339 ; Ask for formatting, editing PT or exit 3340 0000107A BE[4753] mov si, msg_format_stage 3341 0000107D E81A0B call print_msg 3342 C_04: 3343 00001080 BE[8753] mov si, msg_partition_edit 3344 00001083 E8140B call print_msg 3345 C_05: 3346 00001086 28E4 sub ah, ah 3347 00001088 CD16 int 16h 3348 3349 0000108A 3C0D cmp al, 13 3350 0000108C 7435 je short C_08 3351 3352 ;; 07/03/2019 3353 0000108E 3C20 cmp al, 20h ; SPACE 3354 ;je A_21 ; edit partition table option is selected 3355 00001090 7503 jne short C_06 3356 ; 19/10/2020 3357 00001092 E955F1 jmp A_21 3358 C_06: 3359 00001095 3C1B cmp al, 27 ; ESCAPE 3360 00001097 75ED jne short C_05 3361 3362 ; 19/010/2020 3363 00001099 E911F7 jmp _exit 3364 3365 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3366 ; save MBR then exit 3367 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3368 3369 save_mbr_exit: 3370 ; 24/02/2019 3371 0000109C E86E12 call init_partition_table 3372 3373 0000109F E85117 call display_partition_table 3374 3375 000010A2 BE[8755] mov si, CRLF 3376 000010A5 E8F20A call print_msg 3377 3378 000010A8 BE[3B54] mov si, msg_writing_mbr 3379 000010AB E8EC0A call print_msg 3380 3381 000010AE 31C0 xor ax, ax ; 0 3382 000010B0 31D2 xor dx, dx ; 0 3383 ; DX_AX = Masterboot Sector = 0 3384 000010B2 BB[0256] mov bx, MasterBootBuff 3385 ; ES:BX = Sector Buffer 3386 000010B5 E8470B call write_hd_sector 3387 000010B8 7303 jnc short C_07 3388 000010BA E9D4F6 jmp print_error_code ; 18/10/2020 3389 3390 C_07: 3391 000010BD BE[8355] mov si, Msg_OK 3392 ;call print_msg 3393 ; 19/10/2020 3394 ;jmp _exit 3395 000010C0 E9E7F6 jmp _p_exit 3396 3397 C_08: 3398 000010C3 803E[156D]01 cmp byte [format_q], 1 3399 000010C8 72D2 jb short save_mbr_exit 3400 3401 ; 25/02/2019 3402 ; Write MBR without writing message 3403 3404 ; NOTE: This may be second time of MBR writing... 3405 ; but, if partition table is modified, 3406 ; we need to write MBR to disk, here. 3407 ; 3408 ; (Otherwise.. the last created partition would not be recorded.) 3409 3410 000010CA 31C0 xor ax, ax ; 0 3411 000010CC 31D2 xor dx, dx ; 0 3412 ; DX_AX = Masterboot Sector = 0 3413 000010CE BB[0256] mov bx, MasterBootBuff 3414 ; ES:BX = Sector Buffer 3415 000010D1 E82B0B call write_hd_sector 3416 000010D4 0F82B9F6 jc print_error_code ; 18/10/2020 3417 3418 ;; clear screen 3419 ;mov ax, 3 ; set video mode to 03h (80x25 text) 3420 ;int 10h 3421 3422 ; 25/02/2019 3423 000010D8 8B36[AA70] mov si, [pte_address] 3424 3425 ; 18/02/2019 3426 000010DC E84910 call show_selected_partition 3427 3428 000010DF A0[6E53] mov al, [partition_num_chr] 3429 000010E2 A2[2E54] mov [partition_num_txt], al 3430 3431 000010E5 BE[0C54] mov si, msg_format_question 3432 000010E8 E8AF0A call print_msg 3433 C_09: 3434 000010EB 30E4 xor ah, ah 3435 000010ED CD16 int 16h 3436 3437 000010EF 3C1B cmp al, 1Bh ; ESCAPE 3438 000010F1 74A2 je short C_06 3439 3440 000010F3 24DF and al, 0DFh ; capitalization 3441 000010F5 3C59 cmp al, 'Y' 3442 000010F7 740C je short C_10 3443 000010F9 3C4E cmp al, 'N' 3444 000010FB 75EE jne short C_09 3445 000010FD BE[C65C] mov si, _msg_NO 3446 00001100 E8970A call print_msg 3447 ;jmp short C_06 3448 ; 24/02/2019 3449 00001103 EB97 jmp short save_mbr_exit 3450 C_10: 3451 00001105 BE[C05C] mov si, _msg_YES 3452 00001108 E88F0A call print_msg 3453 3454 ; [pp_StartSector] = partition's start sector 3455 ; [pp_Sectors] = partition size including start & end sector 3456 ; [partition_num_chr] = partition number + '0' 3457 ; [pp_type] = partition type (for TRDOS 386 boot sector) 3458 3459 0000110B 8926[6868] mov [old_sp], sp 3460 3461 0000110F 8A16[F96C] mov dl, [pp_type] 3462 ; DL = partition type (file system ID) 3463 ;dec dl 3464 ;jz FAT12_hd_format 3465 00001113 80FA01 cmp dl, 1 ; 14/09/2020 (BugFix) 3466 00001116 0F86E405 jna FAT12_hd_format 3467 ;cmp dl, 4 3468 ;je FAT16_hd_format 3469 ;cmp dl, 6 3470 ;je FAT16_hd_format 3471 0000111A 80FA0B cmp dl, 0Bh 3472 0000111D 0F82DA03 jb FAT16_hd_format 3473 ;je short FAT32_hd_format 3474 ;cmp dl, 0Ch ; 14/09/2020 3475 00001121 0F877A07 ja SINGLIX_hd_format 3476 3477 ;cmp dl, 0A1h 3478 ;je SINGLIX_hd_format 3479 ;jb RUNIX386_hd_format ; dl = 071h 3480 3481 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3482 ; FAT32 FORMATTING 3483 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3484 3485 ; 08/02/2019 (Modified for -only- FAT32 CHS partitions) 3486 FAT32_hd_format: 3487 ; 29/01/2026 3488 00001125 B80C00 mov ax, 000Ch ; db 0Ch, 00h ; 'or al, 0' 3489 00001128 38C2 cmp dl, al ; 0Ch 3490 0000112A 7403 je short FAT32_lba_format 3491 0000112C B80BC0 mov ax, 0C00Bh ; db 0Bh, 0C0h ; 'or ax, ax' 3492 FAT32_lba_format: 3493 ; Put TRDOS 386 FAT32 partition magic word 3494 ; at offset 5Ah, in TRDOS386 FAT32 boot sector 0. 3495 0000112F BD[7333] mov bp, TRDOS_FAT32_hd_bs 3496 00001132 8D7E03 lea di, [bp+3] 3497 00001135 BE[4064] mov si, bs_oem_name 3498 00001138 B90400 mov cx, 4 3499 0000113B F3A5 rep movsw 3500 ; 29/01/2026 3501 0000113D 89465A mov [bp+5Ah], ax ; [loc_5A] 3502 ;mov word [bp+5Ah], 0C00Bh ; 08/02/2019 3503 00001140 A1[863F] mov ax, [sectors] 3504 00001143 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 3505 00001146 A1[883F] mov ax, [heads] 3506 00001149 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 3507 0000114C A1[F06C] mov ax, [pp_StartSector] 3508 0000114F 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 3509 00001152 A1[F26C] mov ax, [pp_StartSector+2] 3510 00001155 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 3511 ;mov ax, [pp_Sectors] 3512 00001158 A1[226D] mov ax, [ppn_Sectors] ; 16/02/2019 3513 0000115B 894620 mov [bp+20h], ax ; [BPB_TotSec32] 3514 ;mov dx, [pp_Sectors+2] 3515 0000115E 8B16[246D] mov dx, [ppn_Sectors+2] ; 16/02/2019 3516 00001162 895622 mov [bp+22h], dx ; [BPB_TotSec32+2] 3517 3518 ; Sectors per cluster calculation 3519 ; (According to MS FAT32 FS specification.) 3520 00001165 B108 mov cl, 8 ; 8 sectors per cluster 3521 00001167 83FA08 cmp dx, 8 ; >= 532480 sectors 3522 0000116A 7709 ja short FAT32_f_2 ; 8 sectors per cluster 3523 0000116C 7205 jb short FAT32_f_1 ; 1 sector per cluster 3524 0000116E 3D0020 cmp ax, 2000h ; dx_ax = (8*65536)+8192 3525 00001171 7302 jnb short FAT32_f_2 ; 12/09/2020 (BugFix) 3526 FAT32_f_1: 3527 00001173 B101 mov cl, 1 ; 1 sector per cluster 3528 FAT32_f_2: 3529 00001175 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 3530 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 3531 ;mov word [bp+0Eh], 32 ; [BPB_RsvdSecCnt] 3532 3533 ; Calculating FAT size in sectors 3534 ; (According to MS FAT32 FS Specification, 2000) 3535 3536 ; DX_AX = partition (volume) size in sectors 3537 00001178 2B460E sub ax, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 3538 0000117B 83DA00 sbb dx, 0 3539 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 3540 ; RootDirsectors) 3541 ; RootDirSectors = 0 (for FAT32 FS) 3542 0000117E 89CB mov bx, cx ; ch = 0 3543 00001180 C1E308 shl bx, 8 ; * 256 3544 00001183 8A4E10 mov cl, [bp+10h] ; [BPB_NumFATs] 3545 00001186 01CB add bx, cx 3546 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 3547 00001188 D1EB shr bx, 1 3548 ; TmpVal2 = TmpVal2/2 3549 0000118A 89D9 mov cx, bx 3550 0000118C 4B dec bx ; TmpVal2-1 3551 0000118D 01D8 add ax, bx 3552 0000118F 83D200 adc dx, 0 3553 00001192 E8E8FA call div32 3554 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 3555 ; DX_AX = FAT size in sectors 3556 00001195 894624 mov [bp+24h], ax ; [BPB_FATSz32] 3557 00001198 895626 mov [bp+26h], dx ; [BPB_FATSz32+2] 3558 ; * 2 3559 0000119B 89D3 mov bx, dx 3560 0000119D 01C0 add ax, ax 3561 0000119F 11D3 adc bx, dx 3562 ; BX_AX = [BPB_NumFATs] * [BPB_FATSz32] 3563 000011A1 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 3564 000011A4 01C1 add cx, ax 3565 000011A6 83D300 adc bx, 0 3566 ; BX_CX = [BPB_RsvdSecCnt]+[BPB_NumFATs]*[BPB_FATSz32] 3567 000011A9 8B4620 mov ax, [bp+20h] ; [BPB_TotSec32] 3568 000011AC 8B5622 mov dx, [bp+22h] ; [BPB_TotSec32+2] 3569 000011AF 29C8 sub ax, cx 3570 000011B1 19DA sbb dx, bx 3571 000011B3 890E[6A6A] mov [data_start], cx 3572 000011B7 891E[6C6A] mov [data_start+2], bx 3573 ; DX_AX = Data sectors 3574 000011BB A3[6E6A] mov [data_sectors], ax 3575 000011BE 8916[706A] mov [data_sectors+2], dx 3576 000011C2 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 3577 000011C5 30ED xor ch, ch 3578 000011C7 E8B3FA call div32 ; DX_AX/CX 3579 ; DX_AX = Count of clusters (rounded down) 3580 000011CA A3[726A] mov [cluster_count], ax 3581 000011CD 8916[746A] mov [cluster_count+2], dx 3582 3583 000011D1 8D7E47 lea di, [bp+71] ; [BS_VolLab] 3584 000011D4 E89B01 call write_volume_name 3585 000011D7 8D7643 lea si, [bp+67] ; [BS_VolID] 3586 000011DA E8F401 call write_volume_serial 3587 000011DD E80503 call write_cluster_count 3588 3589 000011E0 E87502 call write_formatting_msg 3590 000011E3 B000 mov al, 0 3591 000011E5 E8D102 call write_format_percent_x 3592 3593 000011E8 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 3594 000011EB 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 3595 000011EE 0106[6A6A] add [data_start], ax 3596 000011F2 1116[6C6A] adc [data_start+2], dx 3597 FAT32_f_3: 3598 ; DX_AX = FAT32 Boot Sector address 3599 000011F6 BB[7333] mov bx, TRDOS_FAT32_hd_bs 3600 ; ES:BX = Boot Sector 1 Buffer 3601 000011F9 E8030A call write_hd_sector 3602 000011FC 0F82CD02 jc formatting_error 3603 00001200 E87902 call write_format_percent 3604 00001203 83C001 add ax, 1 3605 00001206 83D200 adc dx, 0 3606 00001209 BB[5666] mov bx, HDFORMAT_FSINFO_BUFF 3607 ; ES:BX = FS INFO Sector Buffer (= BS+1) 3608 0000120C E8F009 call write_hd_sector 3609 0000120F 0F82BA02 jc formatting_error 3610 00001213 E86602 call write_format_percent 3611 00001216 83C001 add ax, 1 3612 00001219 83D200 adc dx, 0 3613 0000121C BB[7335] mov bx, TRDOS_FAT32_hd_bs + 512 3614 ; ES:BX = Boot Sector 2 Buffer 3615 0000121F E8DD09 call write_hd_sector 3616 00001222 0F82A702 jc formatting_error 3617 00001226 E85302 call write_format_percent 3618 00001229 B90300 mov cx, 3 3619 FAT32_f_4: 3620 0000122C 51 push cx 3621 0000122D 83C001 add ax, 1 3622 00001230 83D200 adc dx, 0 3623 00001233 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 3624 00001236 E8C609 call write_hd_sector 3625 00001239 0F829002 jc formatting_error 3626 0000123D E83C02 call write_format_percent 3627 00001240 59 pop cx 3628 00001241 FEC9 dec cl 3629 00001243 75E7 jnz short FAT32_f_4 3630 00001245 83C001 add ax, 1 3631 00001248 83D200 adc dx, 0 3632 0000124B 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 3633 0000124E 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 3634 00001251 83C10C add cx, 12 3635 00001254 83D300 adc bx, 0 3636 ; write BACKUP sectors 3637 ; (6,7,8 boot+fsi and 9,10,11 empty sectors) 3638 00001257 39DA cmp dx, bx 3639 00001259 729B jb short FAT32_f_3 3640 0000125B 39C8 cmp ax, cx 3641 0000125D 7297 jb short FAT32_f_3 3642 ; write remain part of reserved sectors 3643 0000125F 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 3644 00001262 83E90C sub cx, 12 3645 00001265 7618 jna short FAT32_f_6 3646 FAT32_f_5: 3647 00001267 51 push cx 3648 00001268 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 3649 0000126B E89109 call write_hd_sector 3650 0000126E 0F825B02 jc formatting_error 3651 00001272 E80702 call write_format_percent 3652 00001275 83C001 add ax, 1 3653 00001278 83D200 adc dx, 0 3654 0000127B 59 pop cx 3655 0000127C 49 dec cx 3656 0000127D 75E8 jnz short FAT32_f_5 3657 FAT32_f_6: 3658 ; write FAT sectors 3659 0000127F 8B0E[6A6A] mov cx, [data_start] ; lba/abs addr 3660 00001283 8B1E[6C6A] mov bx, [data_start+2] ; lba/abs addr 3661 00001287 53 push bx 3662 00001288 51 push cx 3663 00001289 BB[6A68] mov bx, HDFORMAT_FATBUFFER 3664 ; ES:BX = FAT Sector Buffer 3665 0000128C 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 3666 0000128F B5FF mov ch, 0FFh 3667 00001291 890F mov [bx], cx 3668 00001293 88E9 mov cl, ch ; cx = 0FFFFh 3669 00001295 894F02 mov [bx+2], cx 3670 00001298 894F04 mov [bx+4], cx 3671 0000129B 894F06 mov [bx+6], cx 3672 ; Root dir cluster number = 2 3673 ; 0FFFFFFFh = end of cluster chain 3674 0000129E 894F08 mov [bx+8], cx ; 0FFFFh 3675 000012A1 80E50F and ch, 0Fh 3676 000012A4 894F0A mov [bx+10], cx ; 0FFFh 3677 ;inc cx 3678 000012A7 E85509 call write_hd_sector 3679 000012AA 0F821F02 jc formatting_error 3680 000012AE E8CB01 call write_format_percent 3681 ;mov bx, HDFORMAT_FATBUFFER 3682 000012B1 B90000 mov cx, 0 3683 000012B4 890F mov [bx], cx 3684 000012B6 894F02 mov [bx+2], cx 3685 000012B9 894F04 mov [bx+4], cx 3686 000012BC 894F06 mov [bx+6], cx 3687 000012BF 894F08 mov [bx+8], cx 3688 000012C2 894F0A mov [bx+10], cx 3689 000012C5 EB0F jmp short FAT32_f_8 3690 FAT32_f_7: 3691 000012C7 53 push bx 3692 000012C8 51 push cx 3693 000012C9 BB[6A68] mov bx, HDFORMAT_FATBUFFER 3694 000012CC E83009 call write_hd_sector 3695 000012CF 0F82FA01 jc formatting_error 3696 000012D3 E8A601 call write_format_percent 3697 FAT32_f_8: 3698 000012D6 59 pop cx 3699 000012D7 5B pop bx 3700 000012D8 83C001 add ax, 1 3701 000012DB 83D200 adc dx, 0 3702 000012DE 39DA cmp dx, bx 3703 000012E0 72E5 jb short FAT32_f_7 3704 000012E2 39C8 cmp ax, cx 3705 000012E4 72E1 jb short FAT32_f_7 3706 3707 ; write root directory (1st cluster) 3708 ; as empty sectors 3709 000012E6 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 3710 000012E9 30ED xor ch, ch 3711 000012EB 290E[6E6A] sub [data_sectors], cx 3712 000012EF 831E[706A]00 sbb word [data_sectors+2], 0 3713 FAT32_f_9: 3714 000012F4 51 push cx 3715 000012F5 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 3716 000012F8 E80409 call write_hd_sector 3717 000012FB 0F82CE01 jc formatting_error 3718 000012FF E87A01 call write_format_percent 3719 00001302 83C001 add ax, 1 3720 00001305 83D200 adc dx, 0 3721 00001308 59 pop cx 3722 00001309 FEC9 dec cl 3723 0000130B 75E7 jnz short FAT32_f_9 3724 3725 ; write DATA sectors 3726 ; (after root directory 1st cluster) 3727 0000130D 8B0E[6E6A] mov cx, [data_sectors] 3728 00001311 8B1E[706A] mov bx, [data_sectors+2] 3729 ; NOTE: Partition size must be >= 512 MB 3730 ; for FAT32 FS ((BX >= 15)) 3731 FAT32_f_10: 3732 00001315 53 push bx 3733 00001316 51 push cx 3734 00001317 BB[5664] mov bx, HDFORMAT_SECBUFFER 3735 0000131A E8E208 call write_hd_sector 3736 0000131D 0F82AC01 jc formatting_error 3737 00001321 E85801 call write_format_percent 3738 00001324 59 pop cx 3739 00001325 5B pop bx 3740 00001326 83C001 add ax, 1 3741 00001329 83D200 adc dx, 0 3742 0000132C 49 dec cx 3743 0000132D 75E6 jnz short FAT32_f_10 3744 0000132F 4B dec bx 3745 00001330 75E3 jnz short FAT32_f_10 3746 3747 ; If there are, format remain sectors which are 3748 ; at beyond of data clusters, with zero bytes. 3749 3750 00001332 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 3751 00001335 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 3752 FAT16_f_18: 3753 00001338 034E20 add cx, [bp+20h] ; [BPB_TotSec32] 3754 0000133B 135E22 adc bx, [bp+22h] ; [BPB_TotSec32+2] 3755 FAT16_f_19: 3756 FAT12_f_8: 3757 ; are there remain sectors (in partition) ? 3758 0000133E 29C1 sub cx, ax 3759 00001340 19D3 sbb bx, dx 3760 ; 11/02/2019 3761 ; BX must be 0 (Because, 1 cluster <= 32KB. So, 3762 ; remain sectors must not be more than 32K) 3763 00001342 751C jnz short FAT32_f_12 ; There is a wrong thing !!! 3764 ; If BX is not zero, 3765 ; it is better to skip this stage...) 3766 00001344 09C9 or cx, cx 3767 00001346 7418 jz short FAT32_f_12 ; no.. 3768 ; (good! FAT contains all data sectors) 3769 FAT32_f_11: 3770 00001348 51 push cx 3771 00001349 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 3772 0000134C E8B008 call write_hd_sector 3773 0000134F 0F827A01 jc formatting_error 3774 00001353 E82601 call write_format_percent 3775 00001356 59 pop cx 3776 00001357 83C001 add ax, 1 3777 0000135A 83D200 adc dx, 0 3778 0000135D 49 dec cx 3779 0000135E 75E8 jnz short FAT32_f_11 3780 3781 FAT32_f_12: 3782 SINGLIX_fs1_f_12: 3783 ; End of FAT format routine... 3784 end_of_formatting: 3785 00001360 B064 mov al, 100 3786 00001362 E85401 call write_format_percent_x 3787 ;mov si, CRLF 3788 ;call print_msg 3789 00001365 BE[8355] mov si, Msg_OK 3790 ;call print_msg 3791 ;jmp _exit 3792 ; 19/10/2020 3793 00001368 E93FF4 jmp _p_exit 3794 3795 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3796 ; set & write volume name 3797 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3798 3799 write_fs_volume_name: 3800 0000136B C606[3F64]40 mov byte [vname_length], 64 3801 00001370 EB05 jmp short svn_fs 3802 3803 write_volume_name: 3804 00001372 C606[3F64]0B mov byte [vname_length], 11 3805 svn_fs: 3806 ; DI = (BS) Volume Label address 3807 00001377 BE[2555] mov si, Msg_Volume_Name 3808 0000137A E81D08 call print_msg 3809 3810 ; get cursor position 3811 ; bh = 0 ; video page 3812 0000137D B403 mov ah, 3 ; get cursor pos 3813 0000137F CD10 int 10h 3814 00001381 8916[CB54] mov [Cursor_Pos], dx 3815 3816 00001385 E8FF08 call rw_char 3817 00001388 7207 jc short svn_1 3818 svn_0: 3819 0000138A AC lodsb 3820 0000138B 3C20 cmp al, 20h 3821 0000138D 7706 ja short svn_2 3822 0000138F 74F9 je short svn_0 3823 svn_1: 3824 00001391 BE[4A64] mov si, no_name 3825 00001394 AC lodsb 3826 svn_2: 3827 ;mov di, [bp+47h) ; [BS_VolLab] ; FAT32 3828 ;mov di, [bp+2Bh) ; [BS_VolLab] ; FAT16 (&FAT12) 3829 00001395 89FB mov bx, di ; * 3830 00001397 30ED xor ch, ch 3831 00001399 8A0E[3F64] mov cl, [vname_length] ; 11 3832 0000139D EB05 jmp short svn_4 3833 svn_3: 3834 0000139F AC lodsb 3835 000013A0 3C20 cmp al, 20h 3836 000013A2 7226 jb short svn_6 3837 svn_4: 3838 000013A4 AA stosb 3839 000013A5 E2F8 loop svn_3 3840 svn_5: 3841 000013A7 8A0E[3F64] mov cl, [vname_length] ; 11 3842 000013AB 89DE mov si, bx ; * 3843 000013AD BF[E454] mov di, StrVolumeName 3844 000013B0 F3A4 rep movsb 3845 ;mov byte [di], 0 3846 3847 000013B2 8B16[CB54] mov dx, [Cursor_Pos] 3848 000013B6 BB0700 mov bx, 7 3849 000013B9 B402 mov ah, 2 3850 000013BB CD10 int 10h ; Set Cursor Position 3851 3852 000013BD BE[E454] mov si, StrVolumeName 3853 000013C0 E8D707 call print_msg 3854 000013C3 BE[8755] mov si, CRLF 3855 000013C6 E8D107 call print_msg 3856 000013C9 C3 retn 3857 svn_6: 3858 000013CA B020 mov al, 20h 3859 svn_7: 3860 000013CC AA stosb 3861 000013CD E2FD loop svn_7 3862 000013CF EBD6 jmp short svn_5 3863 3864 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3865 ; set & write volume serial number (volume ID) 3866 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3867 3868 write_volume_serial: 3869 ; SI = (BS) Volume Serial Number (binary) address 3870 3871 ;xor ax, ax 3872 ;int 1Ah ; get time of day 3873 3874 ;mov [si], dx 3875 ;mov [si+2], cx ; set unique volume ID 3876 3877 ;mov ah, 02h ; Return Current Time 3878 ;int 1Ah 3879 ;xchg ch, cl 3880 ;xchg dh, dl 3881 3882 ;add cx, dx 3883 ;add [si+2], cx 3884 3885 ;mov ah, 04h ; Return Current Date 3886 ;int 1Ah 3887 3888 ;xchg ch,cl 3889 ;xchg dh,dl 3890 3891 ;add cx, dx 3892 ;add [si+2], cx 3893 3894 ; According to Microsoft DOS 6.0 serial number 3895 ; production method... 3896 ; < Create unique 32 bit serial number > 3897 3898 ; Create_Serial_ID (MSDOS 6.0 Source code, MSFOR.ASM) 3899 ; (20/04/1987) 3900 ; 3901 ; Get date (INT 21h, AH=2Bh) 3902 ; Get time (INT 21h, AH=2Ch) 3903 ; Serial_ID+0 = DX reg date + DX reg time 3904 ; Serial_ID+2 = CX reg date + CX reg time 3905 ; Serial_Num_Low = Serial_ID+2 3906 ; Serial_Num_High = Serial_ID+0 3907 3908 000013D1 B404 mov ah, 04h ; Return Current Date 3909 000013D3 CD1A int 1Ah 3910 3911 ; DL = Day (BCD) (20h) 3912 ; DH = Month (BCD) (12h) 3913 ; CH = Century (BCD) (20h) 3914 ; CL = Year (BCD) (17h) 3915 3916 000013D5 88D0 mov al, dl 3917 000013D7 E87100 call bcd_to_bin 3918 000013DA 88C2 mov dl, al 3919 000013DC 88F0 mov al, dh 3920 000013DE E86A00 call bcd_to_bin 3921 000013E1 88C6 mov dh, al 3922 000013E3 88C8 mov al, cl 3923 000013E5 E86300 call bcd_to_bin 3924 000013E8 88C1 mov cl, al 3925 000013EA 88E8 mov al, ch 3926 000013EC E85C00 call bcd_to_bin 3927 000013EF 88C5 mov ch, al 3928 3929 ; DH = Month (1-10) 3930 ; DL = Day (1-31) 3931 ; CX = Year (1900-2099) 3932 3933 000013F1 52 push dx 3934 000013F2 51 push cx 3935 3936 000013F3 B402 mov ah, 02h ; Return Current Time 3937 000013F5 CD1A int 1Ah 3938 3939 ; DH = Seconds (BCD) (59h) 3940 ; CL = Minutes (BCD) (59h) 3941 ; CH = Hours (BCD) (23h) 3942 ; DL = Daylight savings time option (1=yes) 3943 3944 000013F7 88F0 mov al, dh 3945 000013F9 E84F00 call bcd_to_bin 3946 000013FC 88C6 mov dh, al 3947 000013FE 88C8 mov al, cl 3948 00001400 E84800 call bcd_to_bin 3949 00001403 88C1 mov cl, al 3950 00001405 88E8 mov al, ch 3951 00001407 E84100 call bcd_to_bin 3952 0000140A 88C5 mov ch, al 3953 3954 ; CH = Hour (0-23) 3955 ; CL = Minutes (0-59) 3956 ; DH = Seconds (0-59) 3957 ; ((DL = Hundredths (0-99) - MSDOS!)) 3958 ; DL = 0 or 1 (here!) 3959 3960 0000140C 89C8 mov ax, cx 3961 0000140E 59 pop cx 3962 0000140F 01C8 add ax, cx 3963 3964 00001411 894402 mov [si+2], ax 3965 3966 00001414 89D0 mov ax, dx 3967 00001416 5A pop dx 3968 00001417 01D0 add ax, dx 3969 3970 00001419 8904 mov [si], ax 3971 3972 0000141B 30E4 xor ah, ah ; Read time counter 3973 0000141D CD1A int 1Ah 3974 3975 ; CX = High word of clock count 3976 ; DX = Low word of clock count 3977 ; AL = 0 if 24 hours has not passed, else 1 3978 3979 ; NOTES: 3980 ; (Ref: vitaly_filatov.tripod.com/ng/asm/asm_029.1.html) 3981 ; 3982 ; Following formulas convert the clock count to 3983 ; the time of day: 3984 ; Hour = Clock / 65543 (1007h) 3985 ; Remainder = Clock MOD 65543 3986 ; 3987 ; Minutes = Remainder / 1092 (444h) 3988 ; Remainder = Remainder MOD 1092 3989 ; 3990 ; Second = Remainder / 18.21 3991 ; Remainder = Remainder MOD 18.21 3992 ; 3993 ; Hundredths = CINT(Remainder * 100) 3994 3995 0000141F 0014 add [si], dl 3996 3997 ; SI = Volume serial number address (4 bytes) 3998 00001421 8A04 mov al, [si] 3999 00001423 E84A08 call bin_to_hex 4000 00001426 A3[5055] mov [Vol_Serial2+2], ax 4001 00001429 8A4401 mov al, [si+1] 4002 0000142C E84108 call bin_to_hex 4003 0000142F A3[4E55] mov [Vol_Serial2], ax 4004 00001432 8A4402 mov al, [si+2] 4005 00001435 E83808 call bin_to_hex 4006 00001438 A3[4B55] mov [Vol_Serial1+2], ax 4007 0000143B 8A4403 mov al, [si+3] 4008 0000143E E82F08 call bin_to_hex 4009 00001441 A3[4955] mov [Vol_Serial1], ax 4010 4011 00001444 BE[3755] mov si, Msg_Volume_Serial 4012 00001447 E85007 call print_msg 4013 4014 0000144A C3 retn 4015 4016 bcd_to_bin: 4017 0000144B 53 push bx 4018 0000144C D410 db 0D4h,10h ; Undocumented inst. AAM 4019 ; AH = AL / 10h 4020 ; AL = AL MOD 10h 4021 0000144E 88C3 mov bl, al 4022 00001450 B00A mov al, 10 4023 00001452 F6E4 mul ah 4024 00001454 00D8 add al, bl 4025 00001456 5B pop bx 4026 00001457 C3 retn 4027 4028 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4029 ; write formatting percentage 4030 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4031 4032 write_formatting_msg: 4033 ;mov ax, [pp_Sectors] 4034 ;mov dx, [pp_Sectors+2] 4035 ; 16/02/2019 4036 00001458 A1[226D] mov ax, [ppn_Sectors] 4037 0000145B 8B16[246D] mov dx, [ppn_Sectors+2] 4038 4039 ; DX_AX = Total sectors for percentage 4040 ;mov cx, 100 4041 0000145F B90064 mov cx, 256*100 ; 16/03/2021 4042 00001462 E818F8 call div32 4043 00001465 A3[786A] mov [format_percent], ax 4044 4045 00001468 BE[6F55] mov si, msg_formatting 4046 0000146B E82C07 call print_msg 4047 4048 ; get cursor position 4049 ; bh = 0 ; video page 4050 0000146E B403 mov ah, 3 ; get cursor pos 4051 00001470 CD10 int 10h 4052 00001472 8916[CB54] mov [Cursor_Pos], dx 4053 4054 00001476 C606[7A6A]FF mov byte [prev_percent], 255 4055 4056 0000147B C3 retn 4057 4058 write_format_percent: 4059 ; DX_AX = Current sector (which has been written) 4060 4061 0000147C 50 push ax 4062 0000147D 52 push dx 4063 0000147E 53 push bx 4064 0000147F 51 push cx 4065 00001480 56 push si 4066 4067 00001481 2B461C sub ax, [bp+1Ch] ; [BPB_HiddSec] 4068 00001484 1B561E sbb dx, [bp+1Eh] ; [BPB_HiddSec+2] 4069 wpc_t: 4070 00001487 8B0E[786A] mov cx, [format_percent] 4071 0000148B E8EFF7 call div32 4072 ; AL = percentage value between 1 to 100 4073 ; 16/03/2021 4074 ; AH = percentage value between 1 to 100 4075 wpc_x: 4076 ;cmp al, [prev_percent] 4077 ;je short wpc_y 4078 ;mov [prev_percent], al 4079 ; 16/03/2021 4080 0000148E 3A26[7A6A] cmp ah, [prev_percent] 4081 00001492 741F je short wpc_y 4082 00001494 8826[7A6A] mov [prev_percent], ah 4083 00001498 8B16[CB54] mov dx, [Cursor_Pos] 4084 0000149C BB0700 mov bx, 7 4085 0000149F B402 mov ah, 2 4086 000014A1 CD10 int 10h ; Set Cursor Position 4087 000014A3 31D2 xor dx, dx 4088 000014A5 30E4 xor ah, ah 4089 000014A7 A0[7A6A] mov al, [prev_percent] ; 16/03/2021 4090 000014AA BE[7D55] mov si, format_percent_str + 2 4091 000014AD E8A907 call bin_to_decimal 4092 000014B0 E8E706 call print_msg 4093 wpc_y: 4094 000014B3 5E pop si 4095 000014B4 59 pop cx 4096 000014B5 5B pop bx 4097 000014B6 5A pop dx 4098 000014B7 58 pop ax 4099 000014B8 C3 retn 4100 4101 write_format_percent_x: 4102 ; AL = % number 4103 4104 000014B9 50 push ax 4105 000014BA 52 push dx 4106 000014BB 53 push bx 4107 000014BC 51 push cx 4108 000014BD 56 push si 4109 4110 000014BE EBCE jmp short wpc_x 4111 4112 write_fs_format_percent: 4113 ; DX_AX = Current sector (which has been written) 4114 4115 000014C0 50 push ax 4116 000014C1 52 push dx 4117 000014C2 53 push bx 4118 000014C3 51 push cx 4119 000014C4 56 push si 4120 4121 000014C5 2B460C sub ax, [bp+0Ch] ; [bsBeginSector] 4122 000014C8 1B560E sbb dx, [bp+0Eh] ; [bsBeginSector+2] 4123 000014CB EBBA jmp short wpc_t 4124 4125 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4126 ; format error 4127 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4128 4129 formatting_error: 4130 000014CD 8B26[6868] mov sp, [old_sp] 4131 4132 000014D1 88E0 mov al, ah ; error code 4133 000014D3 E89A07 call bin_to_hex 4134 000014D6 A3[9555] mov [error_code], ax 4135 4136 000014D9 BE[8755] mov si, CRLF 4137 000014DC E8BB06 call print_msg 4138 4139 000014DF BE[8A55] mov si, Msg_Error 4140 ;call print_msg 4141 ;jmp _exit 4142 ; 19/10/2020 4143 000014E2 E9C5F2 jmp _p_exit 4144 4145 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4146 ; write cluster count 4147 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4148 4149 write_cluster_count: 4150 000014E5 BE[5555] mov si, msg_cluster_count 4151 000014E8 E8AF06 call print_msg 4152 000014EB A1[726A] mov ax, [cluster_count] 4153 000014EE 8B16[746A] mov dx, [cluster_count+2] 4154 000014F2 BE[6B55] mov si, cluster_count_str+6 4155 000014F5 E86107 call bin_to_decimal 4156 ;call print_msg 4157 ;retn 4158 ; 19/10/2020 4159 000014F8 E99F06 jmp print_msg 4160 4161 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4162 ; FAT16 FORMATTING 4163 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4164 ; 08/02/2019 (Modified for -only- FAT16 CHS partitions) 4165 FAT16_hd_format: 4166 ; 04/05/2024 (Retro DOS v5 modification) 4167 ; DL = Partition (FS) ID 4168 ; mov ax, 0706h ; db 06h, 07h ; 'push es, pop es' 4169 ; cmp dl, al ; 06h ; Big CHS partition (>= 32MB) 4170 ; je short FAT16_big_chs_format 4171 ; ;mov ax, 070Eh ; db 0Eh, 07h ; 'push cs, pop es' 4172 ; ;cmp dl, al ; 0Eh ; LBA partition 4173 ; ;je short FAT16_lba_format 4174 ;FAT16_chs_format: 4175 ; ; Partition Type: 04h, CHS (<32 MB) partition 4176 ; mov ax, 0004h ; db 04h, 00h ; 'add al, 0' 4177 ;FAT16_big_chs_format: 4178 ;;; 4179 ;;FAT16_lba_format: 4180 ; Put TRDOS 386 FAT16 partition magic word 4181 ; at offset 3Eh, in TRDOS386 FAT16 boot sector. 4182 000014FB BD[7337] mov bp, TRDOS_FAT16_hd_bs 4183 000014FE 8D7E03 lea di, [bp+3] 4184 00001501 BE[4064] mov si, bs_oem_name 4185 00001504 B90400 mov cx, 4 4186 00001507 F3A5 rep movsw 4187 4188 ;mov [bp+3Eh], ax ; [loc_3E] 4189 ; 04/05/2024 (Retro DOS v5 modification) 4190 00001509 80FA06 cmp dl, 6 4191 0000150C 7404 je short FAT16_f_x ; skip ; db 'RDv5 FAT16 06h', 0 4192 ; dl = 04h or 0Eh 4193 0000150E 8896CE01 mov [bp+1CEh], dl ; Retro DOS v5 boot sect off 1CEh 4194 ; (see: 'rd5hdbs.txt' for 1CEh) 4195 FAT16_f_x: 4196 00001512 A1[863F] mov ax, [sectors] 4197 00001515 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4198 00001518 A1[883F] mov ax, [heads] 4199 0000151B 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4200 0000151E A1[F06C] mov ax, [pp_StartSector] 4201 00001521 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 4202 00001524 A1[F26C] mov ax, [pp_StartSector+2] 4203 00001527 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4204 ;mov ax, [pp_Sectors] 4205 0000152A A1[226D] mov ax, [ppn_Sectors] ; 16/02/2019 4206 ;mov dx, [pp_Sectors+2] 4207 0000152D 8B16[246D] mov dx, [ppn_Sectors+2] ; 16/02/2019 4208 00001531 21D2 and dx, dx 4209 00001533 7505 jnz short FAT16_f_0 4210 00001535 894613 mov [bp+13h], ax ; [BPB_TotSec16] 4211 ; CX = 0 4212 ;mov [bp+20h], cx ; [BPB_TotSec32] = 0 4213 ;mov [bp+22h], cx ; [BPB_TotSec32+2] = 0 4214 00001538 EB06 jmp short FAT16_f_1 4215 FAT16_f_0: 4216 0000153A 894620 mov [bp+20h], ax ; [BPB_TotSec32] 4217 ;;mov dx, [pp_Sectors+2] 4218 ;mov dx, [ppn_Sectors+2] ; 16/02/2019 4219 0000153D 895622 mov [bp+22h], dx ; [BPB_TotSec32+2] 4220 ; CX = 0 4221 ;mov [bp+13h], cx ; [BPB_TotSec16] = 0 4222 FAT16_f_1: 4223 ; Sectors per cluster calculation 4224 ; (According to MS FAT32 FS specification.) 4225 00001540 B102 mov cl, 2 ; 2 sectors per cluster 4226 00001542 09D2 or dx, dx 4227 00001544 7507 jnz short FAT16_f_2 ; >2 sectors (>16MB) 4228 00001546 3DA87F cmp ax, 32680 4229 00001549 763C jna short FAT16_f_10 ; 2 sectors, <=16MB 4230 ; > 16MB 4231 0000154B EB38 jmp short FAT16_f_9 ; 4 sectors per cluster 4232 FAT16_f_2: 4233 0000154D 83FA04 cmp dx, 4 ; >= 262144 sectors ; >=128MB 4234 00001550 7708 ja short FAT16_f_3 ; >4 sectors per cluster 4235 00001552 7231 jb short FAT16_f_9 ; 4 sectors per cluster 4236 00001554 09C0 or ax, ax ; dx_ax = (4*65536)+0 4237 00001556 742D jz short FAT16_f_9 ; 4 sectors per cluster 4238 00001558 EB29 jmp short FAT16_f_8 ; 8 sectors per cluster 4239 FAT16_f_3: 4240 0000155A 83FA08 cmp dx, 8 ; >= 524288 sectors ; >=256MB 4241 0000155D 7708 ja short FAT16_f_4 ; >8 sectors per cluster 4242 0000155F 7222 jb short FAT16_f_8 ; 8 sectors per cluster 4243 00001561 21C0 and ax, ax ; dx_ax = (8*65536)+0 4244 00001563 741E jz short FAT16_f_8 ; 8 sectors per cluster 4245 00001565 EB1A jmp short FAT16_f_7 ; 16 sectors per cluster 4246 FAT16_f_4: 4247 00001567 83FA10 cmp dx, 16 ; >= 1048576 sectors ; >=512MB 4248 0000156A 7708 ja short FAT16_f_5 ; >16 sectors per cluster 4249 0000156C 7213 jb short FAT16_f_7 ; 16 sectors per cluster 4250 0000156E 21C0 and ax, ax ; dx_ax = (16*65536)+0 4251 00001570 740F jz short FAT16_f_7 ; 16 sectors per cluster 4252 00001572 EB0B jmp short FAT16_f_6 ; 32 sectors per cluster 4253 FAT16_f_5: 4254 00001574 83FA20 cmp dx, 32 ; >= 2097152 sectors ; >=1GB 4255 00001577 7206 jb short FAT16_f_6 ; 32 sectors per cluster 4256 00001579 09C0 or ax, ax ; dx_ax = (32*65536)+0 4257 0000157B 7402 jz short FAT16_f_6 ; 32 sectors per cluster 4258 ; >1GB (<=2GB) 4259 ; 64 sectors per cluster 4260 0000157D D0E1 shl cl, 1 4261 FAT16_f_6: 4262 ; 32 sectors per cluster (for <= 2GB volumes) 4263 0000157F D0E1 shl cl, 1 4264 FAT16_f_7: 4265 ; 16 sectors per cluster (for <= 1GB volumes) 4266 00001581 D0E1 shl cl, 1 4267 FAT16_f_8: 4268 ; 8 sectors per cluster (for <= 512MB volumes) 4269 00001583 D0E1 shl cl, 1 4270 FAT16_f_9: 4271 ; 4 sectors per cluster (for <= 256MB volumes) 4272 00001585 D0E1 shl cl, 1 4273 FAT16_f_10: 4274 ; 2 sectors per cluster (for <= 128MB volumes) 4275 00001587 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 4276 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 4277 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 4278 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 4279 4280 ; Calculating FAT size in sectors 4281 ; (According to MS FAT32 FS Specification, 2000) 4282 4283 ; DX_AX = partition (volume) size in sectors 4284 0000158A 8B5E11 mov bx, [bp+11h] ; [BPB_RootEntCnt] = 512 4285 0000158D 83C30F add bx, 15 ; bx = 527 4286 00001590 C1EB04 shr bx, 4 ; /16 = 527/16 = 32 4287 ; ((32*BX)+511)/512 4288 00001593 891E[766A] mov [root_dir_secs], bx 4289 00001597 035E0E add bx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4290 0000159A 29D8 sub ax, bx 4291 0000159C 83DA00 sbb dx, 0 4292 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 4293 ; RootDirsectors) 4294 ;mov bx, cx ; ch = 0 4295 ;shl bx, 8 ; * 256 4296 ; 11/02/2019 4297 0000159F 88CF mov bh, cl 4298 000015A1 30DB xor bl, bl 4299 000015A3 B102 mov cl, 2 ; [BPB_NumFATs] 4300 000015A5 01CB add bx, cx 4301 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 4302 000015A7 89D9 mov cx, bx 4303 000015A9 4B dec bx ; TmpVal2-1 4304 000015AA 01D8 add ax, bx 4305 000015AC 83D200 adc dx, 0 4306 000015AF E8CBF6 call div32 4307 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 4308 ; AX = FAT size in sectors 4309 ; DX = 0 4310 000015B2 894616 mov [bp+16h], ax ; [BPB_FATSz16] 4311 ; * 2 4312 000015B5 D1E0 shl ax, 1 4313 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 4314 000015B7 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4315 000015BA 01C1 add cx, ax 4316 4317 ; 15/07/2024 (bugfix) 4318 000015BC 894E42 mov [bp+42h], cx ; bsRootDirStart 4319 000015BF 8B1E[766A] mov bx, [root_dir_secs] 4320 000015C3 895E44 mov [bp+44h], bx ; bsRootDirSects 4321 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 4322 4323 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4324 ;add cx, [root_dir_secs] ; + RootDirsectors 4325 ; 15/07/2024 4326 000015C6 01D9 add cx, bx 4327 000015C8 29DB sub bx, bx ; BX = 0 4328 ; BX_CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4329 ; + RootDirSectors 4330 000015CA 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 4331 ;sub dx, dx 4332 ; DX = 0 4333 000015CD 21C0 and ax, ax 4334 000015CF 7506 jnz short FAT16_f_11 4335 000015D1 8B4620 mov ax, [bp+20h] ; [BPB_TotSec32] 4336 000015D4 8B5622 mov dx, [bp+22h] ; [BPB_TotSec32+2] 4337 FAT16_f_11: 4338 000015D7 29C8 sub ax, cx 4339 000015D9 19DA sbb dx, bx 4340 000015DB 890E[6A6A] mov [data_start], cx 4341 000015DF 891E[6C6A] mov [data_start+2], bx 4342 4343 ; 15/07/2024 (bugfix) 4344 000015E3 894E40 mov [bp+40h], cx ; bsDataStart 4345 4346 ; DX_AX = Data sectors 4347 000015E6 A3[6E6A] mov [data_sectors], ax 4348 000015E9 8916[706A] mov [data_sectors+2], dx 4349 000015ED 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4350 000015F0 30ED xor ch, ch 4351 000015F2 E888F6 call div32 ; DX_AX/CX 4352 ; AX = Count of clusters (rounded down) 4353 ; DX = 0 4354 000015F5 A3[726A] mov [cluster_count], ax 4355 000015F8 8916[746A] mov [cluster_count+2], dx 4356 4357 000015FC 8D7E2B lea di, [bp+43] ; [BS_VolLab] 4358 000015FF E870FD call write_volume_name 4359 00001602 8D7627 lea si, [bp+39] ; [BS_VolID] 4360 00001605 E8C9FD call write_volume_serial 4361 00001608 E8DAFE call write_cluster_count 4362 4363 0000160B E84AFE call write_formatting_msg 4364 0000160E B000 mov al, 0 4365 00001610 E8A6FE call write_format_percent_x 4366 4367 00001613 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 4368 00001616 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 4369 4370 00001619 0106[6A6A] add [data_start], ax 4371 0000161D 1116[6C6A] adc [data_start+2], dx 4372 4373 ; DX_AX = FAT16 Boot Sector address 4374 00001621 BB[7337] mov bx, TRDOS_FAT16_hd_bs 4375 ; ES:BX = Boot Sector Buffer 4376 00001624 E8D805 call write_hd_sector 4377 00001627 0F82A2FE jc formatting_error 4378 0000162B E84EFE call write_format_percent 4379 0000162E 83C001 add ax, 1 4380 00001631 83D200 adc dx, 0 4381 ; write remain part of reserved sectors 4382 00001634 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 4383 ;sub cx, 1 4384 ;jna short FAT16_f_13 4385 ; 11/02/2019 4386 00001637 49 dec cx 4387 00001638 7418 jz short FAT16_f_13 4388 FAT16_f_12: 4389 0000163A 51 push cx 4390 0000163B BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 4391 0000163E E8BE05 call write_hd_sector 4392 00001641 0F8288FE jc formatting_error 4393 00001645 E834FE call write_format_percent 4394 00001648 83C001 add ax, 1 4395 0000164B 83D200 adc dx, 0 4396 0000164E 59 pop cx 4397 0000164F 49 dec cx ; dec cl 4398 00001650 75E8 jnz short FAT16_f_12 4399 FAT16_f_13: 4400 ; write FAT sectors 4401 00001652 8B0E[6A6A] mov cx, [data_start] ; lba/abs addr 4402 00001656 8B1E[6C6A] mov bx, [data_start+2] ; lba/abs addr 4403 4404 ; 11/02/2019 4405 0000165A 2B0E[766A] sub cx, [root_dir_secs] 4406 0000165E 83DB00 sbb bx, 0 4407 4408 00001661 53 push bx 4409 00001662 51 push cx 4410 00001663 BB[6A68] mov bx, HDFORMAT_FATBUFFER 4411 ; ES:BX = FAT Sector Buffer 4412 00001666 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 4413 00001669 B5FF mov ch, 0FFh 4414 0000166B 890F mov [bx], cx ; 0FFF8h 4415 0000166D 88E9 mov cl, ch ; cx = 0FFFFh 4416 0000166F 894F02 mov [bx+2], cx 4417 ;inc cx 4418 00001672 E88A05 call write_hd_sector 4419 00001675 0F8254FE jc formatting_error 4420 00001679 E800FE call write_format_percent 4421 ;mov bx, HDFORMAT_FATBUFFER 4422 0000167C B90000 mov cx, 0 4423 0000167F 890F mov [bx], cx 4424 00001681 894F02 mov [bx+2], cx 4425 00001684 EB0F jmp short FAT16_f_15 4426 FAT16_f_14: 4427 00001686 53 push bx 4428 00001687 51 push cx 4429 00001688 BB[6A68] mov bx, HDFORMAT_FATBUFFER 4430 0000168B E87105 call write_hd_sector 4431 0000168E 0F823BFE jc formatting_error 4432 00001692 E8E7FD call write_format_percent 4433 FAT16_f_15: 4434 00001695 59 pop cx 4435 00001696 5B pop bx 4436 00001697 83C001 add ax, 1 4437 0000169A 83D200 adc dx, 0 4438 0000169D 39DA cmp dx, bx 4439 0000169F 72E5 jb short FAT16_f_14 4440 000016A1 39C8 cmp ax, cx 4441 000016A3 72E1 jb short FAT16_f_14 4442 4443 ; write root directory sectors 4444 ; as empty sectors 4445 000016A5 8B0E[766A] mov cx, [root_dir_secs] 4446 FAT16_f_16: 4447 000016A9 51 push cx 4448 000016AA BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 4449 000016AD E84F05 call write_hd_sector 4450 000016B0 0F8219FE jc formatting_error 4451 000016B4 E8C5FD call write_format_percent 4452 000016B7 83C001 add ax, 1 4453 000016BA 83D200 adc dx, 0 4454 000016BD 59 pop cx 4455 000016BE 49 dec cx 4456 000016BF 75E8 jnz short FAT16_f_16 4457 4458 ; write DATA sectors 4459 ; (after root directory sectors) 4460 000016C1 8B0E[6E6A] mov cx, [data_sectors] 4461 000016C5 8B1E[706A] mov bx, [data_sectors+2] 4462 ; 11/02/2019 4463 000016C9 43 inc bx ; 0 -> 1, 1-> 2 4464 FAT16_f_17: 4465 000016CA 53 push bx 4466 000016CB 51 push cx 4467 000016CC BB[5664] mov bx, HDFORMAT_SECBUFFER 4468 000016CF E82D05 call write_hd_sector 4469 000016D2 0F82F7FD jc formatting_error 4470 000016D6 E8A3FD call write_format_percent 4471 000016D9 59 pop cx 4472 000016DA 5B pop bx 4473 000016DB 83C001 add ax, 1 4474 000016DE 83D200 adc dx, 0 4475 000016E1 49 dec cx 4476 000016E2 75E6 jnz short FAT16_f_17 4477 000016E4 4B dec bx 4478 000016E5 75E3 jnz short FAT16_f_17 4479 4480 ; If there are, format remain sectors which are 4481 ; at beyond of data clusters, with zero bytes. 4482 4483 000016E7 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 4484 000016EA 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4485 4486 000016ED 837E1300 cmp word [bp+13h], 0 ; [BPB_TotSec16] 4487 000016F1 0F8443FC jz FAT16_f_18 4488 000016F5 034E13 add cx, [bp+13h] ; [BPB_TotSec16] 4489 000016F8 83D300 adc bx, 0 4490 000016FB E940FC jmp FAT16_f_19 4491 4492 FAT12_hd_format: 4493 000016FE BD[7339] mov bp, TRDOS_FAT12_hd_bs 4494 00001701 8D7E03 lea di, [bp+3] 4495 00001704 BE[4064] mov si, bs_oem_name 4496 00001707 B90400 mov cx, 4 4497 0000170A F3A5 rep movsw 4498 0000170C A1[863F] mov ax, [sectors] 4499 0000170F 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4500 00001712 A1[883F] mov ax, [heads] 4501 00001715 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4502 00001718 A1[F06C] mov ax, [pp_StartSector] 4503 0000171B 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 4504 0000171E A1[F26C] mov ax, [pp_StartSector+2] 4505 00001721 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4506 ;mov ax, [pp_Sectors] 4507 00001724 A1[226D] mov ax, [ppn_Sectors] ; 16/02/2019 4508 00001727 894613 mov [bp+13h], ax ; [BPB_TotSec16] 4509 4510 ; 11/02/2019 4511 0000172A 31F6 xor si, si ; reset (FAT size fix) flag 4512 0000172C 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4513 0000172F 8B5611 mov dx, [bp+11h] ; [BPB_RootEntCnt] = 512 4514 00001732 83C20F add dx, 15 ; (16-1) (512-1) 4515 00001735 C1EA04 shr dx, 4 ; /16 (*32/512) 4516 ; AX = Root dir sectors 4517 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4518 00001738 01D1 add cx, dx ; + RootDirsectors ; + 32 4519 0000173A 890E[766A] mov [root_dir_secs], cx ; = 33 4520 4521 ; 11/02/2019 4522 ;sub ax, 33 ; 1 reserved sector, 32 root dir sectors 4523 ; .. now AX has number of data sectors 4524 ; + 2* (FAT sectors) 4525 0000173E 29C8 sub ax, cx 4526 FAT12_f_10: ; 11/02/2019 4527 ; Sectors per cluster calculation 4528 ; (According to MS FAT32 FS specification.) 4529 ;mov cx, 1 ; 1 sector per cluster 4530 00001740 B101 mov cl, 1 ; CH = 0 4531 FAT12_f_0: 4532 00001742 3DF50F cmp ax, 4085 ; Max. cluster count for FAT12 4533 00001745 7206 jb short FAT12_f_1 4534 00001747 D0E1 shl cl, 1 ; *2 4535 00001749 D1E8 shr ax, 1 ; /2 4536 0000174B EBF5 jmp short FAT12_f_0 4537 FAT12_f_1: 4538 0000174D 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 4539 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 4540 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 4541 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 4542 4543 ; Calculating FAT size in sectors 4544 ; AX = partition (volume) size in sectors 4545 ; CX = sectors per clusters 4546 00001750 31D2 xor dx, dx 4547 00001752 F7F1 div cx 4548 ; AX = cluster count (only for FAT size calc) 4549 ; DX = 0 4550 00001754 83C002 add ax, 2 ; cluster 2 to ... 4551 00001757 89C2 mov dx, ax 4552 00001759 D1E2 shl dx, 1 4553 0000175B 01D0 add ax, dx ; *3 4554 0000175D D1E8 shr ax, 1 ; /2 4555 0000175F 83D000 adc ax, 0 ; +0.5 -> +1 4556 4557 ; AX = FAT bytes for 12 bit cluster numbers 4558 4559 00001762 B90002 mov cx, 512 ; [BPB_BytesPerSec] 4560 00001765 01C8 add ax, cx 4561 00001767 48 dec ax ; [BPB_BytesPerSec] - 1 4562 00001768 29D2 sub dx, dx 4563 0000176A F7F1 div cx 4564 0000176C 894616 mov [bp+16h], ax ; [BPB_FATSz16] 4565 ; * 2 4566 0000176F D1E0 shl ax, 1 4567 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 4568 4569 ;mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4570 ;add cx, ax 4571 ;mov ax, [bp+11h] ; [BPB_RootEntCnt] = 512 4572 ;add ax, 15 ; (16-1) (512-1) 4573 ;shr ax, 4 ; /16 (*32/512) 4574 ;; AX = Root dir sectors 4575 ;; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4576 ;add cx, ax ; + RootDirsectors 4577 ;mov [root_dir_secs], ax 4578 4579 ; 11/02/2019 4580 ;mov cx, 33 4581 00001771 8B0E[766A] mov cx, [root_dir_secs] 4582 4583 ; 15/07/2024 (bugfix) 4584 ; ax = 2 * FAT size (in sectors) 4585 00001775 03460E add ax, [bp+0Eh] ; total FAT sectors + reserved sectors 4586 00001778 894642 mov [bp+42h], ax ; bsRootDirStart 4587 0000177B 894E44 mov [bp+44h], cx ; bsRootDirSects 4588 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 4589 4590 ; 15/07/2024 4591 ;add cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4592 ; cx = root directory sectors + reserved sectors 4593 0000177E 01C1 add cx, ax 4594 ; cx = root dir sects + rsvd sects + total FAT sects 4595 4596 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4597 ; + RootDirSectors 4598 00001780 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 4599 00001783 29C8 sub ax, cx 4600 ; AX = data sectors 4601 ; cH = 0 4602 4603 ; 11/02/2019 - fix FAT size (better method) 4604 00001785 09F6 or si, si 4605 00001787 7504 jnz short FAT12_f_9 4606 4607 00001789 89C6 mov si, ax ; ax = data sectors 4608 0000178B EBB3 jmp short FAT12_f_10 4609 4610 FAT12_f_9: 4611 0000178D 31D2 xor dx, dx 4612 0000178F 890E[6A6A] mov [data_start], cx 4613 00001793 8916[6C6A] mov [data_start+2], dx ; 0 4614 4615 ; 15/07/2024 (bugfix) 4616 00001797 894E40 mov [bp+40h], cx ; bsDataStart 4617 4618 ; DX_AX = Data sectors 4619 0000179A A3[6E6A] mov [data_sectors], ax 4620 0000179D 8916[706A] mov [data_sectors+2], dx ; 0 4621 000017A1 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4622 000017A4 28ED sub ch, ch 4623 000017A6 F7F1 div cx 4624 ; AX = Count of clusters (rounded down) 4625 000017A8 29D2 sub dx, dx ; 0 4626 000017AA A3[726A] mov [cluster_count], ax 4627 000017AD 8916[746A] mov [cluster_count+2], dx ; 0 4628 4629 000017B1 8D7E2B lea di, [bp+43] ; [BS_VolLab] 4630 000017B4 E8BBFB call write_volume_name 4631 000017B7 8D7627 lea si, [bp+39] ; [BS_VolID] 4632 000017BA E814FC call write_volume_serial 4633 000017BD E825FD call write_cluster_count 4634 4635 000017C0 E895FC call write_formatting_msg 4636 000017C3 B000 mov al, 0 4637 000017C5 E8F1FC call write_format_percent_x 4638 4639 000017C8 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 4640 000017CB 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 4641 4642 000017CE 0106[6A6A] add [data_start], ax 4643 000017D2 1116[6C6A] adc [data_start+2], dx 4644 4645 ; DX_AX = FAT12 Boot Sector address 4646 000017D6 BB[7339] mov bx, TRDOS_FAT12_hd_bs 4647 ; ES:BX = Boot Sector Buffer 4648 000017D9 E82304 call write_hd_sector 4649 000017DC 0F82EDFC jc formatting_error 4650 000017E0 E899FC call write_format_percent 4651 000017E3 83C001 add ax, 1 4652 000017E6 83D200 adc dx, 0 4653 ; write remain part of reserved sectors 4654 000017E9 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 4655 ;sub cx, 1 4656 ;jna short FAT12_f_3 4657 ; 11/02/2019 4658 000017EC 49 dec cx 4659 000017ED 7418 jz short FAT12_f_3 4660 FAT12_f_2: 4661 000017EF 51 push cx 4662 000017F0 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 4663 000017F3 E80904 call write_hd_sector 4664 000017F6 0F82D3FC jc formatting_error 4665 000017FA E87FFC call write_format_percent 4666 000017FD 83C001 add ax, 1 4667 00001800 83D200 adc dx, 0 4668 00001803 59 pop cx 4669 00001804 49 dec cx ; dec cl 4670 00001805 75E8 jnz short FAT12_f_2 4671 FAT12_f_3: 4672 ; write FAT sectors 4673 00001807 8B0E[6A6A] mov cx, [data_start] ; lba/abs addr 4674 0000180B 8B1E[6C6A] mov bx, [data_start+2] ; lba/abs addr 4675 4676 ; 11/02/2019 4677 0000180F 2B0E[766A] sub cx, [root_dir_secs] 4678 00001813 83DB00 sbb bx, 0 4679 4680 00001816 53 push bx 4681 00001817 51 push cx 4682 00001818 BB[6A68] mov bx, HDFORMAT_FATBUFFER 4683 ; ES:BX = FAT Sector Buffer 4684 0000181B 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 4685 0000181E B5FF mov ch, 0FFh 4686 00001820 890F mov [bx], cx ; 0FFF8h 4687 00001822 886F02 mov [bx+2], ch ; 0FFFFF8h 4688 ;xor cx, cx 4689 00001825 E8D703 call write_hd_sector 4690 00001828 0F82A1FC jc formatting_error 4691 0000182C E84DFC call write_format_percent 4692 ;mov bx, HDFORMAT_FATBUFFER 4693 0000182F B90000 mov cx, 0 4694 00001832 890F mov [bx], cx 4695 00001834 884F02 mov [bx+2], cl 4696 00001837 EB0F jmp short FAT12_f_5 4697 FAT12_f_4: 4698 00001839 53 push bx 4699 0000183A 51 push cx 4700 0000183B BB[6A68] mov bx, HDFORMAT_FATBUFFER 4701 0000183E E8BE03 call write_hd_sector 4702 00001841 0F8288FC jc formatting_error 4703 00001845 E834FC call write_format_percent 4704 FAT12_f_5: 4705 00001848 59 pop cx 4706 00001849 5B pop bx 4707 0000184A 83C001 add ax, 1 4708 0000184D 83D200 adc dx, 0 4709 00001850 39DA cmp dx, bx 4710 00001852 72E5 jb short FAT12_f_4 4711 00001854 39C8 cmp ax, cx 4712 00001856 72E1 jb short FAT12_f_4 4713 4714 ; write root directory sectors 4715 ; as empty sectors 4716 00001858 8B0E[766A] mov cx, [root_dir_secs] 4717 FAT12_f_6: 4718 0000185C 51 push cx 4719 0000185D BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 4720 00001860 E89C03 call write_hd_sector 4721 00001863 0F8266FC jc formatting_error 4722 00001867 E812FC call write_format_percent 4723 0000186A 83C001 add ax, 1 4724 0000186D 83D200 adc dx, 0 4725 00001870 59 pop cx 4726 00001871 49 dec cx ; dec cl 4727 00001872 75E8 jnz short FAT12_f_6 4728 4729 ; write DATA sectors 4730 ; (after root directory sectors) 4731 00001874 8B0E[6E6A] mov cx, [data_sectors] 4732 ;mov bx, [data_sectors+2] 4733 ;inc bx ; 11/02/2019 4734 FAT12_f_7: 4735 ;push bx 4736 00001878 51 push cx 4737 00001879 BB[5664] mov bx, HDFORMAT_SECBUFFER 4738 0000187C E88003 call write_hd_sector 4739 0000187F 0F824AFC jc formatting_error 4740 00001883 E8F6FB call write_format_percent 4741 00001886 59 pop cx 4742 ;pop bx 4743 00001887 83C001 add ax, 1 4744 0000188A 83D200 adc dx, 0 4745 0000188D 49 dec cx 4746 0000188E 75E8 jnz short FAT12_f_7 4747 ;dec bx 4748 ;jnz short FAT12_f_7 4749 4750 ; If there are, format remain sectors which are 4751 ; at beyond of data clusters, with zero bytes. 4752 4753 00001890 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 4754 00001893 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4755 4756 00001896 034E13 add cx, [bp+13h] ; [BPB_TotSec16] 4757 00001899 83D300 adc bx, 0 4758 0000189C E99FFA jmp FAT12_f_8 4759 4760 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4761 ; SINGLIX FS FORMATTING 4762 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4763 4764 ; 20/03/2021 4765 ; 19/03/2021 4766 SINGLIX_hd_format: 4767 ; 06/01/2018 4768 ; 05/01/2018 4769 ; If Sectors/Track = 17, use CHS+LBA type boot sector 4770 0000189F 8B1E[863F] mov bx, [sectors] 4771 000018A3 83FB11 cmp bx, 17 4772 000018A6 7711 ja short SINGLIX_fs1_f_1 4773 SINGLIX_fs1_f_0: 4774 000018A8 BD[733B] mov bp, TRDOS_TRFS1_chs_bs 4775 000018AB 887E2D mov [bp+45], bh ; 0 ; [bs_LBA_Ready] = 0 4776 000018AE 885E2E mov [bp+46], bl ; [bs_Disk_SecPerTrack] 4777 000018B1 A0[883F] mov al, [heads] 4778 000018B4 88462F mov [bp+47], al ; [bs_Disk_Heads] 4779 000018B7 EB15 jmp short SINGLIX_fs1_f_3 4780 SINGLIX_fs1_f_1: 4781 ; Sectors per Track = 63 4782 ; If disk capacity >= 63*16*1024 use LBA type boot sector 4783 000018B9 8B0E[883F] mov cx, [heads] 4784 000018BD A1[8A3F] mov ax, [cylinders] 4785 000018C0 F7E1 mul cx 4786 000018C2 21D2 and dx, dx 4787 000018C4 7505 jnz short SINGLIX_fs1_f_2 4788 000018C6 3D0040 cmp ax, 16384 4789 000018C9 72DD jb short SINGLIX_fs1_f_0 4790 SINGLIX_fs1_f_2: 4791 000018CB BD[733D] mov bp, TRDOS_TRFS1_lba_bs 4792 ;mov byte [bp+45], 1 ; [bs_LBA_Ready] = 1 4793 SINGLIX_fs1_f_3: 4794 ;mov ax, [pp_Sectors] 4795 ;mov dx, [pp_Sectors+2] 4796 ; 16/02/2019 4797 000018CE A1[226D] mov ax, [ppn_Sectors] 4798 000018D1 8B16[246D] mov dx, [ppn_Sectors+2] 4799 000018D5 894610 mov [bp+16], ax ; [bsVolumeSize] 4800 000018D8 895612 mov [bp+18], dx ; [bsVolumeSize+2] 4801 000018DB 8B0E[F06C] mov cx, [pp_StartSector] 4802 000018DF 8B1E[F26C] mov bx, [pp_StartSector+2] 4803 000018E3 894E0C mov [bp+12], cx ; [bsBeginSector] 4804 000018E6 895E0E mov [bp+14], bx ; [bsBeginSector+2] 4805 000018E9 C6462C80 mov byte [bp+44], 80h ; [bsDriveNumber] ; hd0 4806 4807 ; Prepare MAT 4808 000018ED A3[D06A] mov [MAT_VolumeSize], ax ; Total Sectors of the FS 4809 000018F0 8916[D26A] mov [MAT_VolumeSize+2], dx 4810 000018F4 890E[D46A] mov [MAT_BeginSector], cx ; Beginning Sector of the FS 4811 000018F8 891E[D66A] mov [MAT_BeginSector+2], bx 4812 ;mov cx, [bp+24] ; [bsMATLocation] 4813 ;mov bx, [bp+26] ; [bsMATLocation+2] 4814 ;add cx, 1 4815 ;adc bx, 0 4816 ; Note: (as Default) MAT Address = 1, DAT Address = 2 4817 000018FC B90200 mov cx, 2 4818 ;xor bx, bx ; 0 4819 ;mov [bp+24], cx ; [bsMATLocation] 4820 ;mov [bp+26], bx ; [bsMATLocation+2] 4821 000018FF 890E[D86A] mov [DAT_Address], cx 4822 ;mov [DAT_Address+2], bx 4823 ; DX_AX = FS1 Volume Size 4824 00001903 83C007 add ax, 7 ; 7 bits more (for round up) 4825 00001906 83D200 adc dx, 0 4826 00001909 B90800 mov cx, 8 ; 1 DAT byte == 8 sectors 4827 0000190C E86EF3 call div32 4828 ; DX_AX = DAT bytes 4829 0000190F B9FF01 mov cx, 511 4830 00001912 01C8 add ax, cx 4831 00001914 83D200 adc dx, 0 4832 00001917 41 inc cx ; 512 4833 00001918 E862F3 call div32 4834 ; DX_AX = DAT sectors (DX must be 0 for volume sizes < 128GB) 4835 0000191B A3[DC6A] mov [DAT_SectorCount], ax 4836 ; 19/03/2021 4837 0000191E 8916[DE6A] mov [DAT_SectorCount+2], dx 4838 4839 00001922 83C002 add ax, 2 ; BS + MAT 4840 00001925 83D200 adc dx, 0 ; 19/03/2021 4841 00001928 89461C mov [bp+28], ax ; [bsRootDirDT] ; RDT address (offset) 4842 0000192B 89561E mov [bp+30], dx ; 19/03/2021 4843 4844 ; Free Sectors = Total Sectors - (BS+MAT+DATsects+RDT+4) 4845 0000192E 83C005 add ax, 5 ; DATsects + (BS+MAT+RDT+4) 4846 ; 19/03/2021 4847 00001931 83D200 adc dx, 0 4848 ;mov dx, ax ; ? ; 19/03/2021 4849 00001934 8B0E[D06A] mov cx, [MAT_VolumeSize] 4850 00001938 8B1E[D26A] mov bx, [MAT_VolumeSize+2] 4851 0000193C 29C1 sub cx, ax 4852 ; 19/03/2021 4853 ;sbb bx, 0 4854 0000193E 19D3 sbb bx, dx 4855 4856 00001940 890E[E06A] mov [MAT_FreeSectors], cx 4857 00001944 891E[E26A] mov [MAT_FreeSectors+2], bx 4858 00001948 A3[E46A] mov [MAT_FirstFreeSector], ax 4859 ;mov word [MAT_FirstFreeSector+2], 0 4860 ; 19/03/2021 4861 0000194B 8916[E66A] mov [MAT_FirstFreeSector+2], dx 4862 4863 0000194F BF[7C6A] mov di, fs_volume_name 4864 00001952 E816FA call write_fs_volume_name 4865 00001955 BE[BC6A] mov si, fs_volume_serial 4866 00001958 E876FA call write_volume_serial 4867 4868 ; Modify FS volume name 4869 ; (Convert 20h tail bytes to 0) 4870 0000195B B94000 mov cx, 64 4871 0000195E BE[7C6A] mov si, fs_volume_name 4872 00001961 31DB xor bx, bx 4873 00001963 B0FF mov al, 0FFh 4874 modify_fs_vname_1: 4875 00001965 88C4 mov ah, al 4876 00001967 AC lodsb 4877 00001968 3C20 cmp al, 20h 4878 0000196A 7708 ja short modify_fs_vname_2 4879 0000196C 80FC20 cmp ah, 20h 4880 0000196F 7603 jna short modify_fs_vname_2 4881 00001971 89F3 mov bx, si 4882 00001973 4B dec bx 4883 modify_fs_vname_2: 4884 00001974 E2EF loop modify_fs_vname_1 4885 00001976 09DB or bx, bx 4886 00001978 740B jz short modify_fs_vname_3 4887 0000197A 89DF mov di, bx 4888 0000197C B9[BC6A] mov cx, fs_volume_name+64 4889 0000197F 29D9 sub cx, bx 4890 00001981 30C0 xor al, al 4891 00001983 F3AA rep stosb 4892 4893 modify_fs_vname_3: 4894 00001985 E8D0FA call write_formatting_msg 4895 00001988 B000 mov al, 0 4896 0000198A E82CFB call write_format_percent_x 4897 4898 0000198D 8B460C mov ax, [bp+12] ; [bsBeginSector] 4899 00001990 8B560E mov dx, [bp+14] ; [bsBeginSector+2] 4900 4901 ; DX_AX = TRFS1 Boot Sector address 4902 00001993 89EB mov bx, bp 4903 ; ES:BX = Boot Sector Buffer 4904 00001995 E86702 call write_hd_sector 4905 00001998 0F8231FB jc formatting_error 4906 4907 0000199C 83C001 add ax, 1 4908 0000199F 83D200 adc dx, 0 4909 4910 ; DX_AX = MAT (DAT header) sector address 4911 000019A2 BB[CC6A] mov bx, FS_MAT_Buffer 4912 ; 16/02/2019 4913 000019A5 C7074D41 mov word [bx],'MA' 4914 000019A9 C6470254 mov byte [bx+2],'T' 4915 000019AD E84F02 call write_hd_sector 4916 000019B0 0F8219FB jc formatting_error 4917 000019B4 E809FB call write_fs_format_percent 4918 4919 ; Calculate DAT bits 4920 ; NOTE: 4096 bits per DAT sector 4921 000019B7 A1[E46A] mov ax, [MAT_FirstFreeSector] 4922 ; 19/03/2021 4923 ;xor dx, dx 4924 000019BA 8B16[E66A] mov dx, [MAT_FirstFreeSector+2] 4925 000019BE 52 push dx 4926 000019BF 50 push ax 4927 000019C0 B90010 mov cx, 4096 4928 000019C3 E8B7F2 call div32 4929 000019C6 891E[C06A] mov [DAT_FFBit], bx 4930 000019CA A3[C26A] mov [DAT_FFSector], ax 4931 ; 19/03/2021 4932 000019CD 8916[C46A] mov [DAT_FFSector+2], dx 4933 000019D1 58 pop ax 4934 000019D2 5A pop dx 4935 000019D3 83E801 sub ax, 1 4936 000019D6 83DA00 sbb dx, 0 4937 000019D9 0306[E06A] add ax, [MAT_FreeSectors] 4938 000019DD 1316[E26A] adc dx, [MAT_FreeSectors+2] 4939 000019E1 E899F2 call div32 4940 000019E4 891E[C66A] mov [DAT_LFBit], bx 4941 000019E8 A3[C86A] mov [DAT_LFSector], ax 4942 ; 19/03/2021 4943 000019EB 8916[CA6A] mov [DAT_LFSector+2], dx 4944 ; 4945 000019EF 31F6 xor si, si ; 0 4946 ; 19/03/2021 4947 000019F1 8936[CA70] mov [tempword], si ; 0 4948 SINGLIX_fs1_f_4: 4949 ; calculate free bits for current DAT sector 4950 ; (to be written) 4951 000019F5 BF[E86A] mov di, FS_DAT_Buffer 4952 4953 ; 19/03/2021 4954 000019F8 A1[CA70] mov ax, [tempword] 4955 000019FB 3B06[C46A] cmp ax, [DAT_FFSector+2] 4956 000019FF 7260 jb short SINGLIX_fs1_f_9 4957 00001A01 7708 ja short SINGLIX_fs1_f_13 4958 4959 00001A03 3B36[C26A] cmp si, [DAT_FFSector] 4960 00001A07 743A je short SINGLIX_fs1_f_7 4961 00001A09 7256 jb short SINGLIX_fs1_f_9 4962 SINGLIX_fs1_f_13: 4963 ; 19/03/2021 4964 00001A0B 3B06[CA6A] cmp ax, [DAT_LFSector+2] 4965 00001A0F 722D jb short SINGLIX_fs1_f_6 4966 00001A11 774E ja short SINGLIX_fs1_f_9 4967 4968 00001A13 3B36[C86A] cmp si, [DAT_LFSector] 4969 00001A17 7225 jb short SINGLIX_fs1_f_6 4970 00001A19 7746 ja short SINGLIX_fs1_f_9 4971 4972 ;mov bx, [DAT_LFBit] 4973 ;;mov al, 0FFh 4974 ;mov ah, bl 4975 ;shr bx, 3 ; bit count to byte count 4976 ;jz short SINGLIX_fs1_f_5 4977 ; 20/03/2021 4978 00001A1B 8B0E[C66A] mov cx, [DAT_LFBit] 4979 00001A1F 88CC mov ah, cl 4980 00001A21 C1E903 shr cx, 3 ; bit count to byte count 4981 00001A24 7404 jz short SINGLIX_fs1_f_5 4982 ;Example: 4983 ;last free sector = 47 -> byte 5, bit 7 4984 ;last free sector = 48 -> byte 6, bit 0 4985 ; (also previous sectors are free sectors) 4986 00001A26 B0FF mov al, 0FFh ; 20/03/2021 4987 ;mov cx, bx 4988 00001A28 F3AA rep stosb 4989 ; 20/03/2021 4990 ;mov di, FS_DAT_Buffer 4991 ;add di, bx 4992 SINGLIX_fs1_f_5: 4993 00001A2A 80E407 and ah, 7 4994 ;mov cl, ah 4995 ;shl al, cl 4996 ;not al 4997 ; 20/03/2021 4998 00001A2D 30C0 xor al, al 4999 SINGLIX_fs1_f_15: 5000 ; 20/03/2021 5001 ; 0 -> 00000001b (last free bit is bit 0) 5002 ; 1 -> 00000011b (last free bit is bit 1) 5003 ; 7 -> 11111111b (last free bit is bit 7) 5004 00001A2F 0C01 or al, 1 5005 00001A31 08E4 or ah, ah 5006 00001A33 7406 jz short SINGLIX_fs1_f_16 5007 00001A35 D0E0 shl al, 1 5008 00001A37 FECC dec ah 5009 00001A39 EBF4 jmp short SINGLIX_fs1_f_15 5010 SINGLIX_fs1_f_16: 5011 00001A3B AA stosb 5012 ;mov cx, 511 5013 ;sub cx, bx 5014 ;jna short SINGLIX_fs1_f_9 5015 ;mov al, 0 ; out of volume bits (=0) 5016 ;rep stosb 5017 00001A3C EB23 jmp short SINGLIX_fs1_f_9 5018 SINGLIX_fs1_f_6: 5019 00001A3E B90002 mov cx, 512 5020 00001A41 EB1A jmp short SINGLIX_fs1_f_8 5021 SINGLIX_fs1_f_7: 5022 ; 20/03/2021 5023 ;Example: 5024 ;first free sector = 23 -> byte 2, bit 7 5025 ;first free sector = 24 -> byte 3, bit 0 5026 ; (previous sectors are allocated sectors) 5027 00001A43 8B1E[C06A] mov bx, [DAT_FFBit] 5028 00001A47 88D9 mov cl, bl 5029 00001A49 80E107 and cl, 7 5030 00001A4C C1EB03 shr bx, 3 ; from bits to bytes 5031 00001A4F 01DF add di, bx 5032 00001A51 B0FF mov al, 0FFh 5033 00001A53 D2E0 shl al, cl 5034 00001A55 AA stosb 5035 00001A56 B9FF01 mov cx, 511 5036 00001A59 29D9 sub cx, bx 5037 00001A5B 7604 jna short SINGLIX_fs1_f_9 5038 SINGLIX_fs1_f_8: 5039 00001A5D B0FF mov al, 0FFh ; Free sector bits (=1) 5040 00001A5F F3AA rep stosb 5041 SINGLIX_fs1_f_9: 5042 00001A61 A1[D46A] mov ax, [MAT_BeginSector] 5043 00001A64 8B16[D66A] mov dx, [MAT_BeginSector+2] 5044 ;add ax, [DAT_Address] ; = 2 5045 ;adc dx, [DAT_Address+2] 5046 00001A68 83C002 add ax, 2 5047 00001A6B 83D200 adc dx, 0 5048 00001A6E 01F0 add ax, si 5049 00001A70 83D200 adc dx, 0 5050 ; Write DAT sector(s) 5051 ; DX_AX = Disk Allocation Table sector address 5052 00001A73 BB[E86A] mov bx, FS_DAT_Buffer 5053 00001A76 E88601 call write_hd_sector 5054 00001A79 0F8250FA jc formatting_error 5055 00001A7D E840FA call write_fs_format_percent 5056 ; Clear DAT buffer again (for next stage) 5057 00001A80 B90001 mov cx, 256 5058 00001A83 BF[E86A] mov di, FS_DAT_Buffer 5059 00001A86 29C0 sub ax, ax 5060 00001A88 F3AB rep stosw 5061 5062 00001A8A 46 inc si 5063 ; 19/03/2021 5064 00001A8B 7504 jnz short SINGLIX_fs1_f_14 5065 5066 ; 19/03/2021 5067 00001A8D FF06[CA70] inc word [tempword] 5068 SINGLIX_fs1_f_14: 5069 00001A91 A1[CA70] mov ax, [tempword] 5070 00001A94 3B06[DE6A] cmp ax, [DAT_SectorCount+2] 5071 00001A98 0F8259FF jb SINGLIX_fs1_f_4 5072 5073 00001A9C 3B36[DC6A] cmp si, [DAT_SectorCount] 5074 ;jna SINGLIX_fs1_f_4 5075 ; 19/03/2021 (bugfix) 5076 00001AA0 0F8251FF jb SINGLIX_fs1_f_4 5077 5078 ; ;;; 5079 5080 ; DAT sectors has been written.. 5081 ; Now, Root Directory Description Table is in order 5082 5083 00001AA4 BF[E86A] mov di, FS_RDT_Buffer 5084 00001AA7 B84444 mov ax, 'DD' 5085 00001AAA AB stosw 5086 00001AAB 30E4 xor ah, ah 5087 00001AAD B054 mov al, 'T' 5088 00001AAF AB stosw 5089 00001AB0 B80002 mov ax, 512 ; Sector size (Bytes per sector) 5090 00001AB3 AB stosw 5091 00001AB4 31C0 xor ax, ax ; RDT sequence number (= 0, section 1) 5092 00001AB6 AB stosw 5093 ; RDT address 5094 00001AB7 A1[DC6A] mov ax, [DAT_SectorCount] 5095 00001ABA 8B16[DE6A] mov dx, [DAT_SectorCount+2] 5096 00001ABE 83C002 add ax, 2 ; BS + MAT 5097 00001AC1 83D200 adc dx, 0 5098 00001AC4 AB stosw 5099 00001AC5 89D0 mov ax, dx 5100 00001AC7 AB stosw 5101 00001AC8 29C0 sub ax, ax ; Next RDT number 5102 00001ACA AB stosw 5103 00001ACB AB stosw 5104 ;mov ax, 4 ; Sector count of this section 5105 ; ; (4*512)/4 = 512 root dir entries 5106 ; 20/03/2021 5107 00001ACC B004 mov al, 4 5108 00001ACE AB stosw 5109 00001ACF 30C0 xor al, al 5110 00001AD1 AB stosw 5111 ; Volume beginning sector 5112 00001AD2 8B460C mov ax, [bp+12] ; [bsBeginSector] 5113 00001AD5 8B560E mov dx, [bp+14] ; [bsBeginSector+2] 5114 00001AD8 AB stosw 5115 00001AD9 89D0 mov ax, dx 5116 00001ADB AB stosw 5117 00001ADC 31C0 xor ax, ax 5118 00001ADE 48 dec ax ; 0FFFFh 5119 ; Parent Dir Serial (= FFFFFFFFh for root dir) 5120 00001ADF AB stosw 5121 00001AE0 AB stosw 5122 5123 set_fs_volume_serial_number: 5124 00001AE1 BE[BC6A] mov si, fs_volume_serial 5125 00001AE4 A5 movsw 5126 00001AE5 A5 movsw 5127 5128 00001AE6 29C0 sub ax, ax 5129 ;stosb ; sub directory level = 0 5130 ;stosb ; 0, reserved 5131 00001AE8 AB stosw 5132 00001AE9 B004 mov al, 00000100b ; (DOS) System attribute 5133 00001AEB AA stosb ; (DOS) Basic attributes 5134 00001AEC 28C0 sub al, al ; Extended attributes (0 for TRDOS 386) 5135 00001AEE AA stosb 5136 ; 20/03/2021 5137 ;sub ax, ax ; reserved (8) bytes for TR-MULTIX 5138 00001AEF AB stosw 5139 00001AF0 AB stosw 5140 00001AF1 AB stosw 5141 00001AF2 AB stosw 5142 00001AF3 B85254 mov ax, 'RT' ; TRFS Root directory signature 5143 00001AF6 AB stosw 5144 00001AF7 31C0 xor ax, ax ; Country (language, date, text format) 5145 ; (0 = Default, 1 = USA, 90 = Turkiye) 5146 ;stosb 5147 ;stosb ; Time Zone (0 = GMT = default ; -11 to +12) 5148 00001AF9 AB stosw 5149 5150 00001AFA 89FE mov si, di 5151 ; get the date (from RTC) 5152 00001AFC B404 mov ah, 4 5153 00001AFE CD1A int 1Ah 5154 ; Creating Date (of root directory) 5155 00001B00 86E9 xchg ch, cl ; 07/01/2018 5156 00001B02 89C8 mov ax, cx ; cl = century (BCD), ch = year (BCD) 5157 00001B04 AB stosw 5158 00001B05 88F0 mov al, dh ; month (BCD) 5159 00001B07 AA stosb 5160 00001B08 88D0 mov al, dl ; day (BCD) 5161 00001B0A AA stosb 5162 ; get the time (from RTC) 5163 00001B0B B402 mov ah, 2 5164 00001B0D CD1A int 1Ah 5165 ; Creating Time (of root directory) 5166 00001B0F 86CD xchg cl, ch ; ch = hour (BCD), cl = minute (BSD) 5167 00001B11 89C8 mov ax, cx ; al = hour, ah = minute 5168 00001B13 AB stosw 5169 00001B14 88F0 mov al, dh ; seconds (BCD) 5170 00001B16 AA stosb 5171 00001B17 88D0 mov al, dl ; daylight savings time option 5172 00001B19 AA stosb 5173 ; Set Last Modification Date&Time 5174 00001B1A B90400 mov cx, 4 5175 00001B1D F3A5 rep movsw ; copy creating date&time values to 5176 ; last modification date time values 5177 ; (last modif date&time = creating date&time) 5178 5179 set_fs_volume_name: 5180 00001B1F BE[7C6A] mov si, fs_volume_name 5181 00001B22 B120 mov cl, 32 5182 00001B24 F3A5 rep movsw 5183 5184 ; Fill remain bytes (of this RDT) with zero 5185 00001B26 B9C000 mov cx, (128+256)/2 5186 00001B29 31C0 xor ax, ax 5187 00001B2B F3AB rep stosw 5188 5189 ; RDT is ready here... 5190 5191 00001B2D 8B461C mov ax, [bp+28] ; [bsRootDirDT] 5192 00001B30 8B561E mov dx, [bp+30] ; [bsRootDirDT+2] 5193 ; 20/03/2021 5194 ;xor dx, dx 5195 00001B33 03460C add ax, [bp+12] ; [bsBeginSector] 5196 00001B36 13560E adc dx, [bp+14] ; [bsBeginSector+2] 5197 5198 ; Write RDT sector 5199 ; DX_AX = Root Directory Description Table address 5200 00001B39 BB[E86A] mov bx, FS_RDT_Buffer 5201 00001B3C E8C000 call write_hd_sector 5202 00001B3F 0F828AF9 jc formatting_error 5203 00001B43 E87AF9 call write_fs_format_percent 5204 5205 00001B46 83C001 add ax, 1 5206 00001B49 83D200 adc dx, 0 5207 5208 ; write root directory data sectors 5209 00001B4C B90400 mov cx, 4 5210 5211 SINGLIX_fs1_f_10: 5212 00001B4F 51 push cx 5213 ; Write root directory sector(s) 5214 ; DX_AX = Root Directory Sector address 5215 00001B50 BB[6A68] mov bx, HDFORMAT_EMPTY_BUFF 5216 00001B53 E8A900 call write_hd_sector 5217 00001B56 0F8273F9 jc formatting_error 5218 00001B5A E863F9 call write_fs_format_percent 5219 00001B5D 83C001 add ax, 1 5220 00001B60 83D200 adc dx, 0 5221 00001B63 59 pop cx 5222 00001B64 FEC9 dec cl 5223 00001B66 75E7 jnz short SINGLIX_fs1_f_10 5224 5225 ; Fill remain sectors with 'F6h' bytes 5226 00001B68 8B4E10 mov cx, [bp+16] ; [bsVolumeSize] 5227 00001B6B 8B5E12 mov bx, [bp+18] ; [bsVolumeSize+2] 5228 00001B6E 034E0C add cx, [bp+12] ; [bsBeginSector] 5229 00001B71 135E0E adc bx, [bp+14] ; [bsBeginSector+2] 5230 5231 ; write DATA sectors 5232 ; (after root directory sectors) 5233 SINGLIX_fs1_f_11: 5234 00001B74 53 push bx 5235 00001B75 51 push cx 5236 00001B76 BB[5664] mov bx, HDFORMAT_SECBUFFER 5237 00001B79 E88300 call write_hd_sector 5238 00001B7C 0F824DF9 jc formatting_error 5239 00001B80 E8F9F8 call write_format_percent 5240 00001B83 59 pop cx 5241 00001B84 5B pop bx 5242 00001B85 83C001 add ax, 1 5243 00001B88 83D200 adc dx, 0 5244 00001B8B 39DA cmp dx, bx 5245 00001B8D 72E5 jb short SINGLIX_fs1_f_11 5246 00001B8F 0F87CDF7 ja SINGLIX_fs1_f_12 5247 00001B93 39C8 cmp ax, cx 5248 00001B95 72DD jb short SINGLIX_fs1_f_11 5249 00001B97 E9C6F7 jmp SINGLIX_fs1_f_12 5250 5251 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5252 ; print messages 5253 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5254 5255 print_msg: 5256 5257 print_msg_LOOP: 5258 00001B9A AC lodsb ; Load byte at DS:SI to AL 5259 00001B9B 20C0 and al, al 5260 00001B9D 7409 jz short print_msg_OK 5261 00001B9F B40E mov ah, 0Eh 5262 00001BA1 BB0700 mov bx, 07h 5263 00001BA4 CD10 int 10h ; BIOS Service func ( ah ) = 0Eh 5264 ; Write char as TTY 5265 ; AL-char BH-page BL-color 5266 00001BA6 EBF2 jmp short print_msg_LOOP 5267 5268 print_msg_OK: 5269 00001BA8 C3 retn 5270 5271 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5272 ; reading a block (sector) on hard disk 5273 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5274 ; 17/10/2020 5275 5276 read_hd_sector: 5277 5278 ; INPUT -> DX_AX = Logical Block Address 5279 ; ES:BX = Sector Buffer 5280 ; OUTPUT -> 5281 ; cf = 0 -> DX_AX = Logical Block Adress 5282 ; ES:BX = Sector Buffer 5283 ; cf = 1 -> AH = Error Number 5284 5285 00001BA9 3B16[6468] cmp dx, [chs_limit+2] 5286 00001BAD 770F ja short read_lba_sector 5287 00001BAF 7206 jb short read_chs_sector 5288 00001BB1 3B06[6268] cmp ax, [chs_limit] 5289 00001BB5 7707 ja short read_lba_sector 5290 ;jmp short read_chs_sector 5291 5292 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5293 ; reading a block (sector) by using CHS read (ROMBIOS) function 5294 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5295 ; 17/10/2020 5296 5297 read_chs_sector: 5298 ; hdformat.s (25/09/2020) 5299 00001BB7 C606[5C68]02 mov byte [rw], 2 ; read 5300 00001BBC EB54 jmp short chs_rw 5301 5302 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5303 ; reading a block (sector) by using LBA read (ROMBIOS) function 5304 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5305 ; 17/10/2020 5306 5307 read_lba_sector: 5308 ; hdformat.s (25/09/2020) 5309 00001BBE C606[5C68]42 mov byte [rw], 42h 5310 00001BC3 EB05 jmp short lba_rw 5311 5312 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5313 ; writing a block (sector) by using LBA write (ROMBIOS) function 5314 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5315 ; 17/10/2020 5316 5317 ; 18/10/2020 5318 write_lba_sector: 5319 ; hdformat.s (25/09/2020) 5320 00001BC5 C606[5C68]43 mov byte [rw], 43h 5321 ;jmp short lba_rw 5322 lba_rw: 5323 ;mov di, 5 5324 ; 18/10/2020 5325 00001BCA C606[5D68]05 mov byte [rcnt], 5 ; Retry count 5326 lba_rw_1: 5327 ;pusha ; db 60h 5328 00001BCF 60 db 60h 5329 ;push 0 ; db 6Ah, 00h 5330 00001BD0 6A00 db 6Ah, 0 5331 ;push 0 ; db 6Ah, 00h 5332 00001BD2 6A00 db 6Ah, 0 5333 00001BD4 52 push dx 5334 00001BD5 50 push ax 5335 00001BD6 06 push es 5336 00001BD7 53 push bx 5337 ;push 1 ; db 6Ah, 01h 5338 00001BD8 6A01 db 6Ah, 01h 5339 ;push 10h ; db 6Ah, 10h 5340 00001BDA 6A10 db 6Ah, 10h 5341 5342 00001BDC 89E6 mov si, sp 5343 00001BDE 8A16[5A68] mov dl, [DrvNum] 5344 00001BE2 30C0 xor al, al ; verify off 5345 lba_rw_2: 5346 00001BE4 8A26[5C68] mov ah, [rw] ; 42h = LBA read, 43h = LBA write 5347 ;xor al, al ; verify off 5348 00001BE8 CD13 int 13h 5349 5350 ;mov [error], ah 5351 00001BEA 7310 jnc short lba_rw_3 5352 5353 ;dec di 5354 ; 18/10/2020 5355 00001BEC FE0E[5D68] dec byte [rcnt] 5356 00001BF0 740A jz short lba_rw_3 5357 5358 00001BF2 30E4 xor ah, ah 5359 ;mov dl, [DrvNum] 5360 00001BF4 CD13 int 13h ; BIOS Service func (ah) = 0 5361 ; Reset disk system 5362 5363 ;mov word [si+2], 1 ; set r/w count to 1 again 5364 00001BF6 C6440201 mov byte [si+2], 1 5365 5366 00001BFA EBE8 jmp short lba_rw_2 5367 5368 lba_rw_3: 5369 ;popa 5370 00001BFC 61 db 61h 5371 ;popa 5372 00001BFD 61 db 61h 5373 00001BFE C3 retn 5374 5375 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5376 ; writing a block (sector) on hard disk 5377 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5378 ; 17/10/2020 5379 5380 write_hd_sector: 5381 5382 ; INPUT -> DX_AX = Logical Block Address 5383 ; ES:BX = Sector Buffer 5384 ; OUTPUT -> 5385 ; cf = 0 -> DX_AX = Logical Block Adress 5386 ; ES:BX = Sector Buffer 5387 ; cf = 1 -> AH = Error Number 5388 5389 00001BFF 3B16[6468] cmp dx, [chs_limit+2] 5390 00001C03 77C0 ja short write_lba_sector 5391 00001C05 7206 jb short write_chs_sector 5392 00001C07 3B06[6268] cmp ax, [chs_limit] 5393 00001C0B 77B8 ja short write_lba_sector 5394 ;jmp short write_chs_sector 5395 5396 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5397 ; writing a block (sector) by using CHS write (ROMBIOS) function 5398 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5399 ; 17/10/2020 5400 5401 ; 18/10/2020 5402 write_chs_sector: 5403 ; hdformat.s (25/09/2020) 5404 00001C0D C606[5C68]03 mov byte [rw], 3 ; write 5405 ;jmp short chs_rw 5406 chs_rw: 5407 00001C12 56 push si 5408 00001C13 51 push cx 5409 chs_rw_0: 5410 ;mov di, 5 5411 ; 18/10/2020 5412 00001C14 C606[5D68]05 mov byte [rcnt], 5 ; Retry count 5413 chs_rw_1: 5414 00001C19 52 push dx ; Linear sector # 5415 00001C1A 50 push ax ; DX_AX = Linear address (sectors) 5416 00001C1B 8B0E[863F] mov cx, [sectors] 5417 00001C1F 53 push bx 5418 5419 00001C20 E85AF0 call div32 ; 32 bit divide 5420 5421 00001C23 89D9 mov cx, bx ; Sector (zero based) 5422 00001C25 41 inc cx ; To make it 1 based 5423 00001C26 51 push cx 5424 00001C27 8B0E[883F] mov cx, [heads] 5425 00001C2B E84FF0 call div32 ; Convert track to head & cyl 5426 00001C2E 88DE mov dh, bl ; BX = Head (max. FFh) 5427 00001C30 59 pop cx ; AX=Cyl, DH=Head, CX=Sector 5428 00001C31 5B pop bx ; ES:BX = Buffer 5429 5430 00001C32 8A16[5A68] mov dl, [DrvNum] 5431 00001C36 88C5 mov ch, al 5432 00001C38 D0CC ror ah, 1 ; Rotate right 5433 00001C3A D0CC ror ah, 1 5434 00001C3C 08E1 or cl, ah 5435 chs_rw_2: 5436 00001C3E 8A26[5C68] mov ah, [rw] ; 02h = read, 03h = write 5437 00001C42 B001 mov al, 01h 5438 00001C44 CD13 int 13h ; BIOS Service func (ah) = 2/3 5439 ; Read/Write disk sectors 5440 ; AL-sec num CH-track CL-sec 5441 ; DH-head DL-drive ES:BX-buffer 5442 ; CF-flag AH-status AL-sectors written/read 5443 ; If CF = 1 then AH = Error code (>0) 5444 5445 00001C46 730C jnc short chs_rw_3 5446 ;dec di 5447 00001C48 FE0E[5D68] dec byte [rcnt] ; 18/10/2020 5448 00001C4C 7406 jz short chs_rw_3 5449 5450 00001C4E 30E4 xor ah, ah 5451 ;mov dl, [DrvNum] 5452 00001C50 CD13 int 13h ; BIOS Service func (ah) = 0 5453 ; Reset disk system 5454 00001C52 EBEA jmp short chs_rw_2 5455 5456 chs_rw_3: 5457 00001C54 58 pop ax 5458 00001C55 5A pop dx 5459 00001C56 59 pop cx 5460 00001C57 5E pop si 5461 00001C58 C3 retn 5462 5463 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5464 ; convert byte to decimal number 5465 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5466 5467 bin_to_decimal: 5468 ; INPUT: DS:SI = Target location 5469 ; DX_AX = Binary Number (Integer) 5470 ; OUTPUT: Decimal char at DS:SI 5471 ; SI decremented after every division 5472 ; till AX<10. 5473 ; CX, DX, BX will be changed. 5474 ; 5475 00001C59 B90A00 mov cx, 10 5476 btd_0: 5477 ; DX_AX = Dividend 5478 ; CX = Divisor 5479 00001C5C E81EF0 call div32 5480 ; DX_AX = Quotient 5481 ; BX = remainder 5482 00001C5F 80C330 add bl, '0' 5483 00001C62 881C mov [si], bl 5484 00001C64 21D2 and dx, dx 5485 00001C66 7403 jz short btd_2 5486 btd_1: 5487 00001C68 4E dec si 5488 00001C69 EBF1 jmp short btd_0 5489 btd_2: 5490 00001C6B 09C0 or ax, ax 5491 00001C6D 75F9 jnz short btd_1 5492 5493 00001C6F C3 retn 5494 5495 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5496 ; convert byte to hexadecimal number 5497 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5498 5499 byte_to_hex: ; 04/02/2019 5500 bin_to_hex: 5501 ; INPUT -> 5502 ; AL = byte (binary number) 5503 ; OUTPUT -> 5504 ; AX = hexadecimal string 5505 ; 5506 00001C70 53 push bx 5507 00001C71 31DB xor bx, bx 5508 00001C73 88C3 mov bl, al 5509 00001C75 C0EB04 shr bl, 4 5510 00001C78 8A9F[743F] mov bl, [bx+hexchrs] 5511 00001C7C 86D8 xchg bl, al 5512 00001C7E 80E30F and bl, 0Fh 5513 00001C81 8AA7[743F] mov ah, [bx+hexchrs] 5514 00001C85 5B pop bx 5515 00001C86 C3 retn 5516 5517 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5518 ; read & write characters 5519 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5520 5521 rw_char: 5522 ; OUTPUT -> DS:SI = Entered String (ASCIIZ) 5523 00001C87 BE[E454] mov si, StrVolumeName 5524 00001C8A BB0700 mov bx, 7 5525 00001C8D B403 mov ah, 3 5526 00001C8F CD10 int 10h 5527 00001C91 8916[CB54] mov [Cursor_Pos], dx 5528 read_next_char: 5529 00001C95 30E4 xor ah, ah 5530 00001C97 CD16 int 16h 5531 00001C99 20C0 and al, al 5532 00001C9B 7439 jz short loc_arrow 5533 00001C9D 3CE0 cmp al, 0E0h 5534 00001C9F 7435 je short loc_arrow 5535 00001CA1 3C08 cmp al, 8 5536 00001CA3 753D jne short char_return 5537 loc_back: 5538 00001CA5 B403 mov ah, 3 5539 00001CA7 CD10 int 10h 5540 00001CA9 3A16[CB54] cmp dl, byte [Cursor_Pos] 5541 00001CAD 761F jna short loc_beep 5542 prev_column: 5543 00001CAF FECA dec dl 5544 set_cursor_pos: 5545 00001CB1 B402 mov ah, 2 5546 00001CB3 CD10 int 10h 5547 00001CB5 88D3 mov bl, dl 5548 00001CB7 2A1E[CB54] sub bl, byte [Cursor_Pos] 5549 00001CBB B90100 mov cx, 1 5550 00001CBE B409 mov ah, 9 5551 00001CC0 B020 mov al, 20h 5552 00001CC2 8800 mov [si+bx], al 5553 loc_write_it: 5554 00001CC4 B307 mov bl, 7 5555 00001CC6 CD10 int 10h 5556 00001CC8 8B16[CB54] mov dx, [Cursor_Pos] 5557 00001CCC EBC7 jmp short read_next_char 5558 loc_beep: 5559 00001CCE B40E mov ah, 0Eh 5560 00001CD0 B007 mov al, 7 5561 00001CD2 CD10 int 10h 5562 00001CD4 EBBF jmp short read_next_char 5563 loc_arrow: 5564 00001CD6 80FC4B cmp ah, 4Bh 5565 00001CD9 74CA je short loc_back 5566 00001CDB 80FC53 cmp ah, 53h 5567 00001CDE 74C5 je short loc_back 5568 00001CE0 EBB3 jmp short read_next_char 5569 char_return: 5570 00001CE2 B403 mov ah, 3 5571 00001CE4 CD10 int 10h 5572 check_char_type: 5573 00001CE6 3C20 cmp al, 20h 5574 00001CE8 7229 jb short loc_escape 5575 00001CEA 88D4 mov ah, dl 5576 00001CEC 2A26[CB54] sub ah, byte [Cursor_Pos] 5577 ;cmp ah, 10 5578 ;ja short loc_beep 5579 00001CF0 3A26[3F64] cmp ah, [vname_length] ; 05/01/2018 5580 00001CF4 73D8 jnb short loc_beep 5581 00001CF6 3C7A cmp al, 'z' 5582 00001CF8 779B ja short read_next_char 5583 00001CFA 3C61 cmp al, 'a' 5584 00001CFC 7202 jb short pass_capitalize 5585 00001CFE 24DF and al, 0DFh 5586 pass_capitalize: 5587 00001D00 88E3 mov bl, ah 5588 00001D02 30E4 xor ah, ah 5589 00001D04 8900 mov [si+bx], ax 5590 00001D06 B307 mov bl, 7 5591 00001D08 B40E mov ah, 0Eh 5592 00001D0A CD10 int 10h 5593 00001D0C EB87 jmp short read_next_char 5594 pass_escape: 5595 00001D0E 3C0D cmp al, 0Dh ; 13 ; ENTER 5596 00001D10 7583 jne short read_next_char 5597 ;mov ah, 0Eh 5598 ;int 10h 5599 ;mov al, 0Ah 5600 ;int 10h 5601 00001D12 C3 retn 5602 loc_escape: 5603 00001D13 3C1B cmp al, 1Bh ; 27 ; ESC 5604 00001D15 75F7 jne short pass_escape 5605 00001D17 F9 stc 5606 00001D18 C3 retn 5607 5608 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5609 ; display CHS takle 5610 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5611 5612 display_chs_table: 5613 5614 ; 16/10/2020 5615 ; 12/10/2020 (fdisk3) 5616 ; 11/02/2019 (hdimage) 5617 5618 00001D19 06 push es 5619 00001D1A BF00B8 mov di, 0B800h 5620 00001D1D 8EC7 mov es, di 5621 00001D1F BFA000 mov di, 160 ; row 1 5622 00001D22 B407 mov ah, 07h 5623 00001D24 B044 mov al, 'D' 5624 00001D26 AB stosw 5625 00001D27 B069 mov al, 'i' 5626 00001D29 AB stosw 5627 00001D2A B073 mov al, 's' 5628 00001D2C AB stosw 5629 00001D2D B06B mov al, 'k' 5630 00001D2F AB stosw 5631 00001D30 B03A mov al, ':' 5632 00001D32 AB stosw 5633 00001D33 B020 mov al, ' ' 5634 00001D35 AB stosw 5635 00001D36 B068 mov al, 'h' 5636 00001D38 AB stosw 5637 00001D39 B064 mov al, 'd' 5638 00001D3B AB stosw 5639 00001D3C A0[5A68] mov al, [DrvNum] 5640 00001D3F 2C50 sub al, 80h-'0' 5641 00001D41 AB stosw 5642 00001D42 BF4001 mov di, 320 ; row 2 5643 00001D45 B95000 mov cx, 80 5644 00001D48 B82007 mov ax, 0720h 5645 00001D4B F3AB rep stosw 5646 00001D4D B150 mov cl, 80 ; row 3 5647 00001D4F B02D mov al, "-" 5648 00001D51 F3AB rep stosw 5649 ;mov cl, 19 5650 00001D53 B112 mov cl, 18 ; 16/10/2020 ; row 4 5651 00001D55 B020 mov al, 20h 5652 00001D57 F3AB rep stosw 5653 00001D59 B043 mov al, 'C' 5654 00001D5B AB stosw 5655 00001D5C B079 mov al, 'y' 5656 00001D5E AB stosw 5657 00001D5F B06C mov al, 'l' 5658 00001D61 AB stosw 5659 00001D62 B069 mov al, 'i' 5660 00001D64 AB stosw 5661 00001D65 B06E mov al, 'n' 5662 00001D67 AB stosw 5663 00001D68 B064 mov al, 'd' 5664 00001D6A AB stosw 5665 00001D6B B065 mov al, 'e' 5666 00001D6D AB stosw 5667 00001D6E B072 mov al, 'r' 5668 00001D70 AB stosw 5669 00001D71 B073 mov al, 's' 5670 00001D73 AB stosw 5671 00001D74 B03A mov al, ':' 5672 00001D76 AB stosw 5673 00001D77 B020 mov al, 20h 5674 00001D79 AB stosw 5675 ;mov [cylnumpos], di 5676 00001D7A A1[8A3F] mov ax, [cylinders] 5677 00001D7D 8B16[8C3F] mov dx, [cylinders+2] ; 16/10/2020 5678 ;mov cl, 4 5679 ;mov ch, 07h ; color 5680 00001D81 E86A00 call write_number 5681 5682 ;mov ax, 0720h 5683 00001D84 B020 mov al, 20h ; 16/10/2020 5684 00001D86 AB stosw 5685 00001D87 AB stosw 5686 00001D88 B048 mov al, 'H' 5687 00001D8A AB stosw 5688 00001D8B B065 mov al, 'e' 5689 00001D8D AB stosw 5690 00001D8E B061 mov al, 'a' 5691 00001D90 AB stosw 5692 00001D91 B064 mov al, 'd' 5693 00001D93 AB stosw 5694 00001D94 B073 mov al, 's' 5695 00001D96 AB stosw 5696 00001D97 B03A mov al, ':' 5697 00001D99 AB stosw 5698 00001D9A B020 mov al, 20h 5699 00001D9C AB stosw 5700 ;mov [hednumpos], di 5701 00001D9D A1[883F] mov ax, [heads] 5702 00001DA0 31D2 xor dx, dx ; 16/10/2020 5703 ;mov cl, 2 5704 ;mov ch, 07h ; color 5705 00001DA2 E84900 call write_number 5706 5707 ;mov ax, 0720h 5708 00001DA5 B020 mov al, 20h ; 16/10/2020 5709 00001DA7 AB stosw 5710 00001DA8 AB stosw 5711 00001DA9 B053 mov al, 'S' 5712 00001DAB AB stosw 5713 00001DAC B065 mov al, 'e' 5714 00001DAE AB stosw 5715 00001DAF B063 mov al, 'c' 5716 00001DB1 AB stosw 5717 00001DB2 B074 mov al, 't' 5718 00001DB4 AB stosw 5719 00001DB5 B06F mov al, 'o' 5720 00001DB7 AB stosw 5721 00001DB8 B072 mov al, 'r' 5722 00001DBA AB stosw 5723 00001DBB B073 mov al, 's' 5724 00001DBD AB stosw 5725 00001DBE B03A mov al, ':' 5726 00001DC0 AB stosw 5727 00001DC1 B020 mov al, 20h 5728 00001DC3 AB stosw 5729 ;mov [secnumpos], di 5730 00001DC4 A1[863F] mov ax, [sectors] 5731 00001DC7 29D2 sub dx, dx ; 16/10/2020 5732 ;mov cl, 2 5733 ;mov ch, 07h ; color 5734 00001DC9 E82200 call write_number 5735 5736 00001DCC B92003 mov cx, 800 ; 16/10/2020 ; row 5 5737 00001DCF 29F9 sub cx, di 5738 00001DD1 D0E9 shr cl, 1 5739 ;mov cl, 22 5740 ;mov ax, 0720h 5741 00001DD3 B020 mov al, 20h ; 16/10/2020 5742 00001DD5 F3AB rep stosw 5743 5744 00001DD7 B150 mov cl, 80 ; row 6 5745 00001DD9 B02D mov al, "-" 5746 00001DDB F3AB rep stosw 5747 5748 00001DDD B150 mov cl, 80 ; row 7 5749 ;mov cl, 160 ; row 7, 8 5750 00001DDF B020 mov al, 20h 5751 00001DE1 F3AB rep stosw 5752 5753 00001DE3 BA0006 mov dx, 0600h ; DH = row, DL = 0 column 5754 00001DE6 31DB xor bx, bx ; BH = video page (0) 5755 00001DE8 B402 mov ah, 02h ; set cursor position 5756 00001DEA CD10 int 10h 5757 5758 00001DEC 07 pop es 5759 00001DED C3 retn 5760 5761 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5762 ; write decimal number 5763 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5764 5765 ;write_number: 5766 ; ; 12/10/2020 5767 ; mov bx, 10 5768 ; mov si, cx 5769 ;wnum_1: 5770 ; xor dx, dx 5771 ; div bx 5772 ; push dx 5773 ; dec cl 5774 ; jnz short wnum_1 5775 ; mov cx, si 5776 ; mov ah, ch ; color (07h or 0Fh) 5777 ; xor ch, ch 5778 ;wnum_2: 5779 ; pop dx 5780 ; mov al, dl 5781 ; add al, '0' 5782 ; stosw 5783 ; loop wnum_2 5784 ; retn 5785 5786 write_number: 5787 ; 16/10/2020 5788 ; dx:ax = binary number 5789 ; di = decimal number/string location 5790 ; modified registers: ax, bx, cx, dx, bp, di 5791 00001DEE B90A00 mov cx, 10 5792 00001DF1 89E5 mov bp, sp 5793 wnum_1: 5794 00001DF3 E887EE call div32 5795 00001DF6 53 push bx 5796 00001DF7 21D2 and dx, dx 5797 00001DF9 75F8 jnz short wnum_1 5798 00001DFB 09C0 or ax, ax 5799 00001DFD 75F4 jnz short wnum_1 5800 wnum_2: 5801 00001DFF 58 pop ax 5802 00001E00 0430 add al, '0' 5803 00001E02 B407 mov ah, 07h ; color 5804 00001E04 AB stosw 5805 00001E05 39E5 cmp bp, sp 5806 00001E07 77F6 ja short wnum_2 5807 00001E09 C3 retn 5808 5809 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5810 ; partition size input 5811 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5812 5813 ; 12/03/2021 5814 partition_size_input: 5815 ; 23/10/2020 (fdisk3.s modification on hdimage.s source code) 5816 5817 00001E0A C706[026D]0000 mov word [pSize_multiplier+2], 0 5818 00001E10 C606[076D]42 mov byte [msg_psize_unit+1], 'B' 5819 00001E15 A0[066D] mov al, [pSize_unit] 5820 00001E18 3C25 cmp al, '%' 5821 00001E1A 7529 jne short psu_0 5822 ; 08/02/2019 5823 ; calculate sector count for max. available sectors percentage 5824 00001E1C 8B16[F66C] mov dx, [pp_Sectors+2] ; max. available sectors 5825 00001E20 A1[F46C] mov ax, [pp_Sectors] ; for a new partition 5826 ;mov dx, [total_sectors+2] 5827 ;mov ax, [total_sectors] 5828 ;mov cx, 100 5829 ; 13/03/2021 5830 00001E23 B96300 mov cx, 99 5831 00001E26 01C8 add ax, cx 5832 00001E28 83D200 adc dx, 0 5833 00001E2B 41 inc cx ; cx = 100 5834 00001E2C E84EEE call div32 5835 00001E2F A3[006D] mov [pSize_multiplier], ax 5836 ; 29/10/2020 5837 00001E32 8916[026D] mov [pSize_multiplier+2], dx 5838 00001E36 B400 mov ah, 0 5839 00001E38 8826[076D] mov [msg_psize_unit+1], ah 5840 ;mov byte [pSize_maxdigits], 2 5841 00001E3C C606[046D]03 mov byte [pSize_maxdigits], 3 ; 29/10/2020 5842 00001E41 B025 mov al, '%' 5843 00001E43 EB65 jmp short psu_6 5844 psu_0: 5845 00001E45 3C43 cmp al, 'C' 5846 00001E47 7517 jne short psu_1 5847 00001E49 A1[863F] mov ax, [sectors] 5848 00001E4C F726[883F] mul word [heads] 5849 00001E50 A3[006D] mov [pSize_multiplier], ax 5850 ;mov byte [pSize_maxdigits], 4 5851 ; <= 65535 cylinders 5852 00001E53 C606[046D]05 mov byte [pSize_maxdigits], 5 ; 23/10/2020 5853 ;sub dh, dh 5854 00001E58 8836[076D] mov [msg_psize_unit+1], dh 5855 00001E5C B043 mov al, 'C' 5856 00001E5E EB4A jmp short psu_6 5857 psu_1: 5858 00001E60 3C47 cmp al, 'G' 5859 00001E62 7513 jne short psu_2 5860 00001E64 C706[006D]0008 mov word [pSize_multiplier], 2*1024 5861 00001E6A C706[026D]0004 mov word [pSize_multiplier+2], 1024 5862 ;mov byte [pSize_maxdigits], 1 5863 00001E70 C606[046D]03 mov byte [pSize_maxdigits], 3 ; <= 512 GB ; 23/10/2020 5864 00001E75 EB33 jmp short psu_6 5865 psu_2: 5866 00001E77 3C4D cmp al, 'M' 5867 00001E79 750D jne short psu_3 5868 00001E7B C706[006D]0008 mov word [pSize_multiplier], 2*1024 5869 ;;mov byte [pSize_maxdigits], 4 5870 ;mov byte [pSize_maxdigits], 7 ; 23/10/2020 5871 ; 12/03/2021 5872 00001E81 C606[046D]06 mov byte [pSize_maxdigits], 6 ; <= 524288 5873 00001E86 EB22 jmp short psu_6 5874 psu_3: 5875 00001E88 3C4B cmp al, 'K' 5876 00001E8A 750D jne short psu_4 5877 00001E8C C706[006D]0200 mov word [pSize_multiplier], 2 5878 ;jmp short psu_5 5879 ; 12/03/2021 5880 00001E92 C606[046D]09 mov byte [pSize_maxdigits], 9 ; <= 536870912 5881 00001E97 EB11 jmp short psu_6 5882 psu_4: 5883 ; al = 'S' 5884 00001E99 30E4 xor ah, ah 5885 00001E9B 8826[076D] mov [msg_psize_unit+1], ah 5886 00001E9F C706[006D]0100 mov word [pSize_multiplier], 1 5887 psu_5: 5888 ;mov byte [pSize_maxdigits], 7 5889 00001EA5 C606[046D]0A mov byte [pSize_maxdigits], 10 ; 23/10/2020 5890 psu_6: 5891 00001EAA A2[C34E] mov [msg_partition_size_x], al 5892 00001EAD BE[AF4E] mov si, msg_partition_size 5893 00001EB0 E8E7FC call print_msg 5894 5895 00001EB3 89E5 mov bp, sp 5896 00001EB5 31DB xor bx, bx 5897 00001EB7 891E[FC6C] mov [pSize_temp], bx ; 0 5898 ;mov [pSize_temp+2], bx ; 0 5899 00001EBB 881E[056D] mov [pSize_digitpos], bl ; 0 5900 ; bh = 0 ; video page 5901 00001EBF B403 mov ah, 3 ; get cursor pos 5902 00001EC1 CD10 int 10h 5903 00001EC3 8916[CB54] mov [Cursor_Pos], dx 5904 ; 09/02/2019 5905 00001EC7 B307 mov bl, 7 ; page 0, color 7 (light gray) 5906 psu_7: 5907 00001EC9 30E4 xor ah, ah 5908 00001ECB CD16 int 16h 5909 5910 00001ECD 3C30 cmp al, '0' 5911 00001ECF 7225 jb short psu_8 5912 00001ED1 3C39 cmp al, '9' 5913 00001ED3 77F4 ja short psu_7 5914 00001ED5 8A1E[056D] mov bl, [pSize_digitpos] 5915 00001ED9 3A1E[046D] cmp bl, [pSize_maxdigits] 5916 00001EDD 73EA jnb short psu_7 5917 00001EDF FE06[056D] inc byte [pSize_digitpos] 5918 00001EE3 2C30 sub al, '0' 5919 00001EE5 30E4 xor ah, ah 5920 00001EE7 50 push ax 5921 00001EE8 0430 add al, '0' 5922 00001EEA B40E mov ah, 0Eh ; write char as tty 5923 ;mov bx, 7 ; page 0, color 7 (light gray) 5924 00001EEC CD10 int 10h 5925 00001EEE EBD9 jmp short psu_7 5926 5927 psu_8esc: 5928 ; 29/10/2020 (ESCape) 5929 00001EF0 89EC mov sp, bp ; clean stack 5930 5931 00001EF2 08C0 or al, al ; zf = 0 5932 00001EF4 F9 stc 5933 00001EF5 C3 retn 5934 psu_8: 5935 00001EF6 20C0 and al, al 5936 00001EF8 0F849300 jz psu_15 ; check for left arrow key 5937 00001EFC 3C1B cmp al, 27 5938 00001EFE 74F0 je short psu_8esc ; ESCAPE key ; 29/10/2020 5939 00001F00 0F878500 ja psu_14 ; check for left arrow key 5940 00001F04 3C0D cmp al, 13 5941 ;je short psu_9 ; ENTER key 5942 00001F06 7249 jb short psu_11 ; check for backspace key 5943 ;jmp short psu_7 5944 00001F08 77BF ja short psu_7 5945 psu_9: 5946 00001F0A 31C0 xor ax, ax 5947 00001F0C A3[FE6C] mov [pSize_temp+2], ax ; 0 ; 08/02/2019 5948 00001F0F 3806[056D] cmp byte [pSize_digitpos], al ; 0 5949 00001F13 0F868500 jna psu_16 5950 ;xor bh, bh 5951 00001F17 8A1E[056D] mov bl, [pSize_digitpos] 5952 00001F1B FECB dec bl 5953 00001F1D D0E3 shl bl, 1 5954 00001F1F 01E3 add bx, sp 5955 00001F21 8B07 mov ax, [bx] 5956 00001F23 A3[FC6C] mov [pSize_temp], ax 5957 ;mov word [pSize_temp+2], 0 5958 00001F26 B90A00 mov cx, 10 5959 psu_10: 5960 00001F29 FE0E[056D] dec byte [pSize_digitpos] 5961 00001F2D 746D jz short psu_16 5962 5963 00001F2F A1[FC6C] mov ax, [pSize_temp] 5964 00001F32 8B16[FE6C] mov dx, [pSize_temp+2] 5965 ;mov cx, 10 5966 00001F36 E852ED call mul32 5967 ;mov [pSize_temp], ax 5968 ;mov [pSize_temp+2], dx 5969 ;xor bh, bh 5970 00001F39 8A1E[056D] mov bl, [pSize_digitpos] 5971 00001F3D FECB dec bl 5972 00001F3F D0E3 shl bl, 1 5973 00001F41 01E3 add bx, sp ; (*) 5974 ;mov ax, [bx] 5975 ;add [pSize_temp], ax 5976 ;adc word [pSize_temp+2], 0 5977 00001F43 0307 add ax, [bx] 5978 00001F45 83D200 adc dx, 0 5979 00001F48 A3[FC6C] mov [pSize_temp], ax 5980 00001F4B 8916[FE6C] mov [pSize_temp+2], dx 5981 00001F4F EBD8 jmp short psu_10 5982 5983 ; Left arrow, backspace, DEL key checking 5984 psu_11: 5985 00001F51 3C08 cmp al, 8 ; backspace key 5986 00001F53 0F8572FF jne psu_7 5987 psu_12: 5988 ;; bh = 0 ; video page 5989 ;mov ah, 3 ; get cursor pos 5990 ;int 10h 5991 ;cmp dl, [Cursor_Pos] 5992 ;jna short psu_13 5993 ;dec dl 5994 ;dec byte [pSize_digitpos] 5995 5996 ; 08/02/2019 5997 00001F57 8B16[CB54] mov dx, [Cursor_Pos] 5998 00001F5B 8A1E[056D] mov bl, [pSize_digitpos] 5999 00001F5F 20DB and bl, bl 6000 00001F61 741D jz short psu_13 6001 6002 00001F63 FECB dec bl 6003 00001F65 881E[056D] mov [pSize_digitpos], bl 6004 6005 00001F69 00DA add dl, bl 6006 6007 ; bh = 0 ; video page 6008 00001F6B B402 mov ah, 2 ; set cursor pos 6009 00001F6D CD10 int 10h 6010 ;mov bl, dl 6011 ;sub bl, [Cursor_Pos] 6012 00001F6F B90100 mov cx, 1 6013 00001F72 B409 mov ah, 9 ; write char at current curs pos 6014 00001F74 B020 mov al, 20h ; space (blank) 6015 00001F76 8800 mov [si+bx], al 6016 ; bh = 0 ; video page 6017 00001F78 B307 mov bl, 7 ; attribute/color (light gray) 6018 00001F7A CD10 int 10h 6019 6020 ; 09/02/2019 6021 00001F7C 58 pop ax ; remove last digit on top of stack 6022 ; set sp to correct position for BX (*) 6023 00001F7D E949FF jmp psu_7 6024 psu_13: 6025 00001F80 B40E mov ah, 0Eh 6026 00001F82 B007 mov al, 7 6027 ;mov bx, 7 6028 00001F84 CD10 int 10h 6029 00001F86 E940FF jmp psu_7 6030 psu_14: 6031 00001F89 3CE0 cmp al, 0E0h 6032 00001F8B 0F853AFF jne psu_7 6033 psu_15: 6034 00001F8F 80FC4B cmp ah, 4Bh ; left arrow 6035 00001F92 74C3 je short psu_12 6036 00001F94 80FC53 cmp ah, 53h ; DEL key (backspace) 6037 00001F97 74BE je short psu_12 6038 00001F99 E92DFF jmp psu_7 6039 psu_16: 6040 00001F9C 89EC mov sp, bp 6041 6042 ; 29/10/2020 6043 00001F9E 803E[066D]25 cmp byte [pSize_unit], '%' 6044 00001FA3 751E jne short psu_23 6045 6046 00001FA5 B86400 mov ax, 100 6047 00001FA8 3906[FC6C] cmp word [pSize_temp], ax ; 100 ; % limit 6048 00001FAC 7624 jna short psu_17 6049 00001FAE A3[FC6C] mov word [pSize_temp], ax 6050 6051 ; (re)set asciiz number string to '100' 6052 6053 00001FB1 28FF sub bh, bh ; 0 ; video page 0 6054 00001FB3 8B16[CB54] mov dx, [Cursor_Pos] 6055 00001FB7 B402 mov ah, 2 ; set cursor pos 6056 00001FB9 CD10 int 10h 6057 6058 00001FBB BE[5668] mov si, msg_100 6059 00001FBE E8D9FB call print_msg 6060 6061 00001FC1 EB0F jmp short psu_17 6062 psu_23: 6063 00001FC3 803E[066D]53 cmp byte [pSize_unit], 'S' 6064 00001FC8 7508 jne short psu_17 6065 6066 00001FCA BE[3464] mov si, msg_sectors_crlf 6067 00001FCD E8CAFB call print_msg 6068 ;xor bx, bx 6069 00001FD0 EB30 jmp short psu_18 6070 psu_17: 6071 00001FD2 BE[066D] mov si, msg_psize_unit 6072 00001FD5 E8C2FB call print_msg 6073 6074 00001FD8 BE[8755] mov si, CRLF 6075 00001FDB E8BCFB call print_msg 6076 6077 ; 29/10/2020 6078 00001FDE 803E[066D]25 cmp byte [pSize_unit], '%' 6079 00001FE3 751D jne short psu_18 6080 6081 00001FE5 8B0E[FC6C] mov cx, [pSize_temp] 6082 6083 00001FE9 21C9 and cx, cx 6084 00001FEB 7443 jz short psu_21 ; 0%, ZERO ! 6085 6086 00001FED 83F964 cmp cx, 100 6087 00001FF0 7606 jna short psu_24 6088 6089 ; show 100% for 1 second (for >100%) 6090 00001FF2 E83D00 call wait1second ; 29/10/2020 6091 6092 00001FF5 B96400 mov cx, 100 6093 psu_24: 6094 00001FF8 A1[006D] mov ax, [pSize_multiplier] 6095 00001FFB 8B16[026D] mov dx, [pSize_multiplier+2] 6096 6097 ;mov cx, [pSize_temp] 6098 ;and cx, cx 6099 ;jz short psu_21 ; 0%, ZERO ! 6100 6101 00001FFF E989EC jmp mul32 6102 psu_18: 6103 00002002 A1[FC6C] mov ax, [pSize_temp] 6104 00002005 8B16[FE6C] mov dx, [pSize_temp+2] 6105 00002009 89C1 mov cx, ax 6106 0000200B 09D1 or cx, dx 6107 ;jz short psu_20 6108 0000200D 7421 jz short psu_21 ; 08/02/2019 6109 0000200F 8B0E[006D] mov cx, [pSize_multiplier] 6110 00002013 803E[066D]43 cmp byte [pSize_unit], 'C' 6111 00002018 7413 je short psu_20 ; 09/02/2019 6112 ;jne short psu_19 6113 ;call mul32 6114 ; 08/02/2019 6115 ; dx:ax = requested partition size in sectors 6116 ;retn 6117 ;psu_19: 6118 ;mov cx, [pSize_multiplier] 6119 0000201A 83F901 cmp cx, 1 6120 ;jna short psu_20 6121 0000201D 7703 ja short psu_19 6122 ; 09/02/2019 6123 0000201F 31DB xor bx, bx 6124 00002021 C3 retn 6125 psu_19: 6126 00002022 E866EC call mul32 6127 ;and bx, bx 6128 ;jnz short psu_22 ; 09/02/2019 6129 00002025 8B0E[026D] mov cx, [pSize_multiplier+2] 6130 00002029 09C9 or cx, cx 6131 ;jz short psu_20 6132 0000202B 7404 jz short psu_22 ; 09/02/2019 6133 psu_20: 6134 ;call mul32 6135 ;retn 6136 0000202D E95BEC jmp mul32 ; 23/10/2020 6137 psu_21: 6138 ; zf = 1 ; 29/10/2020 6139 00002030 F9 stc 6140 psu_22: 6141 00002031 C3 retn 6142 6143 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6144 ; wait for 1 second 6145 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6146 6147 ; 29/10/2020 6148 wait1second: 6149 00002032 B402 mov ah, 2 6150 00002034 CD1A int 1Ah ; get time of day 6151 00002036 720C jc short w1s_2 6152 w1s_1: 6153 00002038 52 push dx 6154 00002039 B402 mov ah, 2 6155 0000203B CD1A int 1Ah ; get time of day 6156 0000203D 58 pop ax 6157 0000203E 7204 jc short w1s_2 6158 00002040 38E6 cmp dh, ah 6159 00002042 74F4 je short w1s_1 ; same second 6160 w1s_2: 6161 00002044 C3 retn 6162 6163 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6164 ; partition type input 6165 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6166 6167 partition_type_input: 6168 00002045 BE[C94E] mov si, msg_partition_type 6169 00002048 E84FFB call print_msg 6170 6171 0000204B 31DB xor bx, bx 6172 6173 0000204D 881E[166D] mov [pType_pos], bl ; 0 6174 00002051 891E[176D] mov [pType_num], bx ; 0 6175 6176 ; bh = 0 ; video page 6177 00002055 B403 mov ah, 3 ; get cursor pos 6178 00002057 CD10 int 10h 6179 00002059 8916[CB54] mov [Cursor_Pos], dx 6180 ptu_0: 6181 0000205D 30E4 xor ah, ah 6182 0000205F CD16 int 16h 6183 6184 00002061 803E[166D]01 cmp byte [pType_pos], 1 6185 00002066 773F ja short ptu_5 6186 6187 00002068 3C30 cmp al, '0' 6188 0000206A 723B jb short ptu_5 6189 0000206C 3C39 cmp al, '9' 6190 0000206E 7707 ja short ptu_1 6191 00002070 88C4 mov ah, al 6192 00002072 80EC30 sub ah, '0' 6193 00002075 EB13 jmp short ptu_2 6194 ptu_1: 6195 00002077 3CE0 cmp al, 0E0h 6196 00002079 7473 je short ptu_9 6197 6198 0000207B 24DF and al, 0DFh 6199 0000207D 3C41 cmp al, 'A' 6200 0000207F 72DC jb short ptu_0 6201 00002081 3C46 cmp al, 'F' 6202 00002083 77D8 ja short ptu_0 6203 00002085 88C4 mov ah, al 6204 00002087 80EC37 sub ah, 'A'-10 6205 ptu_2: 6206 0000208A 803E[166D]00 cmp byte [pType_pos], 0 6207 0000208F 7606 jna short ptu_3 6208 00002091 8826[186D] mov [pType_num+1], ah 6209 00002095 EB04 jmp short ptu_4 6210 ptu_3: 6211 00002097 8826[176D] mov [pType_num], ah 6212 ptu_4: 6213 0000209B B40E mov ah, 0Eh 6214 0000209D B307 mov bl, 7 6215 0000209F CD10 int 10h 6216 6217 000020A1 FE06[166D] inc byte [pType_pos] 6218 6219 000020A5 EBB6 jmp short ptu_0 6220 ptu_5: 6221 000020A7 20C0 and al, al 6222 000020A9 7443 jz short ptu_9 ; check for left arrow key 6223 000020AB 3C1B cmp al, 27 6224 000020AD 744C je short ptu_10 ; ESCAPE key 6225 000020AF 77AC ja short ptu_0 6226 000020B1 3C0D cmp al, 13 6227 000020B3 744A je short ptu_11 ; ENTER key 6228 000020B5 77A6 ja short ptu_0 6229 ptu_6: 6230 ; Left arrow, backspace, DEL key checking 6231 6232 000020B7 3C08 cmp al, 8 ; backspace key 6233 000020B9 75A2 jne short ptu_0 6234 ptu_7: 6235 ; bh = 0 ; video page 6236 000020BB B403 mov ah, 3 ; get cursor pos 6237 000020BD CD10 int 10h 6238 000020BF 3A16[CB54] cmp dl, [Cursor_Pos] 6239 000020C3 7620 jna short ptu_8 6240 000020C5 FECA dec dl 6241 000020C7 FE0E[166D] dec byte [pType_pos] 6242 ; bh = 0 ; video page 6243 000020CB B402 mov ah, 2 ; set cursor pos 6244 000020CD CD10 int 10h 6245 000020CF 88D3 mov bl, dl 6246 000020D1 2A1E[CB54] sub bl, [Cursor_Pos] 6247 000020D5 B90100 mov cx, 1 6248 000020D8 B409 mov ah, 9 ; write char at current curs pos 6249 000020DA B020 mov al, 20h ; space (blank) 6250 000020DC 8800 mov [si+bx], al 6251 ; bh = 0 ; video page 6252 000020DE B307 mov bl, 7 ; attribute/color (light gray) 6253 000020E0 CD10 int 10h 6254 000020E2 E978FF jmp ptu_0 6255 ptu_8: 6256 000020E5 B40E mov ah, 0Eh 6257 000020E7 B007 mov al, 7 6258 000020E9 CD10 int 10h 6259 000020EB E96FFF jmp ptu_0 6260 ptu_9: 6261 000020EE 80FC4B cmp ah, 4Bh ; left arrow 6262 000020F1 74C8 je short ptu_7 6263 000020F3 80FC53 cmp ah, 53h ; DEL key (backspace) 6264 000020F6 74C3 je short ptu_7 6265 000020F8 E962FF jmp ptu_0 6266 6267 ptu_10: ; ESCAPE 6268 ;mov al, 0 6269 ; 29/10/2020 6270 000020FB 28C0 sub al, al ; 0 6271 ; partition type is 0 (none) 6272 000020FD EB12 jmp short ptu_12 6273 ptu_11: ; ENTER 6274 000020FF A0[176D] mov al, [pType_num] 6275 00002102 803E[166D]01 cmp byte [pType_pos], 1 6276 00002107 7608 jna short ptu_12 6277 00002109 B410 mov ah, 16 6278 0000210B F6E4 mul ah 6279 0000210D 0206[186D] add al, [pType_num+1] 6280 ptu_12: 6281 00002111 50 push ax 6282 00002112 E85BFB call bin_to_hex 6283 00002115 A3[DF4E] mov [msg_ptype_num], ax 6284 ; bh = 0 ; video page 6285 00002118 B402 mov ah, 2 ; set cursor pos 6286 0000211A 8B16[CB54] mov dx, [Cursor_Pos] 6287 0000211E CD10 int 10h 6288 00002120 BE[DF4E] mov si, msg_ptype_num 6289 00002123 E874FA call print_msg 6290 00002126 58 pop ax 6291 00002127 C3 retn 6292 6293 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6294 ; show selected partition 6295 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6296 6297 show_selected_partition: 6298 ; INPUT -> 6299 ; DS:SI = Partition table row address 6300 6301 ; 2019 - 2020 (hdimage.s) 6302 ;pt_s_offset equ 7 6303 ;pt_bh_offset equ 11 6304 ;pt_bs_offset equ 15 6305 ;pt_bc_offset equ 19 6306 ;pt_fs_offset equ 23 6307 ;pt_eh_offset equ 27 6308 ;pt_es_offset equ 31 6309 ;pt_ec_offset equ 35 6310 ;pt_rs_offset equ 41 6311 ;pt_ts_offset equ 52 6312 ;pt_fsn_offset equ 63 6313 6314 ; 24/10/2020 (fdisk3.s) 6315 pt_s_offset equ 6 6316 pt_bh_offset equ 10 6317 pt_bs_offset equ 14 6318 pt_bc_offset equ 18 6319 pt_fs_offset equ 22 6320 pt_eh_offset equ 26 6321 pt_es_offset equ 30 6322 pt_ec_offset equ 34 6323 pt_rs_offset equ 40 6324 pt_ts_offset equ 51 6325 pt_fsn_offset equ 63 6326 6327 ; clear screen 6328 00002128 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 6329 0000212B CD10 int 10h 6330 6331 0000212D 89F0 mov ax, si 6332 0000212F 2D[C057] sub ax, MasterBootBuff + pTableOffset ; + 446 6333 00002132 C0E804 shr al, 4 ; from offset to partition number 6334 00002135 0431 add al, '1' ; 1 based partition number (chr) 6335 ; Write partition number to the header location 6336 00002137 A2[9F50] mov [msg_selected_partition+43], al ; '1' to '4' 6337 6338 ; Partition number will be used at formatting stage 6339 0000213A A2[6E53] mov [partition_num_chr], al ; number + '0' 6340 6341 0000213D B268 mov dl, 'h' 6342 0000213F 8A04 mov al, [si+ptBootable] 6343 00002141 E82CFB call bin_to_hex 6344 00002144 A3[BA51] mov [pt_row+pt_s_offset], ax 6345 00002147 8816[BC51] mov [pt_row+pt_s_offset+2], dl ; 'h' 6346 0000214B 8A4401 mov al, [si+ptBeginHead] 6347 0000214E E81FFB call bin_to_hex 6348 00002151 A3[BE51] mov [pt_row+pt_bh_offset], ax 6349 00002154 8816[C051] mov [pt_row+pt_bh_offset+2], dl ; 'h' 6350 00002158 8A4402 mov al, [si+ptBeginSector] 6351 0000215B E812FB call bin_to_hex 6352 0000215E A3[C251] mov [pt_row+pt_bs_offset], ax 6353 00002161 8816[C451] mov [pt_row+pt_bs_offset+2], dl ; 'h' 6354 00002165 8A4403 mov al, [si+ptBeginCylinder] 6355 00002168 E805FB call bin_to_hex 6356 0000216B A3[C651] mov [pt_row+pt_bc_offset], ax 6357 0000216E 8816[C851] mov [pt_row+pt_bc_offset+2], dl ; 'h' 6358 00002172 8A4404 mov al, [si+ptFileSystemID] 6359 ; Partition type will be used at formatting stage 6360 00002175 A2[FA6C] mov [pp_type_user], al 6361 00002178 E8F5FA call bin_to_hex 6362 0000217B A3[CA51] mov [pt_row+pt_fs_offset], ax 6363 0000217E 8816[CC51] mov [pt_row+pt_fs_offset+2], dl ; 'h' 6364 00002182 8A4405 mov al, [si+ptEndHead] 6365 00002185 E8E8FA call bin_to_hex 6366 00002188 A3[CE51] mov [pt_row+pt_eh_offset], ax 6367 0000218B 8816[D051] mov [pt_row+pt_eh_offset+2], dl ; 'h' 6368 0000218F 8A4406 mov al, [si+ptEndSector] 6369 00002192 E8DBFA call bin_to_hex 6370 00002195 A3[D251] mov [pt_row+pt_es_offset], ax 6371 00002198 8816[D451] mov [pt_row+pt_es_offset+2], dl ; 'h' 6372 0000219C 8A4407 mov al, [si+ptEndCylinder] 6373 0000219F E8CEFA call bin_to_hex 6374 000021A2 A3[D651] mov [pt_row+pt_ec_offset], ax 6375 000021A5 8816[D851] mov [pt_row+pt_ec_offset+2], dl ; 'h' 6376 000021A9 8A4408 mov al, [si+ptStartSector] 6377 000021AC E8C1FA call bin_to_hex 6378 000021AF A3[E251] mov [pt_row+pt_rs_offset+6], ax 6379 000021B2 8816[E451] mov [pt_row+pt_rs_offset+8], dl ; 'h' 6380 000021B6 8A4409 mov al, [si+ptStartSector+1] 6381 000021B9 E8B4FA call bin_to_hex 6382 000021BC A3[E051] mov [pt_row+pt_rs_offset+4], ax 6383 000021BF 8A440A mov al, [si+ptStartSector+2] 6384 000021C2 E8ABFA call bin_to_hex 6385 000021C5 A3[DE51] mov [pt_row+pt_rs_offset+2], ax 6386 000021C8 8A440B mov al, [si+ptStartSector+3] 6387 000021CB E8A2FA call bin_to_hex 6388 000021CE A3[DC51] mov [pt_row+pt_rs_offset], ax 6389 000021D1 8A440C mov al, [si+ptSectors] 6390 000021D4 E899FA call bin_to_hex 6391 000021D7 A3[ED51] mov [pt_row+pt_ts_offset+6], ax 6392 000021DA 8816[EF51] mov [pt_row+pt_ts_offset+8], dl ; 'h' 6393 000021DE 8A440D mov al, [si+ptSectors+1] 6394 000021E1 E88CFA call bin_to_hex 6395 000021E4 A3[EB51] mov [pt_row+pt_ts_offset+4], ax 6396 000021E7 8A440E mov al, [si+ptSectors+2] 6397 000021EA E883FA call bin_to_hex 6398 000021ED A3[E951] mov [pt_row+pt_ts_offset+2], ax 6399 000021F0 8A440F mov al, [si+ptSectors+3] 6400 000021F3 E87AFA call bin_to_hex 6401 000021F6 A3[E751] mov [pt_row+pt_ts_offset], ax 6402 6403 000021F9 8A4404 mov al, [si+ptFileSystemID] 6404 000021FC BF[A640] mov di, valid_partitions 6405 000021FF B91300 mov cx, 19 6406 00002202 F2AE repnz scasb 6407 00002204 7405 jz short ssp_1 6408 00002206 B8[9840] mov ax, FS_OTHERS 6409 00002209 EB0C jmp short ssp_2 6410 ssp_1: 6411 0000220B 81EF[A740] sub di, valid_partitions + 1 6412 0000220F B80E00 mov ax, 14 6413 00002212 F7E7 mul di 6414 00002214 05[8E3F] add ax, FileSys_Names 6415 ssp_2: 6416 00002217 96 xchg ax, si 6417 00002218 B107 mov cl, 7 6418 0000221A BF[F351] mov di, pt_row + pt_fsn_offset 6419 0000221D F3A5 rep movsw 6420 0000221F 89C7 mov di, ax ; partition table row address 6421 6422 00002221 BE[7450] mov si, msg_selected_partition 6423 00002224 E873F9 call print_msg 6424 6425 00002227 BE[5552] mov si, msg_boot_indicator 6426 0000222A E86DF9 call print_msg 6427 0000222D BE[C15C] mov si, msg_YES 6428 00002230 F60580 test byte [di+ptBootable], 80h 6429 00002233 7503 jnz short ssp_3 6430 00002235 BE[C75C] mov si, msg_NO 6431 ssp_3: 6432 00002238 E85FF9 call print_msg 6433 6434 0000223B BE[6D52] mov si, msg_starting_head 6435 0000223E E859F9 call print_msg 6436 00002241 8A4501 mov al, [di+ptBeginHead] 6437 00002244 E8B200 call write_byte_decimal 6438 00002247 E850F9 call print_msg 6439 0000224A BE[8552] mov si, msg_starting_sector 6440 0000224D E84AF9 call print_msg 6441 00002250 8A4502 mov al, [di+ptBeginSector] 6442 00002253 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 6443 00002255 243F and al, 3Fh ; sector number, 1 to 63 6444 00002257 E89F00 call write_byte_decimal 6445 0000225A E83DF9 call print_msg 6446 0000225D BE[9D52] mov si, msg_starting_cylinder 6447 00002260 E837F9 call print_msg 6448 00002263 8A4503 mov al, [di+ptBeginCylinder] ; bits 0to7 of cyl 6449 00002266 C0EA06 shr dl, 6 ; bits 8&9 of cyl 6450 00002269 88D4 mov ah, dl 6451 0000226B 31D2 xor dx, dx 6452 ;mov si, msg_partition_sectors + 7 ; max. 8 digits 6453 ; 06/11/2020 6454 0000226D BE[136D] mov si, msg_partition_sectors + 10 ; max. 11 digits 6455 ; dx_ax: binary number 6456 00002270 E8E6F9 call bin_to_decimal 6457 ; ds:si = decimal number text address 6458 00002273 E824F9 call print_msg 6459 00002276 BE[B552] mov si, msg_system_id 6460 00002279 E81EF9 call print_msg 6461 ; Write file system name (again, copy) 6462 0000227C BE[F351] mov si, pt_row + pt_fsn_offset 6463 ;mov cx, 14 6464 0000227F B10E mov cl, 14 6465 00002281 B40E mov ah, 0Eh ; write tty 6466 00002283 BB0700 mov bx, 7 6467 ssp_4: 6468 00002286 AC lodsb 6469 00002287 CD10 int 10h 6470 00002289 E2FB loop ssp_4 6471 6472 0000228B BE[CD52] mov si, msg_ending_head 6473 0000228E E809F9 call print_msg 6474 00002291 8A4505 mov al, [di+ptEndHead] 6475 00002294 E86200 call write_byte_decimal 6476 00002297 E800F9 call print_msg 6477 0000229A BE[E552] mov si, msg_ending_sector 6478 0000229D E8FAF8 call print_msg 6479 000022A0 8A4506 mov al, [di+ptEndSector] 6480 000022A3 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 6481 000022A5 243F and al, 3Fh ; sector number, 1 to 63 6482 000022A7 E84F00 call write_byte_decimal 6483 000022AA E8EDF8 call print_msg 6484 000022AD BE[FD52] mov si, msg_ending_cylinder 6485 000022B0 E8E7F8 call print_msg 6486 000022B3 8A4507 mov al, [di+ptEndCylinder] ; bits 0to7 of cyl 6487 000022B6 C0EA06 shr dl, 6 ; bits 8&9 of cyl 6488 000022B9 88D4 mov ah, dl 6489 000022BB 31D2 xor dx, dx 6490 ;mov si, msg_partition_sectors + 7 ; max. 8 digits 6491 ; 06/11/2020 6492 000022BD BE[136D] mov si, msg_partition_sectors + 10 ; max. 11 digits 6493 ; dx_ax: binary number 6494 000022C0 E896F9 call bin_to_decimal 6495 ; ds:si = decimal number text address 6496 000022C3 E8D4F8 call print_msg 6497 6498 000022C6 BE[1553] mov si, msg_relative_sectors 6499 000022C9 E8CEF8 call print_msg 6500 000022CC 8B4508 mov ax, [di+ptStartSector] 6501 000022CF 8B550A mov dx, [di+ptStartSector+2] 6502 ;;mov si, msg_partition_sectors + 7 ; max. 8 digits 6503 ;mov si, reserved_bytes + 10 ; max. 11 digits 6504 ; 06/11/2020 6505 000022D2 BE[136D] mov si, msg_partition_sectors + 10 ; max. 11 digits 6506 000022D5 E881F9 call bin_to_decimal 6507 000022D8 E8BFF8 call print_msg 6508 6509 000022DB BE[2F53] mov si, msg_total_sectors 6510 000022DE E8B9F8 call print_msg 6511 000022E1 8B450C mov ax, [di+ptSectors] 6512 000022E4 8B550E mov dx, [di+ptSectors+2] 6513 ;;mov si, msg_partition_sectors + 7 ; max. 8 digits 6514 ;mov si, reserved_bytes + 10 ; max. 11 digits 6515 ; 06/11/2020 6516 000022E7 BE[136D] mov si, msg_partition_sectors + 10 ; max. 11 digits 6517 000022EA E86CF9 call bin_to_decimal 6518 000022ED E8AAF8 call print_msg 6519 6520 ; 24/02/2019 6521 000022F0 BE[8755] mov si, CRLF 6522 000022F3 E8A4F8 call print_msg 6523 6524 000022F6 89FE mov si, di ; partition table row address 6525 6526 000022F8 C3 retn 6527 6528 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6529 ; write byte as descimal number 6530 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6531 6532 write_byte_decimal: 6533 ; INPUT -> 6534 ; AL = binary number 6535 ; OUTPUT -> 6536 ; DS:SI = decimal number text address 6537 ; (ASCIIZ string) 6538 ; 6539 ; (SI, AX, CX will be modified) 6540 6541 ;mov si, msg_partition_sectors + 8 ; max. 8 digits 6542 ; 06/11/2020 6543 000022F9 BE[146D] mov si, msg_partition_sectors + 11 ; max. 11 digits 6544 000022FC B10A mov cl, 10 6545 wbd_loop: 6546 000022FE 4E dec si 6547 000022FF 30E4 xor ah, ah 6548 00002301 F6F1 div cl 6549 00002303 80C430 add ah, '0' 6550 00002306 8824 mov [si], ah 6551 00002308 20C0 and al, al 6552 0000230A 75F2 jnz short wbd_loop 6553 0000230C C3 retn 6554 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6555 ; init (MBR) partition table 6556 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6557 ; 16/10/2020 6558 6559 ; 03/02/2019 6560 init_partition_table: 6561 6562 ; INPUT -> none 6563 ; OUTPUT -> none 6564 6565 ; 15/10/2020 6566 ; (If a partition row contains invalid/wrong/defective parameters) 6567 ; (it's active partition flag/byte will be 0FFh, an invalid value!) 6568 6569 ; 12/02/2019 6570 ;cmp word [MBIDCode], 0AA55h 6571 ;jne ipt_stc ; invalid 6572 6573 ; 15/02/2019 6574 ; clear primary partition table structure/list 6575 6576 0000230D BF[9C6F] mov di, part_table_boot_ind 6577 00002310 B92400 mov cx, 36 ; 18*4 = 72 bytes 6578 00002313 31C0 xor ax, ax ; 0 6579 00002315 F3AB rep stosw 6580 6581 00002317 A3[E46F] mov [pcount], ax ; reset (pcount & ppcount) 6582 0000231A A3[E66F] mov [apcount], ax ; reset (apcount & epnumber) 6583 6584 0000231D BE[C057] mov si, MasterBootBuff+446 ; Partition table offset 6585 ;mov cx, 4 6586 00002320 B104 mov cl, 4 6587 00002322 31FF xor di, di 6588 ipt_0: 6589 00002324 8A6404 mov ah, [si+ptFileSystemID] 6590 6591 00002327 20E4 and ah, ah 6592 00002329 0F841601 jz ipt_8 ; empty 6593 6594 0000232D FE06[E46F] inc byte [pcount] ; partition count 6595 6596 00002331 80FC01 cmp ah, 1 ; FAT12 6597 00002334 7442 je short ipt_2 6598 00002336 80FC04 cmp ah, 4 ; FAT16 6599 00002339 743D je short ipt_2 6600 0000233B 723F jb short ipt_3 6601 0000233D 80FC06 cmp ah, 6 ; FAT16 big 6602 00002340 7436 je short ipt_2 6603 00002342 7715 ja short ipt_1 ; EXTENDED 6604 6605 ;cmp ah, 5 ; EXTENDED 6606 ;jne short ipt_3 6607 ipt_17: 6608 00002344 803E[E76F]00 cmp byte [epnumber], 0 6609 ;ja short ipt_stc ; invalid (more than 1 extended dos partition) 6610 00002349 7605 jna short ipt_15 6611 6612 0000234B C685[9C6F]FF mov byte [part_table_boot_ind+di], 0FFh 6613 ; Invalid/Defective partition flag 6614 ipt_15: 6615 00002350 B005 mov al, 5 6616 00002352 28C8 sub al, cl ; partition number 1 to 4 6617 00002354 A2[E76F] mov byte [epnumber], al ; extended partition entry number (1 to 4) 6618 00002357 EB23 jmp short ipt_3 6619 ipt_1: 6620 ; 26/10/2020 6621 00002359 80FC07 cmp ah, 07h ; NTFS (Windows FS) 6622 0000235C 741A je short ipt_2 ; accept NTFS as primary dos partition 6623 ; (then, extended partition can be created) 6624 ; 24/10/2020 6625 0000235E 80FC0C cmp ah, 0Ch ; FAT32 (LBA) 6626 00002361 7415 je short ipt_2 6627 00002363 7707 ja short ipt_18 6628 ; 16/10/2020 6629 00002365 80FC0B cmp ah, 0Bh ; FAT32 (CHS) 6630 ;jne short ipt_3 6631 ; 24/10/2020 6632 00002368 740E je short ipt_2 6633 0000236A 7210 jb short ipt_3 ; non-dos partition (NTFS or unknown fs type) 6634 ipt_18: 6635 0000236C 80FC0F cmp ah, 0Fh ; EXTENDED (LBA) 6636 0000236F 74D3 je short ipt_17 6637 00002371 7709 ja short ipt_3 ; non-dos partition 6638 ; (xenix/unix/linux/singlix/runix or unknown) 6639 00002373 80FC0E cmp ah, 0Eh ; FAT16 (LBA) 6640 00002376 7504 jne short ipt_3 ; 0Dh 6641 ; FAT16 LBA (0Eh) 6642 ipt_2: 6643 00002378 FE06[E56F] inc byte [ppcount] ; primary dos partition count 6644 ipt_3: 6645 0000237C 88A5[A16F] mov [part_table_sys_id+di], ah ; Partition Type (FS type) 6646 6647 00002380 8A04 mov al, [si+ptBootable] 6648 6649 00002382 20C0 and al, al 6650 00002384 7413 jz short ipt_4 6651 6652 00002386 803E[E66F]01 cmp byte [apcount], 1 ; check (previous) active partition count 6653 ;jnb short ipt_stc ; invalid (if it is not zero here) 6654 0000238B 7304 jnb short ipt_16 6655 6656 0000238D 3C80 cmp al, 80h ; active partition sign/flag? 6657 ;jne short ipt_stc ; invalid flag 6658 0000238F 7404 je short ipt_11 6659 ipt_16: 6660 ; 15/10/2020 6661 00002391 B0FF mov al, 0FFh ; Invalid/Defective partition flag 6662 00002393 EB04 jmp short ipt_4 6663 ipt_11: 6664 00002395 FE06[E66F] inc byte [apcount] ; active partition count = 1 6665 ipt_4: 6666 00002399 8885[9C6F] mov [part_table_boot_ind+di], al 6667 6668 ;mov al, [heads] 6669 ;ipt_4_fix: 6670 ;dec al 6671 0000239D 8A6401 mov ah, [si+ptBeginHead] 6672 ;cmp al, ah 6673 ;;jb short ipt_retn ; invalid 6674 ;jb ipt_heads_fix ; 10/02/2019 6675 000023A0 88A5[9D6F] mov [part_table_start_head+di], ah 6676 000023A4 8A6405 mov ah, [si+ptEndHead] 6677 ;cmp al, ah 6678 ;;jb short ipt_retn ; invalid 6679 ;jb short ipt_heads_fix ; 10/02/2019 6680 000023A7 88A5[A26F] mov [part_table_end_head+di], ah 6681 ;mov al, [sectors] 6682 000023AB 8A7C02 mov bh, [si+ptBeginSector] 6683 000023AE 88FC mov ah, bh 6684 000023B0 80E43F and ah, 3Fh ; 63 6685 ;cmp al, ah 6686 ;jb short ipt_retn ; invalid 6687 000023B3 88A5[9E6F] mov [part_table_start_sector+di], ah 6688 000023B7 8A7406 mov dh, [si+ptEndSector] 6689 000023BA 88F4 mov ah, dh 6690 000023BC 80E43F and ah, 3Fh ; 63 6691 ;cmp al, ah 6692 ;jb short ipt_retn ; invalid 6693 000023BF 88A5[A36F] mov [part_table_end_sector+di], ah 6694 000023C3 C0EF06 shr bh, 6 6695 000023C6 8A5C03 mov bl, [si+ptBeginCylinder] 6696 ;mov ax, [cylinders] 6697 ;dec ax 6698 ;cmp ax, bx 6699 ;jb short ipt_retn ; invalid 6700 000023C9 899D[9F6F] mov [part_table_start_cyl+di], bx 6701 000023CD C0EE06 shr dh, 6 6702 000023D0 8A5407 mov dl, [si+ptEndCylinder] 6703 ;cmp ax, dx 6704 ;jb short ipt_retn ; invalid 6705 000023D3 8995[A46F] mov [part_table_end_cyl+di], dx 6706 6707 000023D7 8B4408 mov ax, [si+ptStartSector] 6708 000023DA 8B540A mov dx, [si+ptStartSector+2] 6709 6710 000023DD 8985[A66F] mov [part_table_rel_sec_lw+di], ax 6711 000023E1 8995[A86F] mov [part_table_rel_sec_hw+di], dx 6712 6713 000023E5 09D0 or ax, dx 6714 ;jz short ipt_stc ; invalid (start sector must not be zero) 6715 000023E7 7505 jnz short ipt_12 6716 ; 15/10/2020 6717 000023E9 C685[9C6F]FF mov byte [part_table_boot_ind+di], 0FFh 6718 ; Invalid/Defective partition flag 6719 ipt_12: 6720 000023EE 8B440C mov ax, [si+ptSectors] 6721 000023F1 8B540E mov dx, [si+ptSectors+2] 6722 6723 000023F4 89D3 mov bx, dx 6724 000023F6 09C3 or bx, ax 6725 ;jz short ipt_stc ; invalid (zero size of partition) 6726 000023F8 7505 jnz short ipt_6 ; 10/02/2019 6727 6728 ; 15/10/2020 6729 000023FA C685[9C6F]FF mov byte [part_table_boot_ind+di], 0FFh 6730 ; Invalid/Defective partition flag 6731 6732 ;cmp dx, [total_sectors+2] 6733 ;ja short ipt_stc ; invalid (partition size > disk capacity) 6734 ;jb short ipt_6 6735 ;;cmp ax, [total_sectors] ; (ax + 1) <= total sectors 6736 ;jb short ipt_6 6737 6738 ;ipt_stc: 6739 ; ; invalid MBR data 6740 ; ;stc 6741 ;ipt_retn: 6742 ; retn 6743 6744 ;ipt_heads_fix: 6745 ; 10/02/2019 6746 ; AL = [heads] - 1 6747 6748 ;test byte [cylinders], 1 6749 ;jnz short ipt_stc ; odd cylinder count (can not be shifted) 6750 6751 ;inc al ; = [heads] 6752 ;cmp al, 8 6753 ;ja short ipt_stc ; this fix is needed for <= 16 heads (& 17 spt) 6754 ;shl al, 1 6755 ;mov [heads], al ; heads = heads*2 6756 ;shr word [cylinders], 1 ; cylinders = cylinders/2 6757 ;jmp ipt_4_fix 6758 6759 ipt_6: 6760 000023FF 8985[AA6F] mov [part_table_num_sec_lw+di], ax 6761 00002403 8995[AC6F] mov [part_table_num_sec_hw+di], dx 6762 6763 00002407 0385[A66F] add ax, [part_table_rel_sec_lw+di] 6764 0000240B 1395[A86F] adc dx, [part_table_rel_sec_hw+di] 6765 ;jc short ipt_retn ; invalid 6766 ; 27/10/2020 6767 0000240F 720E jc short ipt_13 6768 6769 00002411 3B16[6068] cmp dx, [total_sectors+2] 6770 ;ja short ipt_stc ; invalid (partition end > disk capacity) 6771 00002415 720D jb short ipt_7 6772 ; 27/10/2020 6773 00002417 7706 ja short ipt_13 6774 00002419 3B06[5E68] cmp ax, [total_sectors] ; ax <= total sectors 6775 ;ja short ipt_stc ; invalid (partition end > disk capacity) 6776 0000241D 7605 jna short ipt_7 6777 ipt_13: 6778 ; 15/10/2020 6779 0000241F C685[9C6F]FF mov byte [part_table_boot_ind+di], 0FFh 6780 ; Invalid/Defective partition flag 6781 ipt_7: 6782 ; 27/10/2020 6783 00002424 B8FE03 mov ax, 1022 ; CHS cylinder number limit 6784 00002427 3985[9F6F] cmp [part_table_start_cyl+di], ax 6785 0000242B 7707 ja short ipt_19 ; = 1023 6786 0000242D 40 inc ax ; 1023 6787 0000242E 3985[A46F] cmp [part_table_end_cyl+di], ax 6788 00002432 7203 jb short ipt_14 ; < 1023 6789 ipt_19: 6790 ; 27/10/2020 6791 ; set cylinder number if the partition's start or end sector is 6792 ; at the beyond of chs limit 6793 ; ax = 1022 -> set start cylinder 6794 ; ax = 1023 -> set end cylinder 6795 00002434 E82100 call cylindernumberfix 6796 ipt_14: 6797 00002437 83C610 add si, 16 6798 0000243A E201 loop ipt_5 6799 6800 ; OK! 6801 6802 ;clc 6803 0000243C C3 retn 6804 6805 ipt_5: 6806 0000243D 83C712 add di, 18 6807 00002440 E9E1FE jmp ipt_0 6808 6809 ipt_8: 6810 ; Empty partition table check (all of 16 bytes must be 0) 6811 00002443 51 push cx 6812 00002444 56 push si ; 16/10/2020 6813 00002445 B108 mov cl, 8 6814 ipt_9: 6815 00002447 AD lodsw 6816 00002448 09C0 or ax, ax 6817 0000244A 7507 jnz short ipt_10 6818 0000244C E2F9 loop ipt_9 6819 0000244E 59 pop cx ; 16/10/2020 ; (discard si) 6820 0000244F 59 pop cx 6821 00002450 E2EB loop ipt_5 6822 6823 ;clc 6824 00002452 C3 retn 6825 ipt_10: 6826 ;pop cx 6827 ; invalid 6828 ;stc 6829 ; 27/10/2020 6830 ; 15/10/2020 6831 ;mov byte [part_table_boot_ind+di], 0FFh 6832 ; Invalid/Defective partition flag 6833 ;retn 6834 ; 16/10/2020 6835 ; 31/10/2020 6836 ;mov byte [part_table_sys_id+di], 0 ; Empty partition 6837 00002453 5E pop si 6838 00002454 59 pop cx 6839 00002455 E939FF jmp ipt_16 6840 6841 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6842 ; set cylinder number to partition's start or end sector 6843 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6844 ; 27/10/2020 6845 6846 cylindernumberfix: 6847 ; ax = 1022 -> set start cylinder 6848 ; ax = 1023 -> set end cylinder 6849 ; di = partition table structure offset 6850 6851 ; modified registers: ax, dx, bx 6852 6853 00002458 3DFF03 cmp ax, 1023 6854 0000245B 7343 jnb short cnf_4 ; set end cylinder 6855 6856 0000245D 80BD[9D6F]FE cmp byte [part_table_start_head+di], 0FEh ; 254 6857 00002462 753C jne short cnf_4 ; no need to fix (start cyl) 6858 ; 30/10/2020 6859 ; 28/10/2020 6860 00002464 80BD[9E6F]3F cmp byte [part_table_start_sector+di], 3Fh ; 63 6861 00002469 7535 jne short cnf_4 ; no need to fix (start cyl) 6862 ; 30/10/2020 6863 6864 0000246B 8B85[A66F] mov ax, [part_table_rel_sec_lw+di] ; start sector, lw 6865 0000246F 8B95[A86F] mov dx, [part_table_rel_sec_hw+di] ; start sector, hw 6866 00002473 51 push cx 6867 00002474 8B0E[1C6D] mov cx, [hs] ; [heads*spt] 6868 00002478 E802E8 call div32 6869 ; dx:ax = cylinder number, dx = 0, quotient 6870 ; bx = remainder 6871 0000247B 59 pop cx 6872 0000247C 09D2 or dx, dx 6873 0000247E 751A jnz short cnf_2 ; invalid 6874 00002480 3B85[9F6F] cmp ax, [part_table_start_cyl+di] 6875 ;je short cnf_5 6876 00002484 7406 je short cnf_1 6877 00002486 7212 jb short cnf_2 ; invalid 6878 00002488 8985[9F6F] mov [part_table_start_cyl+di], ax ; change it 6879 ;jmp short cnf_5 6880 cnf_1: 6881 0000248C 80BD[A26F]FE cmp byte [part_table_end_head+di], 0FEh ; 254 6882 00002491 7507 jne short cnf_2 ; no need to fix (also invalid) 6883 6884 ; 28/10/2020 6885 00002493 80BD[A36F]3F cmp byte [part_table_end_sector+di], 3Fh ; 63 6886 00002498 7414 je short cnf_5 ; fix 6887 ; no need to fix (also invalid) 6888 cnf_2: 6889 0000249A C685[9C6F]FF mov byte [part_table_boot_ind+di], 0FFh ; invalid PTE 6890 cnf_3: 6891 0000249F C3 retn 6892 cnf_4: 6893 000024A0 80BD[A26F]FE cmp byte [part_table_end_head+di], 0FEh ; 254 6894 000024A5 75F8 jne short cnf_3 ; no need to fix (end cyl) 6895 6896 ; 28/10/2020 6897 000024A7 80BD[A36F]3F cmp byte [part_table_end_sector+di], 3Fh ; 63 6898 000024AC 75F1 jne short cnf_3 ; no need to fix (end cyl) 6899 cnf_5: 6900 000024AE 8B85[A66F] mov ax, [part_table_rel_sec_lw+di] ; start sector, lw 6901 000024B2 8B95[A86F] mov dx, [part_table_rel_sec_hw+di] ; start sector, hw 6902 6903 000024B6 0385[AA6F] add ax, [part_table_num_sec_lw+di] ; number of sectors, lw 6904 000024BA 1395[AC6F] adc dx, [part_table_num_sec_hw+di] ; number of sectors, hw 6905 ;jc short cnf_2 6906 6907 000024BE 83E801 sub ax, 1 6908 000024C1 83DA00 sbb dx, 0 6909 ; dx:ax = end sector 6910 000024C4 51 push cx 6911 000024C5 8B0E[1C6D] mov cx, [hs] ; [heads*spt] 6912 000024C9 E8B1E7 call div32 6913 ; dx:ax = cylinder number, dx = 0, quotient 6914 ; bx = remainder 6915 000024CC 59 pop cx 6916 000024CD 09D2 or dx, dx 6917 000024CF 75C9 jnz short cnf_2 ; invalid 6918 000024D1 3B85[A46F] cmp ax, [part_table_end_cyl+di] 6919 000024D5 74C8 je short cnf_3 ; same cylinder number 6920 000024D7 72C1 jb short cnf_2 ; invalid 6921 000024D9 8985[A46F] mov [part_table_end_cyl+di], ax ; change it 6922 000024DD C3 retn 6923 6924 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6925 ; sort partition table in (ending) cylinder number order 6926 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6927 ; 25/10/2020 (fdisk3.s) 6928 6929 ; 02/02/2019 (hdimage.s) 6930 6931 sort_partition_table: 6932 6933 ; INPUT -> none 6934 ; OUTPUT -> none 6935 6936 000024DE 31DB xor bx, bx 6937 ;jmp short sortpt_2 ; 25/10/2020 6938 sortpt_1: 6939 000024E0 889F[2C6D] mov [bx+sort], bl ; 0 6940 000024E4 FEC3 inc bl 6941 sortpt_2: 6942 000024E6 80FB04 cmp bl, 4 ; number of partition table entries to sort 6943 000024E9 72F5 jb short sortpt_1 6944 6945 ; Do a bubble sort 6946 6947 000024EB EB04 jmp short sortpt_4 6948 sortpt_3: 6949 ; Sort until we don't do a swap 6950 6951 000024ED 08C9 or cl, cl ; sort changed ? 6952 000024EF 7450 jz short sortpt_8 ; no 6953 sortpt_4: 6954 000024F1 30C9 xor cl, cl 6955 6956 000024F3 B301 mov bl, 1 6957 6958 000024F5 B212 mov dl, 18 ; partition table structure size 6959 000024F7 EB07 jmp short sortpt_6 6960 sortpt_5: 6961 000024F9 FEC3 inc bl 6962 6963 000024FB 80FB04 cmp bl, 4 6964 000024FE 73ED jnb short sortpt_3 6965 6966 sortpt_6: 6967 00002500 8A87[2C6D] mov al, [bx+sort] 6968 6969 00002504 F6E2 mul dl 6970 6971 00002506 89C6 mov si, ax 6972 6973 00002508 8BBC[A46F] mov di, [part_table_end_cyl+si] 6974 6975 0000250C 8A87[2B6D] mov al, [bx+sort-1] 6976 6977 00002510 F6E2 mul dl ; * 18 6978 6979 00002512 97 xchg di, ax 6980 6981 00002513 3985[A46F] cmp [part_table_end_cyl+di], ax ; previous > current 6982 00002517 771A ja short sortpt_7 ; swap order indicators 6983 ; 31/10/2020 6984 ; current end cyl >= previous end cyl 6985 ; 31/10/2020 6986 00002519 72DE jb short sortpt_5 6987 ; current end cyl > previous end cyl 6988 6989 0000251B 21C0 and ax, ax ; cylinder 0 ? 6990 0000251D 75DA jnz short sortpt_5 ; no 6991 ; current end cyl = previous end cyl, cyl > 0 6992 6993 ; current end cyl = previous end cyl = 0 6994 6995 ; If current entry is empty partition entry 6996 ; and previous entry is not empty partition entry 6997 ; swap them. 6998 ; 6999 0000251F 8B85[AC6F] mov ax, [part_table_num_sec_hw+di] ; previous entry 7000 00002523 0B85[AA6F] or ax, [part_table_num_sec_lw+di] 7001 00002527 74D0 jz short sortpt_5 7002 7003 00002529 8B84[AC6F] mov ax, [part_table_num_sec_hw+si] ; current entry 7004 0000252D 0B84[AA6F] or ax, [part_table_num_sec_lw+si] 7005 00002531 75C6 jnz short sortpt_5 7006 sortpt_7: 7007 ; Swap the order indicators 7008 7009 00002533 8B87[2B6D] mov ax, [bx+sort-1] 7010 00002537 86E0 xchg ah, al 7011 00002539 8987[2B6D] mov [bx+sort-1], ax 7012 7013 0000253D B101 mov cl, 1 ; sort changed 7014 0000253F EBB8 jmp short sortpt_5 7015 7016 sortpt_8: 7017 ; 30/10/2020 7018 ;mov byte [p_sorted], 1 ; 04/02/2019 7019 7020 00002541 C3 retn 7021 7022 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7023 ; find free space before/after/between partitions 7024 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7025 ; 03/02/2019 7026 7027 find_part_free_space: ; find/calculate free space for partitions 7028 ; 15/02/2019 7029 7030 ; INPUT -> 7031 ; AL = 0 -> calculate for primary/MBR partitions 7032 ; AL = 5 -> calculate for extended partition 7033 ; OUTPUT -> 7034 ; CX = the largest free space/cylinders (between partitions) 7035 ; AX = Free space index (gap number) - from 0 to 4 - 7036 ; BX = Free space structure offset (for the largest free space) 7037 ; 7038 ; 22/02/2019 7039 ; [freespace_count] = number of free spaces/gaps 7040 7041 00002542 A2[476F] mov [p_type], al 7042 7043 ; Sort the partition table 7044 7045 00002545 E896FF call sort_partition_table ; 16/02/2019 7046 7047 ; Initialize free space to zero 7048 7049 ; 15/02/2019 7050 00002548 BF[3070] mov di, fspc ; free_space.space 7051 0000254B B92800 mov cx, 5*8 ; (5*16/2) 7052 0000254E 31C0 xor ax, ax ; 0 7053 00002550 F3AB rep stosw 7054 7055 00002552 A2[446F] mov [freespace_count], al ; 0 7056 ; 22/02/2019 7057 ;mov [last_found_partition], al ; 0 7058 7059 00002555 A3[426F] mov [_i_], ax ; 0 7060 ;jmp short fpfs_2 7061 ; 31/10/020 7062 00002558 EB0E jmp short fpfs_3 7063 fpfs_1: 7064 0000255A FE06[426F] inc byte [_i_] 7065 ;;fpfs_2: 7066 0000255E 803E[426F]04 cmp byte [_i_], 4 7067 00002563 7203 jb short fpfs_3 7068 00002565 E97601 jmp fpfs_13 7069 fpfs_3: 7070 ; Find space between start of disk and first partition 7071 7072 ;mov ax, [_i_] 7073 00002568 8B1E[426F] mov bx, [_i_] ; 31/10/2020 7074 fpfs_2: 7075 ;mov bx, ax ; 31/10/2020 7076 ;mov al, [sort+bx] 7077 0000256C 8A8F[2C6D] mov cl, [sort+bx] ; 15/02/2019 7078 7079 ;mov cl, 18 ; partition table structure size = 18 bytes 7080 00002570 B012 mov al, 18 ; 15/02/2019 7081 00002572 F6E1 mul cl 7082 00002574 89C3 mov bx, ax 7083 7084 00002576 80BF[A16F]00 cmp byte [part_table_sys_id+bx], 0 7085 0000257B 74DD je short fpfs_1 7086 7087 0000257D 880E[466F] mov [last_found_partition], cl ; 15/02/2019 7088 7089 ;xor cx, cx 7090 00002581 30C9 xor cl, cl ; 0 7091 ;mov al, 1 ; LBA = 1 (after MBR) ; ah = 0 7092 ; 03/11/2020 7093 00002583 A0[863F] mov al, [sectors] ; 63 or 17 ; 03/11/2020 7094 7095 00002586 803E[476F]05 cmp byte [p_type], 5 ; EXTENDED 7096 0000258B 7506 jne short fpfs_4 7097 7098 ; This is a special case - the extended partition can not start 7099 ; on cylinder 0 due to its architecture. Protect against that here 7100 7101 ; 13/02/2019 7102 ; LBA value of free space start 7103 ;mov al, [sectors] ; 03/11/2020 7104 0000258D F626[883F] mul byte [heads] 7105 ; ax = start sector (for Extended Partition) 7106 00002591 FEC1 inc cl ; 1 ; cx = start cylinder = 1 7107 fpfs_4: 7108 ; Found a partition, get the space 7109 7110 ; 15/02/2019 7111 00002593 8B97[9F6F] mov dx, [part_table_start_cyl+bx] 7112 ; Start cylinder of the 1st partition (as sorted) 7113 00002597 39CA cmp dx, cx ; (cx=0 for primary partition, cx=1 for extd partition) 7114 00002599 0F86C300 jna fpfs_9 ; It is accepted as free (partition) space 7115 ; if this space between masterboot sector and partition 1 7116 ; has 1 cylinder (heads*spt) size at least. 7117 ; 22/02/2019 7118 0000259D 31FF xor di, di ; 0 ; Reset Free Space Table offset 7119 7120 0000259F FE06[446F] inc byte [freespace_count] ; mov byte [freespace_count], 1 7121 7122 000025A3 890E[3270] mov [free_space.start], cx ; 0 (for PP) or 1 (for EP) 7123 7124 ; non-aligned address of start sector (for the 1st partition as sorted) 7125 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 7126 ; if new partition will be selected as a primary dos partition. 7127 ; (But, start sector -LBA- will not be changed 7128 ; if it is a non-dos or user input type partition.. unless 7129 ; cylinder boundary alignment option is used.) 7130 7131 000025A7 A3[3C70] mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 7132 ; or 1 (for PP) 7133 ;mov [free_space.startsector+2], 0 7134 7135 ; free space ends before start of next valid partition 7136 000025AA 89D0 mov ax, dx ; start cylinder of partition 1 (as sorted) 7137 000025AC 29CA sub dx, cx ; cylinder count of free space 1 (gap 1) 7138 000025AE 48 dec ax ; end cylinder of free space 1 (gap 1) 7139 000025AF A3[3470] mov [free_space.end], ax 7140 000025B2 8916[3070] mov [free_space.space], dx 7141 7142 ; save free space (1) as (non-aligned) sector count 7143 000025B6 8B87[A66F] mov ax, [part_table_rel_sec_lw+bx] 7144 000025BA 8B97[A86F] mov dx, [part_table_rel_sec_hw+bx] 7145 000025BE 2B06[3C70] sub ax, [free_space.startsector] 7146 000025C2 83DA00 sbb dx, 0 7147 000025C5 A3[3870] mov [free_space.sectors_unused], ax 7148 000025C8 8916[3A70] mov [free_space.sectors_unused+2], dx 7149 7150 ;mov ax, [free_space.space] 7151 7152 ;call cylinders_to_sectors 7153 7154 ;mov [free_space.sectors_unused], ax 7155 ;mov [free_space.sectors_unused+2], dx 7156 7157 000025CC 8B0E[8A3F] mov cx, [cylinders] ; Total (disk) cylinders -divisor- 7158 000025D0 8B1E[3070] mov bx, [free_space.space] ; Partition cylinders -dividend- 7159 7160 000025D4 E8F801 call cylinders_to_percent 7161 7162 000025D7 A3[3670] mov [free_space.percent_unused], ax 7163 7164 ; 15/02/2019 7165 ;mov bl, [_i_] 7166 ;xor bh, bh 7167 ;mov al, [sort+bx] 7168 7169 ;mov [last_found_partition], al 7170 7171 ; 31/10/2020 7172 000025DA E98300 jmp fpfs_9 7173 7174 ; Look for space between the rest of the partitions 7175 7176 fpfs_7: 7177 ; ah = 0 7178 ;mov al, [_i_] 7179 ;;cbw 7180 ;mov bx, ax 7181 ; 22/02/2019 7182 000025DD 8B1E[426F] mov bx, [_i_] 7183 7184 ; 15/02/2019 7185 ;mov al, [sort+bx] 7186 000025E1 8A8F[2C6D] mov cl, [sort+bx] 7187 ;mov bl, 18 7188 ;mul bl 7189 000025E5 B012 mov al, 18 7190 000025E7 F6E1 mul cl 7191 000025E9 89C6 mov si, ax 7192 7193 000025EB 80BC[A16F]00 cmp byte [part_table_sys_id+si], 0 7194 000025F0 746E je short fpfs_9 7195 7196 ; 15/02/2019 7197 000025F2 860E[466F] xchg [last_found_partition], cl 7198 7199 ; Check to see if more than one partition on a cylinder 7200 ; If so, leave the space at zero */ 7201 7202 ; NOTE: 7203 ; It is accepted as valid free (partition) space 7204 ; if free space (gap) between partitions 7205 ; has 1 cylinder (heads*spt) size at least. 7206 7207 000025F6 B012 mov al, 18 ; Partition tables/data structure size = 18 bytes 7208 000025F8 F6E1 mul cl 7209 000025FA 89C3 mov bx, ax ; ah = 0 7210 7211 000025FC 8B97[A46F] mov dx, [part_table_end_cyl+bx] ; end cyl. of previous partition 7212 00002600 8B84[9F6F] mov ax, [part_table_start_cyl+si] ; start cyl. of current partition 7213 7214 00002604 42 inc dx ; start cylinder of free space is after the end cylinder of 7215 ; the previous partition (as sorted) 7216 7217 00002605 39D0 cmp ax, dx ; and it must be before than the next partition (as sorted) 7218 00002607 7657 jna short fpfs_9 ; je short fpfs_9 7219 7220 ; No, things are normal 7221 ; Get space between the end of the last one and the start of the next one 7222 7223 ; 22/02/2019 7224 ;add di, 16 7225 00002609 8B3E[446F] mov di, [freespace_count] 7226 0000260D C1E704 shl di, 4 ; * 16 ; next entry offset (in free space table) 7227 7228 00002610 FE06[446F] inc byte [freespace_count] 7229 7230 00002614 89C1 mov cx, ax 7231 00002616 29D1 sub cx, dx 7232 00002618 48 dec ax 7233 00002619 8995[3270] mov [free_space.start+di], dx 7234 0000261D 8985[3470] mov [free_space.end+di], ax 7235 00002621 898D[3070] mov [free_space.space+di], cx 7236 7237 ;mov ax, [free_space.space+di] 7238 ;call cylinders_to_sectors 7239 ;mov [free_space.sectors_unused+di], ax 7240 ;mov [free_space.sectors_unused+2+di], dx 7241 7242 ; calculate and save (non-aligned) free sector count between partitions 7243 7244 00002625 8B87[A66F] mov ax, [part_table_rel_sec_lw+bx] 7245 00002629 8B97[A86F] mov dx, [part_table_rel_sec_hw+bx] 7246 0000262D 0387[AA6F] add ax, [part_table_num_sec_lw+bx] 7247 00002631 1397[AC6F] adc dx, [part_table_num_sec_hw+bx] 7248 7249 00002635 8B8C[A66F] mov cx, [part_table_rel_sec_lw+si] 7250 00002639 8B9C[A86F] mov bx, [part_table_rel_sec_hw+si] 7251 7252 0000263D 8985[3C70] mov [free_space.startsector+di], ax 7253 00002641 8995[3E70] mov [free_space.startsector+2+di], dx 7254 7255 00002645 29C1 sub cx, ax 7256 00002647 19D3 sbb bx, dx 7257 7258 00002649 898D[3870] mov [free_space.sectors_unused+di], cx 7259 0000264D 899D[3A70] mov [free_space.sectors_unused+2+di], bx 7260 7261 fpfs_8: 7262 ; NOTE: Percentage is based on cylinder-boundary aligned partition size. 7263 ; (total disk cylinders and partition's cylinder count are used for that) 7264 7265 00002651 8B0E[8A3F] mov cx, [cylinders] ; -divisor- 7266 00002655 8B9D[3070] mov bx, [free_space.space+di] ; -dividend- 7267 00002659 E87301 call cylinders_to_percent 7268 7269 0000265C 8985[3670] mov [free_space.percent_unused+di], ax 7270 7271 ; ah = 0 7272 7273 ; 15/02/2019 7274 ;mov bl, [_i_] 7275 ;xor bh, bh 7276 ;mov al, [sort+bx] 7277 ; 7278 ;mov [last_found_partition], al 7279 7280 fpfs_9: 7281 00002660 FE06[426F] inc byte [_i_] 7282 fpfs_10: 7283 00002664 803E[426F]04 cmp byte [_i_], 4 7284 00002669 7303 jnb short fpfs_11 7285 7286 0000266B E96FFF jmp fpfs_7 7287 7288 fpfs_11: 7289 ; Find the space between the last partition and the end of the disk 7290 ; Make sure that freespace cannot become negative 7291 7292 0000266E A0[466F] mov al, [last_found_partition] 7293 00002671 B112 mov cl, 18 ; Partition table structure size = 18 bytes 7294 00002673 F6E1 mul cl 7295 00002675 89C3 mov bx, ax 7296 00002677 8B0E[8A3F] mov cx, [cylinders] 7297 0000267B 49 dec cx ; 15/02/2019 7298 ; (min. cylinder count = 1 for a valid/usable free space) 7299 0000267C 8B87[A46F] mov ax, [part_table_end_cyl+bx] 7300 ;cmp [part_table_end_cyl+bx], cx 7301 00002680 39C8 cmp ax, cx ; cx = end cylinder of the disk 7302 00002682 7203 jb short fpfs_12 7303 00002684 E9A400 jmp fpfs_15 7304 fpfs_12: 7305 ; 22/02/2019 7306 00002687 8B3E[446F] mov di, [freespace_count] 7307 0000268B C1E704 shl di, 4 ; * 16 ; next entry offset (in free space table) 7308 7309 0000268E FE06[446F] inc byte [freespace_count] 7310 7311 00002692 898D[3470] mov [free_space.end+di], cx ; end cyl. of free space 5 (gap 5) 7312 ;mov ax, [part_table_end_cyl+bx] 7313 7314 ;mov dx, cx 7315 ;sub dx, ax 7316 ;mov [free_space.space+di], dx ; di = 4*16 7317 ; 12/03/2021 7318 ; ax = end cylinder of the last partition 7319 ; cx = end cylinder of the disk 7320 00002696 29C1 sub cx, ax 7321 00002698 898D[3070] mov [free_space.space+di], cx ; di = 4*16 7322 7323 0000269C 40 inc ax 7324 0000269D 8985[3270] mov [free_space.start+di], ax 7325 7326 ;inc cx ; [cylinders] 7327 ;mov ax, [free_space.space+si] 7328 ;call cylinders_to_sectors 7329 ;mov [free_space.sectors_unused+di], ax 7330 ;mov [free_space.sectors_unused+2+di], dx 7331 7332 ; calculate and save (non-aligned) free sector count 7333 7334 ; 22/02/2019 7335 000026A1 8B87[A66F] mov ax, [part_table_rel_sec_lw+bx] 7336 000026A5 8B97[A86F] mov dx, [part_table_rel_sec_hw+bx] 7337 000026A9 0387[AA6F] add ax, [part_table_num_sec_lw+bx] 7338 000026AD 1397[AC6F] adc dx, [part_table_num_sec_hw+bx] 7339 7340 000026B1 8985[3C70] mov [free_space.startsector+di], ax 7341 000026B5 8995[3E70] mov [free_space.startsector+2+di], dx 7342 7343 000026B9 8B0E[5E68] mov cx, [total_sectors] 7344 000026BD 8B1E[6068] mov bx, [total_sectors+2] 7345 000026C1 29C1 sub cx, ax 7346 000026C3 19D3 sbb bx, dx 7347 000026C5 898D[3870] mov [free_space.sectors_unused+di], cx 7348 000026C9 899D[3A70] mov [free_space.sectors_unused+2+di], bx 7349 7350 000026CD 8B0E[8A3F] mov cx, [cylinders] 7351 000026D1 8B9D[3070] mov bx, [free_space.space+di] 7352 000026D5 E8F700 call cylinders_to_percent 7353 000026D8 8985[3670] mov [free_space.percent_unused+di], ax 7354 000026DC EB4D jmp short fpfs_15 7355 7356 fpfs_13: 7357 ; No partitions found, show entire space as free 7358 7359 ; 22/02/2019 7360 000026DE FE06[446F] inc byte [freespace_count] ; mov byte [freespace_count], 1 7361 7362 ; 15/02/2019 7363 ;sub ax, ax 7364 ; ah = 0 ; 31/10/2020 7365 000026E2 29D2 sub dx, dx 7366 7367 ;inc al ; LBA = 1 (after MBR) ; ah = 0 7368 000026E4 B001 mov al, 1 ; 25/02/2019 7369 7370 ;This is a special case - the extended partition can not start 7371 ;on cylinder 0 due to its architecture. Protect against that here 7372 7373 000026E6 803E[476F]05 cmp byte [p_type], 5 ; EXTENDED 7374 000026EB 7509 jne short fpfs_14 7375 7376 000026ED FEC2 inc dl 7377 7378 ; 15/02/2019 7379 ; LBA value of free space start 7380 000026EF A0[863F] mov al, [sectors] 7381 000026F2 F626[883F] mul byte [heads] 7382 ; ax = start sector (for Extended Partition) 7383 fpfs_14: 7384 000026F6 8916[3270] mov [free_space.start], dx ; 0 or 1 7385 7386 ; non-aligned address of start sector (for the 1st partition as sorted) 7387 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 7388 ; if new partition will be selected as a primary dos partition. 7389 7390 000026FA A3[3C70] mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 7391 ; or 1 (for PP) 7392 ;mov [free_space.startsector+2], 0 7393 7394 000026FD A1[8A3F] mov ax, [cylinders] ; disk capacity 7395 00002700 89C1 mov cx, ax 7396 00002702 48 dec ax 7397 00002703 A3[3470] mov [free_space.end], ax 7398 00002706 29D0 sub ax, dx 7399 00002708 40 inc ax 7400 00002709 A3[3070] mov [free_space.space], ax 7401 7402 0000270C A1[5E68] mov ax, [total_sectors] 7403 0000270F 8B16[6068] mov dx, [total_sectors+2] 7404 00002713 2B06[3C70] sub ax, [free_space.startsector] 7405 00002717 83DA00 sbb dx, 0 7406 0000271A A3[3870] mov [free_space.sectors_unused], ax 7407 0000271D 8916[3A70] mov [free_space.sectors_unused+2], dx 7408 7409 ;mov cx, [cylinders] 7410 00002721 8B1E[3070] mov bx, [free_space.space] 7411 00002725 E8A700 call cylinders_to_percent 7412 00002728 A3[3670] mov [free_space.percent_unused], ax 7413 7414 fpfs_15: 7415 ; Find largest free space 7416 0000272B 29C9 sub cx, cx 7417 ; 22/02/2019 7418 0000272D 29C0 sub ax, ax 7419 0000272F 31DB xor bx, bx 7420 00002731 8A16[446F] mov dl, [freespace_count] 7421 00002735 08D2 or dl, dl 7422 00002737 7420 jz short fpfs_19 7423 00002739 8816[426F] mov [_i_], dl 7424 fpfs_16: 7425 0000273D 8B97[3070] mov dx, [free_space.space+bx] 7426 00002741 39CA cmp dx, cx 7427 00002743 7604 jbe short fpfs_17 7428 ; 22/02/2019 7429 00002745 89D1 mov cx, dx ; Largest free space 7430 00002747 89D8 mov ax, bx 7431 fpfs_17: 7432 00002749 FE0E[426F] dec byte [_i_] 7433 0000274D 7405 jz short fpfs_18 7434 7435 0000274F 83C310 add bx, 16 ; Free space structure size 7436 00002752 EBE9 jmp short fpfs_16 7437 fpfs_18: 7438 ; 22/02/2019 7439 00002754 89C3 mov bx, ax ; offset (from 0 to 64) 7440 00002756 C0E804 shr al, 4 ; index (from 0 to 4) 7441 fpfs_19: 7442 00002759 C3 retn 7443 7444 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7445 ; find enough free space 7446 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7447 7448 ; ; 15/02/2019 7449 ;find_enough_free_space: 7450 ; ; Find enough free space 7451 ; ; 7452 ; ; INPUT: 7453 ; ; AX = Requested space (in cylinders) 7454 ; ; 22/02/2019 7455 ; ; [freespace_count] = number of free spaces/gaps 7456 ; ; OUTPUT: 7457 ; ; AX = Available space 7458 ; DX = Requested space 7459 ; ; If CF = 0 -> AX >= DX 7460 ; ; If CF = 1 -> AX < DX 7461 ; ; CX = Index of available space in free space structure 7462 ; ; (GAP number, 0 to 4) - if AX > 0 - 7463 ; 7464 ; mov dx, ax ; 22/02/2019 7465 ; sub ax, ax 7466 ; xor bx, bx 7467 ; ; 22/02/2019 7468 ; mov ch, [freespace_count] 7469 ; mov [_i_], ax ; 0 7470 ; jmp short fefs_1 7471 ;fefs_0: 7472 ; ;mov al, 16 7473 ; ;mul byte [_i_] 7474 ; ;mov bx, ax 7475 ; mov bl, [_i_] 7476 ; shl bl, 4 ; * 16 7477 ;fefs_1: 7478 ; mov ax, [free_space.space+bx] 7479 ; and ax, ax 7480 ; jz short fefs_2 ; not a free space 7481 ; mov cl, [_i_] 7482 ; cmp ax, dx 7483 ; jnb short fefs_3 ; enough space 7484 ;fefs_2: 7485 ; ; 22/02/2019 7486 ; inc byte [_i_] 7487 ; cmp byte [_i_], ch 7488 ; jb short fefs_0 7489 ; sub ch, ch 7490 ; stc 7491 ; retn 7492 ;fefs_3: 7493 ; xor ch, ch 7494 ; retn 7495 7496 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7497 ; find enough free sectors 7498 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7499 7500 ; 15/02/2019 7501 find_enough_free_sectors: 7502 ; Find (first) enough free space in sectors 7503 ; 7504 ; INPUT: 7505 ; DX:AX = Requested space (as non-aligned free sectors) 7506 ; 22/02/2019 7507 ; [freespace_count] = number of free spaces/gaps 7508 ; OUTPUT: 7509 ; DX:AX = Available space 7510 ; If CF = 0 -> DX:AX >= Request 7511 ; If CF = 1 -> DX:AX < Request 7512 ; CX = Index of available space in free space structure 7513 ; (GAP number, 0 to 4) - if DX:AX > 0 - 7514 7515 0000275A 31FF xor di, di 7516 0000275C 31F6 xor si, si 7517 0000275E 31DB xor bx, bx 7518 ; 22/02/2019 7519 00002760 8A2E[446F] mov ch, [freespace_count] 7520 00002764 891E[426F] mov [_i_], bx ; 0 7521 00002768 EB07 jmp short fefss_1 7522 fefss_0: 7523 ;mov al, 16 7524 ;mul byte [_i_] 7525 ;mov bx, ax 7526 0000276A 8B1E[426F] mov bx, [_i_] 7527 0000276E C0E304 shl bl, 4 ; * 16 7528 fefss_1: 7529 00002771 81C3[3870] add bx, free_space.sectors_unused 7530 00002775 3B5702 cmp dx, [bx+2] 7531 00002778 7230 jb short fefss_7 7532 0000277A 7706 ja short fefss_2 7533 0000277C 3B07 cmp ax, [bx] 7534 0000277E 742F je short fefss_8 7535 00002780 7228 jb short fefss_7 ; 18/02/2019 7536 fefss_2: 7537 ; 30/10/2020 7538 ;cmp word [bx], 0 7539 ;jne short fefss_3 7540 ;cmp word [bx+2], 0 7541 ;je short fefss_6 7542 fefss_3: 7543 00002782 3B7F02 cmp di, [bx+2] 7544 00002785 7711 ja short fefss_6 7545 00002787 7405 je short fefss_4 7546 00002789 8B7F02 mov di, [bx+2] 7547 0000278C EB04 jmp short fefss_5 7548 fefss_4: 7549 0000278E 3B37 cmp si, [bx] 7550 00002790 7306 jnb short fefss_6 7551 fefss_5: 7552 00002792 8B37 mov si, [bx] 7553 ; 22/02/2019 7554 00002794 8A0E[426F] mov cl, [_i_] 7555 fefss_6: 7556 00002798 FE06[426F] inc byte [_i_] 7557 0000279C 382E[426F] cmp byte [_i_], ch ; [freespace_count] 7558 000027A0 72C8 jb short fefss_0 7559 7560 000027A2 89F0 mov ax, si 7561 000027A4 89FA mov dx, di 7562 000027A6 30ED xor ch, ch 7563 000027A8 F9 stc 7564 000027A9 C3 retn 7565 fefss_7: 7566 000027AA 8B07 mov ax, [bx] 7567 000027AC 8B5702 mov dx, [bx+2] 7568 fefss_8: 7569 000027AF 8B0E[426F] mov cx, [_i_] 7570 000027B3 C3 retn 7571 7572 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7573 ; get first free partition table entry 7574 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7575 7576 ; 16/02/2019 7577 get_first_free_pte: 7578 ; Find free partition table entry 7579 ; 7580 ; INPUT: 7581 ; none 7582 ; OUTPUT: 7583 ; If CF = 0 -> CX = partition table entry number 7584 ; If CF = 1 -> there is not a free entry in partition table 7585 7586 000027B4 BE[C057] mov si, MasterBootBuff+pTableOffset 7587 000027B7 31C9 xor cx, cx 7588 gffp_1: 7589 000027B9 8A4404 mov al, [si+ptFileSystemID] ; 23/02/2019 7590 7591 000027BC 20C0 and al, al 7592 000027BE 740E jz short gffp_3 ; empty 7593 7594 000027C0 80F903 cmp cl, 3 7595 000027C3 7307 jnb short gffp_2 7596 7597 000027C5 FEC1 inc cl 7598 000027C7 83C610 add si, 16 ; Partition table entry size 7599 000027CA EBED jmp short gffp_1 7600 gffp_2: 7601 ; CL = 3 7602 000027CC F9 stc 7603 000027CD C3 retn 7604 gffp_3: 7605 ; CL = PTE number (0 to 3) 7606 000027CE C3 retn 7607 7608 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7609 ; convert cylinder count to sectors 7610 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7611 ; 03/02/2019 7612 7613 ; 15/03/2021 7614 ;cylinders_to_sectors: 7615 ; INPUT: 7616 ; ax = Cylinders (Total or partition's cylinder count) 7617 ; OUTPUT: 7618 ; dx:ax = Sectors 7619 7620 ;;mov dx, [heads] 7621 ;;mul dx 7622 ;; 30/10/2020 7623 ;mul word [heads] 7624 ;; dx:ax = Number of tracks (cylinders*heads) 7625 ;mov cx, [sectors] 7626 ;call mul32 7627 ; ; dx:ax = Number of sectors 7628 ;retn 7629 7630 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7631 ; convert cylinder count to percent of disk size (total cylinders) 7632 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7633 ; 03/02/2019 7634 7635 cylinders_to_percent: 7636 7637 ; INPUT: 7638 ; bx = Number of cylinders (of partition) -dividend- 7639 ; cx = Total cylinders -divisor- 7640 ; OUTPUT: 7641 ; ax = Percentage 7642 7643 ; if (cylinders_in == 0) 7644 ; percentage_out = 0; 7645 ; else if (total_cylinders == 0) 7646 ; percentage_out = 0; 7647 ; else 7648 7649 000027CF 09DB or bx, bx 7650 000027D1 741B jz short ctpc_6 ; ax = 0 = percentage_out 7651 ctpc_1: 7652 000027D3 09C9 or cx, cx 7653 000027D5 7417 jz short ctpc_6 7654 7655 000027D7 B86400 mov ax, 100 7656 000027DA F7E3 mul bx ; [cylinders_in] 7657 7658 ; dx:ax = Dividend 7659 7660 000027DC E89EE4 call div32 ; 100*cylinders_in / total_cylinders 7661 ; DX:AX = Quotient 7662 ; BX = Remainder 7663 7664 ; ax = percentage_out 7665 7666 ; 12/03/2021 7667 000027DF D1E9 shr cx, 1 7668 7669 000027E1 39CB cmp bx, cx ; is remainder >= total_cylinders/2 ? 7670 000027E3 7201 jb short ctpc_5 ; No. 7671 ctpc_4: 7672 000027E5 40 inc ax 7673 ctpc_5: 7674 000027E6 83F864 cmp ax, 100 7675 000027E9 7603 jbe short ctpc_6 7676 000027EB B86400 mov ax, 100 7677 ctpc_6: 7678 000027EE C3 retn 7679 7680 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7681 ; display partition table 7682 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7683 ; 04/02/2019 7684 7685 ; 12/03/2021 7686 display_partition_table_x: 7687 000027EF B005 mov al, 5 ; display extended partition table 7688 000027F1 EB02 jmp short dpt_x 7689 7690 display_partition_table: 7691 7692 ; INPUT: 7693 ; al = 0 for MBR 7694 ; = 5 for EBR (logical drives in extended partition) 7695 ; OUTPUT: 7696 ; none 7697 7698 ; 12/03/2021 7699 000027F3 30C0 xor al, al ; display primary partition table 7700 dpt_x: 7701 ;pt_positions: 7702 n_pos equ 30 ; 1 byte 7703 7704 000027F5 A2[486F] mov [_e_], al 7705 7706 ; clear screen 7707 000027F8 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 7708 000027FB CD10 int 10h 7709 7710 000027FD 803E[486F]05 cmp byte [_e_], 5 7711 00002802 7507 jne short dpt_1 7712 dpt_0: 7713 00002804 BD[E86F] mov bp, ext_table_boot_ind 7714 00002807 B045 mov al, 'E' 7715 00002809 EB05 jmp short dpt_4 7716 dpt_1: 7717 0000280B BD[9C6F] mov bp, part_table_boot_ind 7718 0000280E B04D mov al, 'M' 7719 dpt_4: 7720 00002810 BE[5C58] mov si, p_table_header 7721 00002813 88441E mov [si+n_pos], al 7722 00002816 E881F3 call print_msg 7723 7724 00002819 31DB xor bx, bx 7725 0000281B 891E[426F] mov [_i_], bx 7726 dpt_5: 7727 0000281F FE06[426F] inc byte [_i_] 7728 7729 ; BX = partition entry (0 to 3) 7730 ; BP = partition table structure address 7731 7732 00002823 E86600 call display_pt_entry ; display partition table row 7733 7734 00002826 8B1E[426F] mov bx, [_i_] 7735 7736 0000282A 80FB04 cmp bl, 4 7737 0000282D 72F0 jb short dpt_5 7738 7739 0000282F BE[9D59] mov si, p_table_footer 7740 00002832 E865F3 call print_msg 7741 7742 ; 27/02/2019 7743 00002835 BF[B355] mov di, str_disk_sectors 7744 7745 00002838 803E[486F]05 cmp byte [_e_], 5 7746 0000283D 741D je short dpt_9 7747 7748 ; display total disk sectors 7749 7750 ;mov di, str_disk_sectors 7751 7752 ;cmp byte [di], '0' 7753 ;jnb short dpt_8 7754 7755 0000283F A1[5E68] mov ax, [total_sectors] 7756 00002842 8B16[6068] mov dx, [total_sectors+2] 7757 7758 00002846 E82200 call dpt_10 7759 dpt_8: 7760 00002849 BE[9D55] mov si, msg_disk_sectors 7761 dpt_11: 7762 0000284C E84BF3 call print_msg 7763 7764 0000284F BE[B355] mov si, str_disk_sectors 7765 00002852 E845F3 call print_msg 7766 7767 00002855 BE[8755] mov si, CRLF 7768 00002858 E83FF3 call print_msg 7769 7770 0000285B C3 retn 7771 7772 dpt_9: 7773 ; display extended partition size 7774 7775 0000285C A1[3A6F] mov ax, [ep_Size] 7776 0000285F 8B16[3C6F] mov dx, [ep_Size+2] 7777 7778 00002863 E80500 call dpt_10 7779 7780 00002866 BE[BE55] mov si, msg_ep_size 7781 00002869 EBE1 jmp short dpt_11 7782 7783 dpt_10: 7784 0000286B 89E6 mov si, sp 7785 0000286D B90A00 mov cx, 10 7786 dpt_6: 7787 00002870 E80AE4 call div32 7788 7789 00002873 80C330 add bl, '0' 7790 00002876 53 push bx 7791 00002877 21C0 and ax, ax 7792 00002879 75F5 jnz short dpt_6 7793 0000287B 21D2 and dx, dx 7794 0000287D 75F1 jnz short dpt_6 7795 7796 0000287F 29E6 sub si, sp 7797 00002881 D1EE shr si, 1 7798 dpt_7: 7799 00002883 58 pop ax 7800 00002884 AA stosb 7801 00002885 4E dec si 7802 00002886 75FB jnz short dpt_7 7803 7804 00002888 30C0 xor al, al 7805 0000288A AA stosb 7806 7807 ; 27/02/2019 7808 0000288B C3 retn 7809 7810 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7811 ; display partition table entry/row 7812 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7813 ; 04/02/2019 7814 7815 struc ptbl 7816 7817 00000000 ?? .boot_ind: resb 1 7818 00000001 ?? .start_head: resb 1 7819 00000002 ?? .start_sector: resb 1 7820 00000003 ???? .start_cyl: resw 1 7821 00000005 ?? .sys_id: resb 1 7822 00000006 ?? .end_head: resb 1 7823 00000007 ?? .end_sector: resb 1 7824 00000008 ???? .end_cyl: resw 1 7825 0000000A ???? .rel_sec_lw: resw 1 7826 0000000C ???? .rel_sec_hw: resw 1 7827 0000000E ???? .num_sec_lw: resw 1 7828 00000010 ???? .num_sec_hw: resw 1 7829 .size: 7830 7831 endstruc 7832 7833 display_pt_entry: 7834 ; 24/10/2020 (fdisk3.s) 7835 7836 ; INPUT: 7837 ; bl = partition entry 7838 ; bh = 0 7839 ; bp = partition table structure address 7840 ; OUTPUT: 7841 ; none 7842 7843 ; 24/10/2020 (fdisk3.s) 7844 ;pt_positions: 7845 p_pos equ 3 ; 1 byte 7846 s_pos equ 6 ; 2+1 byte 7847 bh_pos equ 10 ; 2+1 bytes 7848 bs_pos equ 14 ; 2+1 bytes 7849 bc_pos equ 18 ; 2+1 bytes 7850 fs_pos equ 22 ; 2+1 bytes 7851 eh_pos equ 26 ; 2+1 bytes 7852 es_pos equ 30 ; 2+1 bytes 7853 ec_pos equ 34 ; 2+1 bytes 7854 rs_pos equ 42 ; 10 bytes 7855 ns_pos equ 53 ; 10 bytes 7856 fsx_pos equ 64 ; 14 bytes 7857 7858 ; 2019-2020 (hdimage.s) 7859 ;;pt_positions: 7860 ;p_pos equ 7 ; 1 byte 7861 ;s_pos equ 9 ; 2+1 byte 7862 ;bh_pos equ 13 ; 2+1 bytes 7863 ;bs_pos equ 17 ; 2+1 bytes 7864 ;bc_pos equ 21 ; 2+1 bytes 7865 ;fs_pos equ 25 ; 2+1 bytes 7866 ;eh_pos equ 29 ; 2+1 bytes 7867 ;es_pos equ 33 ; 2+1 bytes 7868 ;ec_pos equ 37 ; 2+1 bytes 7869 ;rs_pos equ 42 ; 7 bytes 7870 ;ns_pos equ 52 ; 7 bytes 7871 ;fsx_pos equ 61 ; 14 bytes 7872 7873 0000288C 55 push bp ; 23/02/2019 7874 7875 0000288D 08DB or bl, bl 7876 0000288F 7406 jz short dpte_0 7877 7878 ;xor bh, bh 7879 00002891 B012 mov al, ptbl.size ; 18 7880 00002893 F6E3 mul bl 7881 00002895 01C5 add bp, ax 7882 dpte_0: 7883 00002897 807E0500 cmp byte [bp+ptbl.sys_id], 0 7884 0000289B 0F861801 jna dpte_9 7885 7886 0000289F B768 mov bh, 'h' 7887 7888 000028A1 BE[4A6F] mov si, pte_row 7889 7890 ; clear partition table display buffer/row 7891 000028A4 89F7 mov di, si 7892 000028A6 B92800 mov cx, 40 7893 000028A9 B82020 mov ax, 2020h 7894 000028AC F3AB rep stosw 7895 7896 000028AE 88D8 mov al, bl 7897 000028B0 0431 add al, '1' 7898 000028B2 884403 mov [si+p_pos], al ; partition number '1' to '4' 7899 7900 ; partition status, type and CHS parameters 7901 ; (as hexadecimal number) 7902 7903 ;mov al, [bp+ptbl.boot_ind] 7904 000028B5 8A4600 mov al, [bp] 7905 000028B8 E8B5F3 call byte_to_hex 7906 7907 000028BB 894406 mov [si+s_pos], ax 7908 000028BE 887C08 mov [si+s_pos+2], bh ; 'h' 7909 7910 000028C1 8A4601 mov al, [bp+ptbl.start_head] 7911 000028C4 E8A9F3 call byte_to_hex 7912 7913 000028C7 89440A mov [si+bh_pos], ax 7914 000028CA 887C0C mov [si+bh_pos+2], bh ; 'h' 7915 7916 000028CD 8B4E03 mov cx, [bp+ptbl.start_cyl] 7917 ; 28/10/2020 7918 000028D0 81F9FF03 cmp cx, 1023 7919 000028D4 7603 jna short dpte_10 ; cyl number is in CHS limit 7920 000028D6 B9FF03 mov cx, 1023 ; fix cylinder number (to it's PTE value) 7921 ; to correct display PTE (CHS bytes) 7922 dpte_10: 7923 000028D9 C0E506 shl ch, 6 7924 000028DC 8A4602 mov al, [bp+ptbl.start_sector] 7925 000028DF 08E8 or al, ch 7926 000028E1 E88CF3 call byte_to_hex 7927 7928 000028E4 89440E mov [si+bs_pos], ax 7929 000028E7 887C10 mov [si+bs_pos+2], bh ; 'h' 7930 7931 ;mov al, [bp+ptbl.start_cyl] 7932 000028EA 88C8 mov al, cl 7933 000028EC E881F3 call byte_to_hex 7934 7935 000028EF 894412 mov [si+bc_pos], ax 7936 000028F2 887C14 mov [si+bc_pos+2], bh ; 'h' 7937 7938 000028F5 8A4605 mov al, [bp+ptbl.sys_id] 7939 000028F8 E875F3 call byte_to_hex 7940 7941 000028FB 894416 mov [si+fs_pos], ax 7942 000028FE 887C18 mov [si+fs_pos+2], bh ; 'h' 7943 7944 00002901 8A4606 mov al, [bp+ptbl.end_head] 7945 00002904 E869F3 call byte_to_hex 7946 7947 00002907 89441A mov [si+eh_pos], ax 7948 0000290A 887C1C mov [si+eh_pos+2], bh ; 'h' 7949 7950 0000290D 8B4E08 mov cx, [bp+ptbl.end_cyl] 7951 ; 28/10/2020 7952 00002910 81F9FF03 cmp cx, 1023 7953 00002914 7603 jna short dpte_11 ; cyl number is in CHS limit 7954 00002916 B9FF03 mov cx, 1023 ; fix cylinder number (to it's PTE value) 7955 ; to correct display PTE (CHS bytes) 7956 dpte_11: 7957 00002919 C0E506 shl ch, 6 7958 0000291C 8A4607 mov al, [bp+ptbl.end_sector] 7959 0000291F 08E8 or al, ch 7960 00002921 E84CF3 call byte_to_hex 7961 7962 00002924 89441E mov [si+es_pos], ax 7963 00002927 887C20 mov [si+es_pos+2], bh ; 'h' 7964 7965 ;mov al, [bp+ptbl.end_cyl] 7966 0000292A 88C8 mov al, cl 7967 0000292C E841F3 call byte_to_hex 7968 7969 0000292F 894422 mov [si+ec_pos], ax 7970 00002932 887C24 mov [si+ec_pos+2], bh ; 'h' 7971 7972 ; relative (start) sector address (lba) 7973 ; (as decimal number) 7974 7975 00002935 8B460A mov ax, [bp+ptbl.rel_sec_lw] 7976 00002938 8B560C mov dx, [bp+ptbl.rel_sec_hw] 7977 7978 0000293B 89E7 mov di, sp 7979 0000293D B90A00 mov cx, 10 7980 dpte_1: 7981 00002940 E83AE3 call div32 7982 7983 00002943 80C330 add bl, '0' 7984 00002946 53 push bx 7985 00002947 21C0 and ax, ax 7986 00002949 75F5 jnz short dpte_1 7987 0000294B 21D2 and dx, dx 7988 0000294D 75F1 jnz short dpte_1 7989 7990 0000294F 8D5C31 lea bx, [si+rs_pos+7] 7991 7992 00002952 29E7 sub di, sp 7993 00002954 D1EF shr di, 1 7994 00002956 29FB sub bx, di 7995 dpte_2: 7996 00002958 58 pop ax 7997 00002959 8807 mov [bx], al 7998 0000295B 4F dec di 7999 0000295C 7403 jz short dpte_3 8000 8001 0000295E 43 inc bx 8002 0000295F EBF7 jmp short dpte_2 8003 8004 dpte_3: 8005 ; number of sectors) 8006 ; (as decimal number) 8007 8008 00002961 8B460E mov ax, [bp+ptbl.num_sec_lw] 8009 00002964 8B5610 mov dx, [bp+ptbl.num_sec_hw] 8010 8011 00002967 89E7 mov di, sp 8012 ;mov cx, 10 8013 dpte_4: 8014 00002969 E811E3 call div32 8015 8016 0000296C 80C330 add bl, '0' 8017 0000296F 53 push bx 8018 00002970 21C0 and ax, ax 8019 00002972 75F5 jnz short dpte_4 8020 00002974 21D2 and dx, dx 8021 00002976 75F1 jnz short dpte_4 8022 8023 00002978 8D5C3C lea bx, [si+ns_pos+7] 8024 8025 0000297B 29E7 sub di, sp 8026 0000297D D1EF shr di, 1 8027 0000297F 29FB sub bx, di 8028 dpte_5: 8029 00002981 58 pop ax 8030 00002982 8807 mov [bx], al 8031 00002984 4F dec di 8032 00002985 7403 jz short dpte_6 8033 8034 00002987 43 inc bx 8035 00002988 EBF7 jmp short dpte_5 8036 dpte_6: 8037 ; set file system name 8038 8039 0000298A 8A4605 mov al, [bp+ptbl.sys_id] 8040 0000298D BF[A640] mov di, valid_partitions 8041 00002990 B91300 mov cx, 19 8042 00002993 F2AE repnz scasb 8043 00002995 7405 jz short dpte_7 8044 00002997 B8[9840] mov ax, FS_OTHERS 8045 0000299A EB0C jmp short dpte_8 8046 dpte_7: 8047 0000299C 81EF[A740] sub di, valid_partitions + 1 8048 000029A0 B80E00 mov ax, 14 8049 000029A3 F7E7 mul di 8050 000029A5 05[8E3F] add ax, FileSys_Names 8051 dpte_8: 8052 000029A8 8D7C40 lea di, [si+fsx_pos] 8053 000029AB 89C6 mov si, ax 8054 000029AD B107 mov cl, 7 8055 000029AF F3A5 rep movsw 8056 8057 000029B1 BE[4A6F] mov si, pte_row 8058 000029B4 E8E3F1 call print_msg 8059 dpte_9: 8060 000029B7 5D pop bp ; 23/02/2019 8061 8062 000029B8 C3 retn 8063 8064 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8065 ; fix partition table 8066 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8067 ; 24/02/2019 8068 8069 partition_table_fix: 8070 ; DELETE or EXIT option for Invalid Partition Table Entry 8071 ; INPUT: 8072 ; DS:SI = PTE address in MBR buffer 8073 8074 000029B9 56 push si ; save PTE address 8075 8076 000029BA 89F0 mov ax, si 8077 000029BC 2D[C057] sub ax, MasterBootBuff+446 8078 000029BF C0E804 shr al, 4 ; / 16 8079 000029C2 0431 add al, '1' 8080 000029C4 A2[BE5E] mov [inv_pte_num], al 8081 8082 ; DS:SI = PTE address in MBR buffer 8083 000029C7 E85EF7 call show_selected_partition 8084 8085 ;mov si, CRLF 8086 ;call print_msg 8087 8088 ; Warning message... 8089 8090 000029CA BE[9A5E] mov si, msg_inv_pte 8091 000029CD E8CAF1 call print_msg 8092 8093 000029D0 5F pop di ; restore PTE address 8094 ptf_0: 8095 000029D1 30E4 xor ah, ah 8096 000029D3 CD16 int 16h 8097 8098 000029D5 3C0D cmp al, 13 8099 000029D7 7406 je short ptf_1 8100 8101 000029D9 3C1B cmp al, 27 8102 000029DB 75F4 jne short ptf_0 8103 8104 000029DD F9 stc 8105 000029DE C3 retn 8106 ptf_1: 8107 ; Clear that (invalid) PTE 8108 000029DF 31C0 xor ax, ax 8109 000029E1 B90800 mov cx, 8 8110 000029E4 F3AB rep stosw 8111 8112 ; Clear screen 8113 000029E6 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 8114 000029E9 CD10 int 10h 8115 8116 000029EB C3 retn 8117 8118 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8119 ; display (& edit) EXTENDED (DOS) partition table 8120 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8121 ; 28/02/2019 8122 8123 display_extended_pt: 8124 ;mov al, 5 ; extended partition (logical drives) 8125 ;call display_partition_table 8126 ; 12/03/2021 8127 000029EC E800FE call display_partition_table_x 8128 8129 000029EF BE[9260] mov si, ebr_editing_options 8130 000029F2 E8A5F1 call print_msg 8131 8132 000029F5 BE[475D] mov si, enter_opt_num_cancel_msg 8133 000029F8 E89FF1 call print_msg 8134 8135 000029FB BE[8755] mov si, CRLF 8136 000029FE E899F1 call print_msg 8137 dept_1: 8138 00002A01 30E4 xor ah, ah 8139 00002A03 CD16 int 16h 8140 8141 00002A05 3C30 cmp al, '0' 8142 00002A07 740C je short dept_2 8143 8144 00002A09 3C31 cmp al, '1' 8145 00002A0B 7464 je short edit_ext_table_create 8146 00002A0D 3C32 cmp al, '2' 8147 00002A0F 7407 je short edit_ext_table_delete 8148 8149 00002A11 3C1B cmp al, 27 ; ESCape 8150 00002A13 75EC jne short dept_1 8151 dept_2: 8152 00002A15 E9EFD9 jmp A_42 8153 8154 edit_ext_table_delete: 8155 ; 28/02/2019 8156 ;mov al, 5 ; extended partition (logical drives) 8157 ;call display_partition_table 8158 ; 12/03/2021 8159 00002A18 E8D4FD call display_partition_table_x 8160 8161 00002A1B BE[1161] mov si, msg_delete_ldd_q 8162 00002A1E E879F1 call print_msg 8163 8164 ;mov si, CRLF 8165 ;call print_msg 8166 eetd_1: 8167 00002A21 30E4 xor ah, ah 8168 00002A23 CD16 int 16h 8169 8170 00002A25 3C1B cmp al, 27 8171 00002A27 7410 je short eetd_2 8172 8173 00002A29 24DF and al, 0DFh 8174 00002A2B 3C59 cmp al, 'Y' 8175 00002A2D 7412 je short eetd_yes 8176 00002A2F 3C4E cmp al, 'N' 8177 00002A31 75EE jne short eetd_1 8178 eetd_no: 8179 00002A33 BE[C75C] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 8180 00002A36 E861F1 call print_msg 8181 eetd_2: 8182 00002A39 BE[8755] mov si, CRLF ; Next line 8183 00002A3C E85BF1 call print_msg 8184 00002A3F EBAB jmp short display_extended_pt 8185 eetd_yes: 8186 00002A41 BE[C15C] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 8187 00002A44 E853F1 call print_msg 8188 00002A47 BE[8755] mov si, CRLF ; Next line 8189 00002A4A E84DF1 call print_msg 8190 00002A4D E88806 call delete_logical_drives 8191 00002A50 803E[2A6D]00 cmp byte [ldrives], 0 8192 00002A55 7795 ja short display_extended_pt 8193 00002A57 E9ADD9 jmp A_42 8194 8195 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8196 ; logical drive count limit error 8197 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8198 8199 eetc_2: 8200 00002A5A BE[7761] mov si, msg_create_ldd_max_error 8201 eetc_10: 8202 00002A5D E83AF1 call print_msg 8203 00002A60 BE[E355] mov si, msg_press_any_key 8204 00002A63 E834F1 call print_msg 8205 00002A66 30E4 xor ah, ah 8206 00002A68 CD16 int 16h 8207 00002A6A EB80 jmp display_extended_pt 8208 8209 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8210 ; no free space in extended partition 8211 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8212 8213 ; 05/03/2019 8214 eetc_9: 8215 00002A6C BE[B063] mov si, msg_c_ldd_nofspc_error 8216 00002A6F EBEC jmp short eetc_10 8217 8218 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8219 ; create logical dos drive in EXTENDED (DOS) partition 8220 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8221 ; 19/10/2020 (fdisk3.s) 8222 8223 edit_ext_table_create: ; 01/03/2019 (hdimage.s) 8224 8225 ; Create Method: ; 04/03/2019 8226 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 8227 ;LDD 2 <- LDD_START1, ebr 2nd entry <- EBR 1 8228 ;LDD 3 <- LDD_START2, ebr 2nd entry <- EBR 2 8229 ;LDD 4 <- LDD_START3, ebr 2nd entry <- EBR 3 8230 8231 ; 01/03/2019 8232 00002A71 803E[E76F]00 cmp byte [epnumber], 0 ; check extended partition 8233 00002A76 0F86B0E2 jna B_07 ; cancel with error message 8234 8235 ; 05/03/2019 8236 00002A7A E8EE02 call check_ext_free_space 8237 00002A7D 72ED jc eetc_9 ; error, no free space in extented partition 8238 8239 ; 30/10/2020 8240 00002A7F A3[A670] mov [ep_free_sectors], ax 8241 00002A82 8916[A870] mov [ep_free_sectors+2], dx 8242 8243 00002A86 803E[2A6D]04 cmp byte [ldrives], 4 8244 00002A8B 73CD jnb eetc_2 ; error, write program limit message 8245 8246 edit_ext_table_create_x: ; 02/03/2019 8247 8248 ; Get logical drive size/cylinders (request) from user 8249 00002A8D E87303 call get_ldd_size 8250 00002A90 833E[AC70]01 cmp word [lcylinders], 1 ; at least 1 cylinder 8251 00002A95 0F8253FF jb display_extended_pt ; cancel 8252 8253 ; 03/03/2019 8254 00002A99 A0[2A6D] mov al, [ldrives] 8255 8256 ;cmp byte [ldrives], 1 8257 ;jnb short eetc_3 ; skip verify MBR extended partition 8258 8259 00002A9C 20C0 and al, al 8260 00002A9E 757E jnz short eetc_3 8261 8262 00002AA0 31ED xor bp, bp 8263 8264 ; Read MBR at EBR buffer 8265 00002AA2 30E4 xor ah, ah ; 19/10/2020 8266 00002AA4 31D2 xor dx, dx 8267 00002AA6 BB[306D] mov bx, ebr_buffer 8268 00002AA9 E8FDF0 call read_hd_sector 8269 00002AAC 7218 jc short eetc_0 8270 8271 00002AAE A0[E76F] mov al, [epnumber] 8272 00002AB1 98 cbw 8273 00002AB2 C0E004 shl al, 4 ; * 16 8274 00002AB5 BE[EE6E] mov si, ebr_buffer+446 8275 00002AB8 01C6 add si, ax 8276 00002ABA BF[C057] mov di, MasterBootBuff+446 8277 00002ABD 01C7 add di, ax 8278 00002ABF B90800 mov cx, 8 8279 00002AC2 F3A7 repe cmpsw ; repeat comparising while cx > 0 and zf = 1 8280 00002AC4 E30C jcxz eetc_1 ; Extended partition entry is not changed 8281 ; Different PTE (means there is a new extended partition) 8282 eetc_0: 8283 ; Write current MBR (with modified PT) 8284 00002AC6 BB[0256] mov bx, MasterBootBuff 8285 00002AC9 31C0 xor ax, ax 8286 ;xor dx, dx 8287 00002ACB E831F1 call write_hd_sector 8288 00002ACE 0F82BFDC jc print_error_code ; ! display error msg and then exit ! 8289 eetc_1: 8290 ; clear EBR buffer 8291 00002AD2 BF[306D] mov di, ebr_buffer 8292 00002AD5 31C0 xor ax, ax 8293 00002AD7 B9FF00 mov cx, 255 8294 00002ADA F3AB rep stosw 8295 00002ADC C70555AA mov word [di], 0AA55h 8296 8297 ; Set logical dos drive parameters in it's EBR 8298 00002AE0 BF[EE6E] mov di, ebr_buffer+446 8299 8300 00002AE3 8B0E[863F] mov cx, [sectors] 8301 00002AE7 29DB sub bx, bx ; 0 8302 00002AE9 A1[326F] mov ax, [ep_StartSector] 8303 00002AEC 8B16[346F] mov dx, [ep_StartSector+2] 8304 8305 ; 03/03/2019 8306 ; set partition start address & size 8307 8308 00002AF0 A3[8670] mov [ldd_start], ax 8309 00002AF3 8916[8870] mov [ldd_start+2], dx 8310 8311 ; 01/11/2020 8312 00002AF7 833E[AC70]FF cmp word [lcylinders], 65535 8313 ; sign for using all of available sectors 8314 00002AFC 7209 jb short eetc_11 8315 8316 00002AFE A1[A670] mov ax, [ep_free_sectors] 8317 00002B01 8B16[A870] mov dx, [ep_free_sectors+2] 8318 00002B05 EB0B jmp short eetc_12 8319 eetc_11: 8320 00002B07 A0[883F] mov al, [heads] 8321 00002B0A F626[863F] mul byte [sectors] 8322 00002B0E F726[AC70] mul word [lcylinders] 8323 eetc_12: 8324 ; 01/11/2020 8325 00002B12 31ED xor bp, bp 8326 00002B14 A3[9670] mov [ldd_size], ax 8327 00002B17 8916[9870] mov [ldd_size+2], dx 8328 8329 ; 1st ldd start sector is always 63 or 17 (= spt) 8330 ;sub ax, cx ; cx = 63 or 17, [sectors] 8331 ;sbb dx, bx ; sbb dx, 0 8332 8333 ; 01/11/2020 8334 00002B1B E9DE00 jmp eetc_4 8335 8336 ;mov [di+ptStartSector], cx 8337 ;mov [di+ptStartSector+2], bx 8338 ; 8339 ;; 01/11/2020 8340 ;mov [di+ptSectors], ax 8341 ;mov [di+ptSectors+2], dx 8342 ; 8343 ;mov cx, ax 8344 ;mov bx, dx 8345 ;; cx:bx = volume size of logical -dos- drive 8346 ; 8347 ;pop ax ; ldd's LBA 8348 ;pop dx 8349 ;; dx:ax = start sector address of ldd 8350 ; 8351 ;; 01/11/2020 8352 ;add cx, ax 8353 ;adc bx, dx 8354 ;sub cx, 1 8355 ;sbb bx, 0 8356 ;; bx:cx = end sector address of ldd 8357 ;push cx 8358 ;push bx 8359 ; 8360 ;jmp eetc_4 8361 8362 eetc_3: 8363 ; [ldrives] >= 1 8364 ; Read EBR 8365 ;mov al, [ldrives] 8366 00002B1E 30E4 xor ah, ah ; 02/11/2020 8367 00002B20 C0E002 shl al, 2 8368 00002B23 89C5 mov bp, ax 8369 8370 ; 03/03/2019 8371 00002B25 8B86[8270] mov ax, [bp+ldd_start-4] 8372 00002B29 8B96[8470] mov dx, [bp+ldd_start-2] 8373 00002B2D BB[306D] mov bx, ebr_buffer 8374 00002B30 E876F0 call read_hd_sector 8375 00002B33 0F825ADC jc print_error_code ; ! display error msg and then exit ! 8376 8377 ; 04/03/2019 8378 00002B37 BE[FE6E] mov si, ebr_buffer+446+16 ; 2nd entry (next EBR) 8379 8380 ; 03/03/2019 8381 00002B3A 8B86[8270] mov ax, [bp+ldd_start-4] 8382 00002B3E 8B96[8470] mov dx, [bp+ldd_start-2] 8383 00002B42 0386[9270] add ax, [bp+ldd_size-4] 8384 00002B46 1396[9470] adc dx, [bp+ldd_size-2] 8385 8386 00002B4A 8B0E[326F] mov cx, [ep_StartSector] 8387 00002B4E 8B1E[346F] mov bx, [ep_StartSector+2] 8388 8389 00002B52 8986[8670] mov [bp+ldd_start], ax 8390 00002B56 8996[8870] mov [bp+ldd_start+2], dx 8391 8392 00002B5A 52 push dx ; ldd's start sector LBA 8393 00002B5B 50 push ax 8394 8395 00002B5C 29C8 sub ax, cx 8396 00002B5E 19DA sbb dx, bx 8397 ; dx:ax = offset from start of the ep start sector 8398 8399 00002B60 894408 mov [si+ptStartSector], ax 8400 00002B63 89540A mov [si+ptStartSector+2], dx 8401 8402 ; 01/11/2020 8403 00002B66 833E[AC70]FF cmp word [lcylinders], 65535 8404 ; sign for using all of available sectors 8405 00002B6B 7209 jb short eetc_13 8406 8407 00002B6D A1[A670] mov ax, [ep_free_sectors] 8408 00002B70 8B16[A870] mov dx, [ep_free_sectors+2] 8409 00002B74 EB0B jmp short eetc_14 8410 eetc_13: 8411 00002B76 A0[883F] mov al, [heads] 8412 00002B79 F626[863F] mul byte [sectors] 8413 00002B7D F726[AC70] mul word [lcylinders] 8414 eetc_14: 8415 ; 01/11/2020 8416 00002B81 8986[9670] mov [bp+ldd_size], ax 8417 00002B85 8996[9870] mov [bp+ldd_size+2], dx 8418 8419 00002B89 89440C mov [si+ptSectors], ax 8420 00002B8C 89540E mov [si+ptSectors+2], dx 8421 8422 ; 01/11/2020 8423 00002B8F 89C1 mov cx, ax 8424 00002B91 89D3 mov bx, dx 8425 ; cx:bx = volume size of logical -dos- drive 8426 8427 00002B93 58 pop ax ; ldd's start sector LBA 8428 00002B94 5A pop dx 8429 8430 ; 01/11/2020 8431 00002B95 01C1 add cx, ax 8432 00002B97 11D3 adc bx, dx 8433 00002B99 83E901 sub cx, 1 8434 00002B9C 83DB00 sbb bx, 0 8435 ; bx:cx = end sector address of ldd 8436 00002B9F 51 push cx 8437 00002BA0 53 push bx 8438 8439 ; calculate CHS from LBA 8440 00002BA1 E80A02 call lba_to_chs 8441 ; ax = cylinder 8442 ; dl = sector 8443 ; dh = head 8444 8445 00002BA4 C60400 mov byte [si+ptBootable], 0 8446 00002BA7 887401 mov [si+ptBeginHead], dh 8447 00002BAA 884403 mov [si+ptBeginCylinder], al 8448 00002BAD C0E406 shl ah, 6 8449 00002BB0 08E2 or dl, ah 8450 00002BB2 885402 mov [si+ptBeginSector], dl 8451 8452 ;;mov ax, [si+ptSectors] 8453 ;;mov dx, [si+ptSectors+2] 8454 ;mov ax, [bp+ldd_size] 8455 ;mov dx, [bp+ldd_size+2] 8456 ;sub ax, 1 8457 ;sbb dx, 0 8458 ;add ax, [bp+ldd_start] 8459 ;adc dx, [bp+ldd_start+2] 8460 ; ; dx:ax = end sector 8461 8462 ; 01/11/2020 8463 00002BB5 58 pop ax 8464 00002BB6 5A pop dx 8465 ; dx:ax = end sector address of ldd 8466 8467 00002BB7 E8F401 call lba_to_chs 8468 ; ax = cylinder 8469 ; dl = sector 8470 ; dh = head 8471 ; 24/10/2020 8472 ; bl = Extended partition ID 8473 8474 ;mov byte [si+ptFileSystemID], 5 ; EXTENDED 8475 ; 24/10/2020 8476 00002BBA 885C04 mov [si+ptFileSystemID], bl ; EXTENDED ; 05h or 0Fh 8477 ; 8478 00002BBD 887405 mov [si+ptEndHead], dh 8479 00002BC0 884407 mov [si+ptEndCylinder], al 8480 00002BC3 C0E406 shl ah, 6 8481 00002BC6 08D4 or ah, dl 8482 00002BC8 886406 mov [si+ptEndSector], ah 8483 8484 ; Write EBR 8485 00002BCB 8B86[8270] mov ax, [bp+ldd_start-4] 8486 00002BCF 8B96[8470] mov dx, [bp+ldd_start-2] 8487 00002BD3 BB[306D] mov bx, ebr_buffer 8488 00002BD6 E826F0 call write_hd_sector 8489 00002BD9 0F82B4DB jc print_error_code ; ! display error msg and then exit ! 8490 8491 ; clear EBR buffer 8492 00002BDD BF[306D] mov di, ebr_buffer 8493 00002BE0 31C0 xor ax, ax 8494 00002BE2 B9FF00 mov cx, 255 8495 00002BE5 F3AB rep stosw 8496 00002BE7 C70555AA mov word [di], 0AA55h 8497 8498 00002BEB BF[EE6E] mov di, ebr_buffer+446 ; 1st entry points to LDD 8499 8500 00002BEE 8B0E[863F] mov cx, [sectors] 8501 00002BF2 29DB sub bx, bx ; 0 8502 ; 01/11/2020 8503 00002BF4 8B86[9670] mov ax, [bp+ldd_size] 8504 00002BF8 8B96[9870] mov dx, [bp+ldd_size+2] 8505 ;sub ax, cx 8506 ;sbb dx, bx ; sbb dx, 0 8507 eetc_4: 8508 00002BFC 894D08 mov [di+ptStartSector], cx 8509 00002BFF 895D0A mov [di+ptStartSector+2], bx 8510 8511 ; 01/11/2020 8512 ; 1st ldd start sector is always 63 or 17 (= spt) 8513 00002C02 29C8 sub ax, cx ; cx = 63 or 17, [sectors] 8514 00002C04 19DA sbb dx, bx ; sbb dx, 0 8515 8516 ; 01/11/2020 8517 00002C06 89450C mov [di+ptSectors], ax 8518 00002C09 89550E mov [di+ptSectors+2], dx 8519 8520 00002C0C 8B8E[9670] mov cx, [bp+ldd_size] 8521 00002C10 8B9E[9870] mov bx, [bp+ldd_size+2] 8522 ; cx:bx = volume size of logical -dos- drive 8523 8524 00002C14 8B86[8670] mov ax, [bp+ldd_start] 8525 00002C18 8B96[8870] mov dx, [bp+ldd_start+2] 8526 ; dx:ax = start sector address of ldd (EBR addr) 8527 8528 ; 01/11/2020 8529 00002C1C 01C1 add cx, ax 8530 00002C1E 11D3 adc bx, dx 8531 00002C20 83E901 sub cx, 1 8532 00002C23 83DB00 sbb bx, 0 8533 ; bx:cx = end sector address of ldd 8534 00002C26 53 push bx 8535 00002C27 51 push cx 8536 ;eetc_4: 8537 ; 01/11/2020 8538 ; stack = end sector address of ldd 8539 ; dx:ax = start sector address of ldd 8540 8541 ; calculate CHS from LBA 8542 8543 00002C28 E88301 call lba_to_chs 8544 ; ax = cylinder 8545 ; dl = sector 8546 ; dh = head 8547 8548 ;mov byte [di+ptBootable], 0 8549 00002C2B 887501 mov [di+ptBeginHead], dh 8550 00002C2E 884503 mov [di+ptBeginCylinder], al 8551 ;mov bl, ah 8552 ;shl bl, 6 8553 ;or dl, bl 8554 ; 01/11/2020 8555 00002C31 C0E406 shl ah, 6 8556 00002C34 08E2 or dl, ah 8557 00002C36 885502 mov [di+ptBeginSector], dl 8558 8559 ;add ax, [lcylinders] 8560 ;dec ax ; end cylinder 8561 ;mov bx, ax 8562 8563 ; 01/11/2020 8564 00002C39 58 pop ax 8565 00002C3A 5A pop dx 8566 ; dx:ax = end sector address of ldd 8567 8568 00002C3B E87001 call lba_to_chs 8569 ; ax = cylinder number (0-1023) 8570 ; dl = sector 8571 ; dh = head 8572 ; 01/11/2020 8573 ; cx = cylinder number (0-65535) 8574 8575 ; 02/11/2020 8576 ;mov [endcyl], cx ; 01/11/2020 8577 00002C3E 870E[AE70] xchg [endcyl], cx 8578 ; cx = end cylinder of the ep 8579 ; [endcyl] = end cylinder of the ldd 8580 8581 ;mov [di+ptFileSystemID], 0 8582 ;mov cx, [heads] 8583 ;dec cl 8584 ;mov [di+ptEndHead], cl 8585 ; 01/11/2020 8586 00002C42 887505 mov [di+ptEndHead], dh 8587 8588 00002C45 884507 mov [di+ptEndCylinder], al 8589 ;mov dx, [sectors] 8590 00002C48 C0E406 shl ah, 6 8591 00002C4B 08D4 or ah, dl 8592 00002C4D 886506 mov [di+ptEndSector], ah 8593 8594 ; 02/03/2019 8595 ; Check unused space if it is 3rd LDD 8596 ; (write message to add unused space.) 8597 8598 ; 02/11/2020 8599 ;cmp byte [ldrives], 3 8600 ;jb eetc_7 8601 8602 ; 01/11/2020 8603 00002C50 833E[AC70]FF cmp word [lcylinders], 65535 8604 ; sign for using all of available sectors 8605 00002C55 0F83B500 jnb eetc_7 ; no need to add unused sector 8606 ; (there are not any unused sectors) 8607 8608 ; cx = cylinder number (0 to 65535) 8609 8610 ; 02/11/2020 8611 00002C59 803E[2A6D]03 cmp byte [ldrives], 3 ; is this logical drive 4 ? 8612 00002C5E 7309 jnb short eetc_17 8613 ; force to show unused space message 8614 8615 ; 02/11/2020 8616 ; (add unused space if cyl nums are same or diff is 1) 8617 00002C60 49 dec cx ; tolerate cylinder numbers n and n-1 8618 00002C61 3B0E[AE70] cmp cx, [endcyl] 8619 00002C65 0F87A500 ja eetc_7 ; the end cyl number of the last ldd 8620 ; is 2 or more cyls less than 8621 ; the end cyl number of the ep 8622 ; (a next ldd can be added to 8623 ; extd partition with 2 or more cyls) 8624 eetc_17: 8625 ; 02/11/2020 8626 00002C69 A0[2A6D] mov al, [ldrives] 8627 ;add al, '0' 8628 00002C6C 0431 add al, '1' ; 03/11/2020 8629 00002C6E A2[EF61] mov [char_lddn], al 8630 8631 00002C71 A0[863F] mov al, [sectors] 8632 00002C74 88C7 mov bh, al 8633 00002C76 8A1E[883F] mov bl, [heads] 8634 00002C7A FECB dec bl 8635 00002C7C F6E3 mul bl ; [sectors] * [heads] - 1 8636 8637 00002C7E 50 push ax 8638 8639 00002C7F 88F8 mov al, bh ; [sectors] 8640 ;mul byte [heads] 8641 00002C81 FEC3 inc bl 8642 00002C83 F6E3 mul bl 8643 ; ax = heads * sectors 8644 ;mul cx ; * end cylinder 8645 00002C85 F726[AE70] mul word [endcyl] ; 02/11/2020 8646 ; dx:ax = end cylinder * heads * sectors 8647 00002C89 59 pop cx 8648 00002C8A 01C8 add ax, cx ; + (sectors * (heads - 1)) 8649 00002C8C 83D200 adc dx, 0 8650 8651 ; 03/03/2019 8652 00002C8F 8B0E[863F] mov cx, [sectors] 8653 00002C93 FEC9 dec cl ; [sectors] - 1 8654 00002C95 01C8 add ax, cx ; + (sectors - 1) 8655 00002C97 83D200 adc dx, 0 8656 ; DX:AX = end LBA 8657 8658 00002C9A 8B0E[366F] mov cx, [ep_EndSector] 8659 00002C9E 8B1E[386F] mov bx, [ep_EndSector+2] 8660 8661 00002CA2 39DA cmp dx, bx 8662 00002CA4 7504 jne short eetc_5 8663 00002CA6 39C8 cmp ax, cx 8664 00002CA8 7464 je short eetc_7 ; 05/03/2019 8665 eetc_5: 8666 00002CAA 53 push bx 8667 00002CAB BE[AC61] mov si, msg_c_ldd_unused_warning 8668 00002CAE E8E9EE call print_msg 8669 00002CB1 5B pop bx 8670 eetc_6: 8671 00002CB2 28E4 sub ah, ah 8672 00002CB4 CD16 int 16h 8673 00002CB6 3C0D cmp al, 13 ; ENTER 8674 00002CB8 7454 je short eetc_7 ; continue 8675 00002CBA 3C1B cmp al, 27 ; ESC 8676 00002CBC 75F4 jne short eetc_6 8677 8678 ; 03/03/2019 8679 ; change end cylinder value 8680 00002CBE A0[E76F] mov al, [epnumber] 8681 00002CC1 FEC8 dec al 8682 00002CC3 B412 mov ah, 18 ; primary partition table structure size 8683 00002CC5 F6E4 mul ah 8684 00002CC7 89C6 mov si, ax 8685 00002CC9 8B84[A46F] mov ax, [si+part_table_end_cyl] 8686 ; 02/11/2020 8687 00002CCD A3[AE70] mov [endcyl], ax ; end cylinder of the ep 8688 eetc_19: 8689 ; 03/11/2020 8690 00002CD0 3DFF03 cmp ax, 1023 ; overs CHS limit ? 8691 00002CD3 7603 jna short eetc_20 ; no 8692 00002CD5 B8FF03 mov ax, 1023 ; 03FFh ; fix end CHS values of the PTE 8693 eetc_20: 8694 00002CD8 884507 mov [di+ptEndCylinder], al 8695 00002CDB 8A84[A36F] mov al, [si+part_table_end_sector] 8696 00002CDF C0E406 shl ah, 6 8697 00002CE2 08C4 or ah, al 8698 00002CE4 886506 mov [di+ptEndSector], ah 8699 00002CE7 8A84[A26F] mov al, [si+part_table_end_head] 8700 00002CEB 884505 mov [di+ptEndHead], al 8701 8702 00002CEE 89C8 mov ax, cx 8703 00002CF0 89DA mov dx, bx 8704 00002CF2 83C001 add ax, 1 8705 00002CF5 83D200 adc dx, 0 8706 ; dx:ax = end of extd partition + 1 8707 8708 ; 02/11/2020 8709 00002CF8 2B86[8670] sub ax, [bp+ldd_start] 8710 00002CFC 1B96[8870] sbb dx, [bp+ldd_start+2] 8711 00002D00 2B4508 sub ax, [di+ptStartSector] 8712 00002D03 1B550A sbb dx, [di+ptStartSector+2] 8713 ; dx:ax = new sector count of the ldd 8714 8715 00002D06 89450C mov [di+ptSectors], ax 8716 00002D09 89550E mov [di+ptSectors+2], dx 8717 00002D0C EB06 jmp short eetc_8 8718 eetc_7: 8719 00002D0E 8B450C mov ax, [di+ptSectors] 8720 00002D11 8B550E mov dx, [di+ptSectors+2] 8721 eetc_8: 8722 ; 01/11/2020 8723 00002D14 813E[AE70]FF03 cmp word [endcyl], 1023 8724 00002D1A 7605 jna short eetc_15 8725 8726 ; 25/10/2020 8727 ;mov cx, [bp+ldd_start] 8728 ;mov bx, [bp+ldd_start+2] 8729 ;; 01/11/2020 8730 ;add cx, [bp+ldd_size] 8731 ;adc bx, [bp+ldd_size+2] 8732 ;sub cx, 1 ; * 8733 ;sbb bx, 0 ; * 8734 ;cmp bx, [chs_limit+2] 8735 ;jb short eetc_15 8736 ;ja short eetc_19 8737 ;cmp cx, [chs_limit] 8738 ;jna short eetc_15 8739 ;eetc_19: 8740 00002D1C E8D000 call size_to_fat_type_lba ; 25/10/2020 8741 00002D1F EB03 jmp short eetc_16 8742 eetc_15: 8743 ; Get proper FAT type in [ldd_type] 8744 ; by using DX:AX - size - 8745 00002D21 E8B100 call size_to_fat_type 8746 eetc_16: 8747 00002D24 884504 mov [di+ptFileSystemID], al 8748 8749 ; Write current EBR (with modified PT) 8750 00002D27 8B86[8670] mov ax, [bp+ldd_start] 8751 00002D2B 8B96[8870] mov dx, [bp+ldd_start+2] 8752 8753 ; 01/11/2020 8754 ; ! safety ! (to protect MBR and primary partition) 8755 ;eetc_16: 8756 ;cmp dx, [ep_StartSector+2] 8757 ;jb short eetc_18 8758 ;ja short eetc_17 8759 ;cmp ax, [ep_StartSector] 8760 ;jna short eetc_18 8761 ;eetc_17: 8762 ;mov ah, 0FFh 8763 ;jmp print_error_code 8764 ;eetc_18: 8765 8766 00002D2F BB[306D] mov bx, ebr_buffer 8767 00002D32 E8CAEE call write_hd_sector 8768 00002D35 0F8258DA jc print_error_code ; ! display error msg and then exit ! 8769 8770 00002D39 A0[2A6D] mov al, [ldrives] 8771 00002D3C B412 mov ah, 18 ; extended partition table structure size 8772 00002D3E F6E4 mul ah 8773 8774 00002D40 89C6 mov si, ax 8775 00002D42 81C6[E86F] add si, ext_table_boot_ind 8776 00002D46 87F7 xchg si, di 8777 8778 ; set partition (logical -dos- drive) data 8779 00002D48 A5 movsw ; boot indicator, beginning head 8780 00002D49 AC lodsb 8781 00002D4A 88C4 mov ah, al 8782 00002D4C 243F and al, 3Fh 8783 00002D4E AA stosb ; beginning sector 8784 00002D4F C0EC06 shr ah, 6 8785 00002D52 AC lodsb ; beginning cylinder 8786 00002D53 AB stosw 8787 00002D54 A5 movsw ; partition id, end head 8788 00002D55 AC lodsb 8789 00002D56 88C4 mov ah, al 8790 00002D58 243F and al, 3Fh 8791 00002D5A AA stosb ; end sector 8792 00002D5B C0EC06 shr ah, 6 8793 00002D5E AC lodsb ; end cylinder 8794 00002D5F AB stosw 8795 8796 00002D60 A5 movsw ; copy start sector (LBA) and sector count 8797 00002D61 A5 movsw 8798 00002D62 A5 movsw 8799 00002D63 A5 movsw 8800 8801 00002D64 FE06[2A6D] inc byte [ldrives] 8802 8803 00002D68 E981FC jmp display_extended_pt 8804 8805 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8806 ; check free space in EXTENDED (DOS) partition 8807 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8808 ; 05/03/2019 8809 8810 check_ext_free_space: 8811 00002D6B A1[3A6F] mov ax, [ep_Size] 8812 00002D6E 8B16[3C6F] mov dx, [ep_Size+2] 8813 8814 00002D72 8A1E[2A6D] mov bl, [ldrives] 8815 00002D76 20DB and bl, bl 8816 00002D78 7433 jz short cefs_1 8817 00002D7A 80FB04 cmp bl, 4 8818 00002D7D 7602 jna short cefs_0 8819 00002D7F B304 mov bl, 4 8820 cefs_0: 8821 00002D81 FECB dec bl 8822 00002D83 C0E302 shl bl, 2 ; * 4 8823 00002D86 30FF xor bh, bh 8824 00002D88 89DE mov si, bx 8825 8826 00002D8A 8B8C[8670] mov cx, [si+ldd_start] 8827 00002D8E 8B9C[8870] mov bx, [si+ldd_start+2] 8828 00002D92 038C[9670] add cx, [si+ldd_size] 8829 00002D96 139C[9870] adc bx, [si+ldd_size+2] 8830 8831 00002D9A 0306[326F] add ax, [ep_StartSector] 8832 00002D9E 1316[346F] adc dx, [ep_StartSector+2] 8833 8834 00002DA2 29C8 sub ax, cx 8835 00002DA4 19DA sbb dx, bx 8836 00002DA6 7505 jnz short cefs_1 8837 8838 00002DA8 09C0 or ax, ax 8839 00002DAA 7501 jnz short cefs_1 8840 8841 ; cf = 0 if the result not negative 8842 8843 00002DAC F9 stc 8844 8845 ; cf = 1 if the result is negative or zero 8846 8847 ; If cf = 0 -> There is free space as in DX:AX 8848 ; NOTE: This calculation is unsafe if 8849 ; logical dos drive count > 4 ! 8850 ; (But still meaningful for creating a new ldd. 8851 ; Because a new ldd will be created only 8852 ; if ldd count < 4.) 8853 cefs_1: 8854 00002DAD C3 retn 8855 8856 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8857 ; convert LBA to CHS parameters (in registers) 8858 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8859 ; 24/10/2020 8860 8861 ; 13/01/2021 (BugFix) 8862 ; 01/03/2019 (hdimage.s) 8863 lba_to_chs: 8864 ; INPUT: 8865 ; DX:AX = LBA address 8866 ; OUTPUT: 8867 ; AX = cylinder 8868 ; DL = sector 8869 ; DH = head 8870 ; 24/10/2020 8871 ; BL = extended partition ID (05h, 0Fh) 8872 ; 8873 ; (modified registers: ax, bx, cx, dx) 8874 8875 00002DAE 8B0E[863F] mov cx, [sectors] 8876 00002DB2 E8C8DE call div32 8877 00002DB5 FEC3 inc bl 8878 00002DB7 53 push bx ; BL = sector 8879 00002DB8 8B0E[883F] mov cx, [heads] 8880 00002DBC E8BEDE call div32 8881 00002DBF 5A pop dx ; DL = sector 8882 00002DC0 88DE mov dh, bl ; BL = head 8883 8884 ; 24/10/2020 8885 ; check cylinder number (CHS) limit 8886 ;mov bh, 05h ; ENTENTED (LBA) 8887 ; 13/03/2021 8888 00002DC2 B305 mov bl, 05h ; EXTENDED (LBA) 8889 8890 00002DC4 89C1 mov cx, ax ; 01/11/2020 8891 8892 00002DC6 3DFF03 cmp ax, 1023 8893 00002DC9 7609 jna short lbatochs_ok 8894 8895 00002DCB B8FF03 mov ax, 1023 ; BC/EC = 0FFh 8896 00002DCE B23F mov dl, 63 ; BS/ES = 0FFh 8897 00002DD0 B6FE mov dh, 254 ; BH/EH = 0FEh 8898 00002DD2 B30F mov bl, 0Fh ; EXTENDED (CHS) 8899 lbatochs_ok: 8900 00002DD4 C3 retn 8901 8902 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8903 ; specify FAT type by using partition/volume size (CHS) 8904 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8905 ; 02/03/2019 8906 8907 size_to_fat_type: 8908 ; INPUT: 8909 ; DX:AX = DOS Partition Size in sectors 8910 ; OUTPUT: 8911 ; AL = Partition type/ID (FAT type) 8912 8913 00002DD5 09D2 or dx, dx 8914 00002DD7 750B jnz short stft_2 8915 8916 00002DD9 3DA87F cmp ax, 32680 8917 00002DDC 7703 ja short stft_1 8918 stft_0: 8919 00002DDE B001 mov al, 1 ; FAT12 file system 8920 00002DE0 C3 retn 8921 stft_1: 8922 00002DE1 B004 mov al, 4 ; FAT16 (< 32MB) 8923 00002DE3 C3 retn 8924 stft_2: 8925 00002DE4 83FA10 cmp dx, 10h 8926 00002DE7 7303 jnb short stft_3 ; FAT32 (CHS) file system 8927 8928 00002DE9 B006 mov al, 6 ; FAT16 (>= 32MB) 8929 00002DEB C3 retn 8930 stft_3: 8931 00002DEC B00B mov al, 0Bh ; FAT32 (CHS) 8932 00002DEE C3 retn 8933 8934 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8935 ; specify FAT type by using partition/volume size (LBA) 8936 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8937 ; 25/10/2020 8938 8939 size_to_fat_type_lba: 8940 ; INPUT: 8941 ; DX:AX = DOS Partition Size in sectors 8942 ; OUTPUT: 8943 ; AL = Partition type/ID (FAT type) 8944 8945 00002DEF 09D2 or dx, dx 8946 00002DF1 7408 jz short stft_4 8947 8948 00002DF3 83FA10 cmp dx, 10h 8949 00002DF6 7208 jb short stft_5 ; FAT16 (LBA) file system 8950 8951 00002DF8 B00C mov al, 0Ch ; FAT32 file system (LBA) 8952 00002DFA C3 retn 8953 stft_4: 8954 00002DFB 3DA87F cmp ax, 32680 8955 00002DFE 76DE jna short stft_0 ; FAT12 file system 8956 stft_5: 8957 00002E00 B00E mov al, 0Eh ; FAT16 file system (LBA) 8958 00002E02 C3 retn 8959 8960 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8961 ; get requested logical dos drive size (from user) 8962 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8963 ; 02/03/2019 8964 8965 get_ldd_size: 8966 ; INPUT -> none 8967 ; 8968 ; OUTPUT -> 8969 ; [lcylinders] = cylinder count 8970 ; 8971 ; (Modified registers: ax, bx, cx, dx, si, di) 8972 8973 00002E03 B80300 mov ax, 3 ; clear screen 8974 00002E06 CD10 int 10h 8975 8976 00002E08 BE[2C48] mov si, msg_create_dos_partition_h 8977 00002E0B E88CED call print_msg 8978 8979 ; 03/03/2019 8980 00002E0E A0[2A6D] mov al, [ldrives] 8981 00002E11 08C0 or al, al ; cmp byte [ldrives], 0 8982 00002E13 7405 jz short gldds_1 ; jna short gldds_0 8983 8984 ;push ax ; * 8985 8986 ;dec al 8987 ;mov ah, 18 8988 ;mul ah 8989 8990 ;mov di, ext_table_rel_sec_lw 8991 ;add di, ax 8992 8993 00002E15 BE[404E] mov si, msg_use_all_space 8994 ; 01/11/2020 8995 ;call print_msg 8996 00002E18 EB03 jmp short gldds_2 8997 8998 ; Calculate available space 8999 9000 ;mov ax, [ep_Size] ; ext part size in sectors 9001 ;mov dx, [ep_Size+2] 9002 9003 ; 04/03/2019 9004 ;gldds_0: 9005 ;mov cx, [di] ; start sector 9006 ;mov bx, [di+2] 9007 ;add cx, [di+4] ; sectors 9008 ;adc bx, [di+6] 9009 ; ; bx:cx = start of next ldd 9010 ;sub ax, cx 9011 ;sbb dx, bx 9012 ; ; dx:ax = free space in sectors 9013 ; 9014 ;pop cx ; * 9015 ;dec cl 9016 ;jz short gldds_2 9017 ;sub di, 18 9018 ;push cx ; * 9019 ;jmp short gldds_0 9020 9021 ; 05/03/2019 9022 ;call check_ext_free_space 9023 ;jc short gldds_cancel 9024 9025 ; 01/11/2020 9026 ; 30/10/2020 9027 ;mov ax, [ep_free_sectors] 9028 ;mov dx, [ep_free_sectors+2] 9029 9030 ; DX:AX = free sectors in extended partition 9031 ;jmp short gldds_2 9032 gldds_1: 9033 00002E1A BE[734E] mov si, msg_use_entire_ep_space 9034 ;call print_msg 9035 9036 ; 01/11/2020 9037 ; Calculate free space in extended partition 9038 ;mov ax, [ep_Size] 9039 ;mov dx, [ep_Size+2] 9040 gldds_2: 9041 ; 01/11/2020 9042 00002E1D E87AED call print_msg 9043 9044 00002E20 A0[883F] mov al, [heads] 9045 00002E23 F626[863F] mul byte [sectors] 9046 00002E27 89C1 mov cx, ax 9047 9048 00002E29 A1[A670] mov ax, [ep_free_sectors] 9049 00002E2C 8B16[A870] mov dx, [ep_free_sectors+2] 9050 9051 ; 01/11/2020 9052 ; this is needed for partition size input 9053 ; (maximum available sectors) 9054 ;mov [pp_Sectors], ax 9055 ;mov [pp_Sectors+2], dx 9056 9057 ; 01/11/2020 9058 ; subtrack start offset (which always equals to spt value) 9059 ;sub ax, [sectors] 9060 ;sbb dx, 0 9061 9062 ;mov cx, ax 9063 ;mov al, [heads] 9064 ;mul byte [sectors] 9065 ;xchg ax, cx 9066 ; dx:ax = sectors 9067 ; cx = heads*spt 9068 ;call div32 9069 ; ax = cylinders 9070 ; bx = remainder 9071 ; dx = 0 9072 ;and bx, bx 9073 ;jz short gldds_3 9074 ;inc ax 9075 ; 01/11/2020 9076 00002E30 F7F1 div cx 9077 ;and dx, dx 9078 ;jz short gldds_3 9079 ;inc ax 9080 gldds_3: 9081 00002E32 A3[AC70] mov [lcylinders], ax ; <= 65535 (< 65535) 9082 gldds_getchar: 9083 00002E35 30E4 xor ah, ah 9084 00002E37 CD16 int 16h 9085 9086 00002E39 3C1B cmp al, 27 ; ESCAPE key 9087 00002E3B 7416 je short gldds_cancel 9088 00002E3D 24DF and al, 0DFh 9089 00002E3F 3C4E cmp al, 'N' 9090 00002E41 7417 je short gldds_4 9091 00002E43 3C59 cmp al, 'Y' 9092 00002E45 75EE jne short gldds_getchar 9093 9094 ; 01/11/2020 9095 00002E47 C706[AC70]FFFF mov word [lcylinders], 65535 ; sign for all free sectors 9096 9097 00002E4D BE[C05C] mov si, _msg_YES 9098 ;call print_msg 9099 ;retn 9100 00002E50 E947ED jmp print_msg 9101 9102 gldds_cancel: 9103 00002E53 C706[AC70]0000 mov word [lcylinders], 0 9104 gldds_28: 9105 00002E59 C3 retn 9106 gldds_4: 9107 00002E5A BE[C65C] mov si, _msg_NO 9108 00002E5D E83AED call print_msg 9109 gldds_26: 9110 00002E60 B80300 mov ax, 3 ; clear screen 9111 00002E63 CD10 int 10h 9112 9113 00002E65 BE[2C48] mov si, msg_create_dos_partition_h 9114 00002E68 E82FED call print_msg 9115 9116 00002E6B BE[3262] mov si, msg_create_ldd_s 9117 00002E6E E829ED call print_msg 9118 00002E71 BE[FE4D] mov si, msg_press_esc_to_cancel 9119 00002E74 E823ED call print_msg 9120 gldds_25: 9121 00002E77 30E4 xor ah, ah 9122 00002E79 CD16 int 16h 9123 9124 00002E7B 3C1B cmp al, 27 ; ESCAPE key 9125 00002E7D 7502 jne short gldds_5 9126 9127 00002E7F EBD2 jmp short gldds_cancel 9128 gldds_5: 9129 ; 04/03/2019 9130 00002E81 3C20 cmp al, 32 ; SPACE key 9131 00002E83 74D4 je short gldds_28 9132 9133 ; 01/11/2020 9134 ;mov byte [pSize_unit], '%' 9135 00002E85 3C25 cmp al, '%' 9136 00002E87 7416 je short gldds_6 9137 ;mov byte [pSize_unit], 'M' 9138 00002E89 3C0D cmp al, 13 ; 0Dh, Carriage Return key 9139 ;je short gldds_6 9140 00002E8B 7504 jne short gldds_29 9141 ; 01/11/2020 9142 00002E8D B04D mov al, 'M' 9143 00002E8F EB0E jmp short gldds_6 9144 gldds_29: 9145 00002E91 24DF and al, 0DFh 9146 00002E93 3C4D cmp al, 'M' 9147 00002E95 7408 je short gldds_6 9148 ;mov [pSize_unit], al 9149 00002E97 3C47 cmp al, 'G' 9150 00002E99 7404 je short gldds_6 9151 00002E9B 3C43 cmp al, 'C' 9152 00002E9D 75D8 jne short gldds_25 9153 gldds_6: 9154 ; 01/11/2020 9155 00002E9F A2[066D] mov [pSize_unit], al 9156 9157 ; Set maximum sector count (all of extended partition) 9158 ;mov al, [sectors] 9159 ;mul byte [heads] 9160 ;mul word [lcylinders] 9161 ; 01/11/2020 9162 00002EA2 A1[A670] mov ax, [ep_free_sectors] 9163 00002EA5 8B16[A870] mov dx, [ep_free_sectors+2] 9164 00002EA9 A3[F46C] mov [pp_Sectors], ax 9165 00002EAC 8916[F66C] mov [pp_Sectors+2], dx 9166 9167 00002EB0 E857EF call partition_size_input 9168 00002EB3 729E jc short gldds_cancel 9169 ; DX:AX = Partition size in sectors 9170 ;or bx, bx 9171 ;jnz short gldds_cancel 9172 9173 ; 01/11/2020 9174 00002EB5 A3[226D] mov [ppn_Sectors], ax 9175 00002EB8 8916[246D] mov [ppn_Sectors+2], dx 9176 9177 ;mov cx, ax 9178 ;mov al, [heads] 9179 ;mul byte [sectors] 9180 ;xchg ax, cx 9181 ; 13/03/2021 9182 00002EBC 8B0E[1C6D] mov cx, [hs] ; heads*sectors 9183 ; dx:ax = sectors 9184 ; cx = heads*spt 9185 00002EC0 E8BADD call div32 9186 ; ax = cylinders 9187 ; bx = remainder 9188 ; dx = 0 9189 ; 02/11/2020 9190 ;and bx, bx 9191 ;jz short gldds_7 9192 ;inc ax 9193 gldds_7: 9194 00002EC3 3B06[AC70] cmp ax, [lcylinders] 9195 00002EC7 7704 ja short gldds_9 9196 gldds_8: 9197 ; OK 9198 00002EC9 A3[AC70] mov [lcylinders], ax 9199 00002ECC C3 retn 9200 9201 gldds_9: 9202 ; Partition size limit message 9203 9204 00002ECD 803E[066D]43 cmp byte [pSize_unit], 'C' 9205 00002ED2 741C je short gldds_10 9206 9207 ; Tolerate 1 cylinder if unit is not cylinder 9208 ;dec ax 9209 ;cmp ax, [lcylinders] 9210 ;jna short gldds_8 9211 9212 ; 01/11/2020 9213 ; Tolerate sectors if sectorcount doesn't over ep limit 9214 00002ED4 A1[226D] mov ax, [ppn_Sectors] 9215 00002ED7 8B16[246D] mov dx, [ppn_Sectors+2] 9216 00002EDB 3B16[A870] cmp dx, [ep_free_sectors+2] 9217 00002EDF 770F ja short gldds_10 9218 00002EE1 7206 jb short gldds_30 9219 00002EE3 3B06[A670] cmp ax, [ep_free_sectors] 9220 00002EE7 7707 ja short gldds_10 9221 gldds_30: 9222 00002EE9 C706[AC70]FFFF mov word [lcylinders], 65535 ; sign for all free sectors 9223 00002EEF C3 retn 9224 9225 gldds_10: 9226 ; clear screen 9227 00002EF0 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 9228 00002EF3 CD10 int 10h 9229 9230 00002EF5 BE[2C48] mov si, msg_create_dos_partition_h ; header 9231 00002EF8 E89FEC call print_msg 9232 9233 00002EFB BE[DF5D] mov si, msg_partition_size_limit 9234 00002EFE E899EC call print_msg 9235 9236 00002F01 803E[066D]4D cmp byte [pSize_unit], 'M' 9237 00002F06 7413 je short gldds_11 9238 9239 00002F08 803E[066D]25 cmp byte [pSize_unit], '%' 9240 00002F0D 7457 je short gldds_22 9241 9242 00002F0F 803E[066D]43 cmp byte [pSize_unit], 'C' 9243 00002F14 7505 jne short gldds_11 9244 9245 00002F16 A1[AC70] mov ax, [lcylinders] 9246 00002F19 EB0F jmp short gldds_12 9247 gldds_11: 9248 ; 'M' 9249 00002F1B A1[F46C] mov ax, [pp_Sectors] 9250 00002F1E 8B16[F66C] mov dx, [pp_Sectors+2] 9251 00002F22 B90008 mov cx, 2*1024 ; sectors -> MB 9252 00002F25 E855DD call div32 9253 ; DX = 0 9254 ; AX = Available space in Megabytes 9255 00002F28 89C7 mov di, ax 9256 gldds_12: 9257 00002F2A B90A00 mov cx, 10 9258 00002F2D 89E5 mov bp, sp 9259 gldds_13: 9260 00002F2F 31D2 xor dx, dx 9261 ;mov cx, 10 9262 00002F31 F7F1 div cx 9263 00002F33 52 push dx 9264 00002F34 83F809 cmp ax, 9 9265 00002F37 77F6 ja short gldds_13 9266 gldds_14: 9267 00002F39 BB0700 mov bx, 07h 9268 00002F3C 09C0 or ax, ax 9269 00002F3E 7501 jnz short gldds_16 9270 gldds_15: 9271 00002F40 58 pop ax 9272 gldds_16: 9273 00002F41 0430 add al, '0' 9274 gldds_17: 9275 00002F43 B40E mov ah, 0Eh 9276 ;mov bx, 07h 9277 00002F45 CD10 int 10h ; write character (as tty) 9278 9279 00002F47 39EC cmp sp, bp 9280 00002F49 72F5 jb short gldds_15 9281 9282 00002F4B 803E[066D]25 cmp byte [pSize_unit], '%' 9283 00002F50 7508 jne short gldds_18 9284 9285 00002F52 3C25 cmp al, '%' 9286 00002F54 745E je short gldds_21 9287 00002F56 B025 mov al, '%' 9288 00002F58 EBE9 jmp short gldds_17 9289 gldds_18: 9290 00002F5A 803E[066D]43 cmp byte [pSize_unit], 'C' 9291 00002F5F 753E jne short gldds_19 9292 9293 00002F61 BE[7B5E] mov si, msg_cylinders 9294 00002F64 EB4B jmp short gldds_20 9295 9296 gldds_22: 9297 ; '%' 9298 ; 01/11/2020 9299 00002F66 8B16[3C6F] mov dx, [ep_Size+2] 9300 00002F6A A1[3A6F] mov ax, [ep_Size] ; * 9301 00002F6D 21D2 and dx, dx 9302 00002F6F 7419 jz short gldds_33 ; dx = 0 9303 00002F71 B90100 mov cx, 1 9304 gldds_31: 9305 00002F74 D1E1 shl cx, 1 9306 00002F76 E804DD call div32 9307 00002F79 09D2 or dx, dx 9308 00002F7B 7409 jz short gldds_32 ; * 9309 00002F7D A1[3A6F] mov ax, [ep_Size] 9310 00002F80 8B16[3C6F] mov dx, [ep_Size+2] 9311 00002F84 EBEE jmp short gldds_31 9312 gldds_32: 9313 00002F86 8B16[A870] mov dx, [ep_free_sectors+2] 9314 ; ep free sectors <= ep size 9315 gldds_33: 9316 00002F8A 50 push ax ; * ; dx = 0 (ep size weight) 9317 00002F8B A1[A670] mov ax, [ep_free_sectors] 9318 00002F8E B96400 mov cx, 100 9319 ;and dx, dx 9320 ;jnz short gldds_34 9321 ;mul cx 9322 ;jmp short gldds_35 9323 ;gldds_34: 9324 00002F91 E8F7DC call mul32 9325 ; dx:ax = 100 * ep free sectors weight 9326 ;gldds_35: 9327 00002F94 59 pop cx ; * 9328 00002F95 E8E5DC call div32 ; 100 * ep free sectors / ep size 9329 ; ax = % value (<= 100) 9330 00002F98 09C0 or ax, ax 9331 ;jnz short gldds_23 9332 00002F9A 758E jnz short gldds_12 ; 13/01/2021 9333 00002F9C 40 inc ax ; 0 -> 1 9334 ; 13/03/2021 9335 00002F9D EB8B jmp short gldds_12 9336 9337 ;gldds_23: 9338 ;mov bp, sp 9339 ;mov cx, 10 9340 ;gldds_24: 9341 ;xor dx, dx 9342 ;div cx 9343 ;push dx ; * 9344 ;cmp ax, 9 9345 ;ja short gldds_24 9346 ;jmp short gldds_14 9347 9348 gldds_19: 9349 00002F9F BE[8F5E] mov si, msg_megabytes 9350 00002FA2 C606[985E]73 mov byte [msg_megabytes_s], 's' 9351 00002FA7 83FF01 cmp di, 1 9352 00002FAA 7705 ja short gldds_20 9353 00002FAC C606[985E]00 mov byte [msg_megabytes_s], 0 9354 gldds_20: 9355 00002FB1 E8E6EB call print_msg 9356 gldds_21: 9357 00002FB4 BE[2C5E] mov si, msg_partition_size_limit_r 9358 00002FB7 E8E0EB call print_msg 9359 gldds_27: 9360 00002FBA 30E4 xor ah, ah 9361 00002FBC CD16 int 16h 9362 9363 00002FBE 3C1B cmp al, 27 ; ESCAPE key 9364 00002FC0 0F849CFE je gldds_26 9365 00002FC4 3C0D cmp al, 13 ; ENTER (Carriage Return) key 9366 00002FC6 75F2 jne short gldds_27 9367 9368 ;mov ax, [lcylinders] 9369 00002FC8 C3 retn 9370 9371 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9372 ; initialize extended (dos) partition table 9373 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9374 ; 18/10/2020 (fdisk3.s) 9375 ; 26/02/2019 (hdimage.s) 9376 9377 init_ext_partition_table: 9378 9379 ; INPUT -> 9380 ; [epnumber] = extended partition number 9381 ; 9382 ; OUTPUT -> none 9383 9384 ; Display Method: ; 04/03/2019 9385 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 9386 ;LDD 2 <- LDD_START1, ebr 1st entry <- EBR 1 9387 ;LDD 3 <- LDD_START2, ebr 1st entry <- EBR 2 9388 ;LDD 4 <- LDD_START3, ebr 1st entry <- EBR 3 9389 ;LDD 5 <- LDD_START3, ebr 2nd entry (LDD 5 is not displayed) 9390 9391 ; 08/03/2019 9392 9393 ; clear extended partition table structure/list 9394 9395 00002FC9 BF[E86F] mov di, ext_table_boot_ind 9396 00002FCC 89FE mov si, di ; 28/02/2019 9397 00002FCE B92400 mov cx, 36 ; 18*4 = 72 bytes 9398 00002FD1 31C0 xor ax, ax ; 0 9399 00002FD3 F3AB rep stosw 9400 00002FD5 89F7 mov di, si ; 28/02/2019 9401 9402 ;mov byte [ldrives], 0 9403 00002FD7 A2[2A6D] mov [ldrives], al ; 0 9404 9405 ;cmp byte [epnumber], 1 9406 ;jb short iept_0 9407 9408 00002FDA A0[E76F] mov al, [epnumber] 9409 00002FDD FEC8 dec al 9410 00002FDF B412 mov ah, 18 ; partition table structure size 9411 00002FE1 F6E4 mul ah 9412 00002FE3 BE[A66F] mov si, part_table_rel_sec_lw 9413 00002FE6 01C6 add si, ax 9414 ; 02/11/2020 9415 ;(save end cylinder for comparising later) 9416 00002FE8 8B44FE mov ax, [si-2] ; part_table_end_cyl 9417 ; 16 bit cylinder number 9418 00002FEB A3[AE70] mov [endcyl], ax 9419 ; 9420 00002FEE 8B04 mov ax, [si] 9421 00002FF0 8B5402 mov dx, [si+2] 9422 00002FF3 A3[326F] mov [ep_StartSector], ax 9423 00002FF6 8916[346F] mov [ep_StartSector+2], dx 9424 00002FFA 8B4C04 mov cx, [si+4] 9425 00002FFD 8B5C06 mov bx, [si+6] 9426 00003000 890E[3A6F] mov [ep_Size], cx 9427 00003004 891E[3C6F] mov [ep_Size+2], bx 9428 00003008 83E901 sub cx, 1 9429 0000300B 83DB00 sbb bx, 0 9430 0000300E 01C1 add cx, ax 9431 00003010 11D3 adc bx, dx 9432 00003012 890E[366F] mov [ep_EndSector], cx 9433 00003016 891E[386F] mov [ep_EndSector+2], bx 9434 9435 ; 27/02/2019 9436 0000301A A3[8670] mov [ldd_start], ax 9437 0000301D 8916[8870] mov [ldd_start+2], dx 9438 9439 ; 03/03/2019 9440 ;mov word [ldd_size], 0 9441 ;mov word [ldd_size+2], 0 9442 9443 00003021 BB[306D] mov bx, ebr_buffer 9444 ; dx:ax = Extended partition address 9445 ; es:bx = Extended partition buffer 9446 00003024 E882EB call read_hd_sector 9447 00003027 7209 jc short iept_0 9448 9449 ; Check EBR if it is a valid boot record or not 9450 00003029 813E[2E6F]55AA cmp word [ebr_buffer+510], 0AA55h 9451 0000302F 7402 je short iept_1 9452 iept_stc_retn: 9453 00003031 F9 stc 9454 iept_0: 9455 00003032 C3 retn 9456 iept_1: 9457 ; Check PTE 1, if it is valid or not 9458 00003033 A0[F26E] mov al, [ebr_buffer+446+ptFileSystemID] 9459 00003036 20C0 and al, al 9460 00003038 74F7 jz short iept_stc_retn ; empty pte, error 9461 0000303A 3C05 cmp al, 5 9462 0000303C 74F3 je short iept_stc_retn ; extended partition, error 9463 ; 24/10/2020 9464 0000303E 3C0F cmp al, 0Fh 9465 00003040 74EF je short iept_stc_retn ; extended partition, error 9466 9467 ;inc byte [ldrives] ; logical (dos) drive count 9468 9469 00003042 BE[EE6E] mov si, ebr_buffer+446 ; Partition table offset 9470 00003045 B90400 mov cx, 4 9471 9472 ; set partition (logical -dos- drive) data 9473 00003048 A5 movsw ; boot indicator, beginning head 9474 00003049 AC lodsb 9475 0000304A 88C4 mov ah, al 9476 0000304C 243F and al, 3Fh 9477 0000304E AA stosb ; beginning sector 9478 0000304F C0EC06 shr ah, 6 9479 00003052 AC lodsb ; beginning cylinder 9480 00003053 AB stosw 9481 00003054 A5 movsw ; partition id, end head 9482 00003055 AC lodsb 9483 00003056 88C4 mov ah, al 9484 00003058 243F and al, 3Fh 9485 0000305A AA stosb ; end sector 9486 0000305B C0EC06 shr ah, 6 9487 0000305E AC lodsb ; end cylinder 9488 0000305F AB stosw 9489 9490 ; 04/03/2019 9491 00003060 8A1E[2A6D] mov bl, [ldrives] 9492 ;dec bl 9493 ;jnz short iept_2 9494 9495 ; 05/03/2019 9496 00003064 08DB or bl, bl 9497 00003066 7518 jnz short iept_2 9498 9499 00003068 8B04 mov ax, [si] ; start sector of 1st LDD (offset) 9500 0000306A 8B5402 mov dx, [si+2] 9501 0000306D 034404 add ax, [si+4] ; size of 1st LDD (volume) 9502 00003070 135406 adc dx, [si+6] 9503 9504 00003073 A3[9670] mov [ldd_size], ax ; size of 1st LDD (partition) 9505 00003076 8916[9870] mov [ldd_size+2], dx 9506 ; 05/03/2019 9507 0000307A FE06[2A6D] inc byte [ldrives] ; logical (dos) drive count 9508 0000307E FEC3 inc bl 9509 iept_2: 9510 00003080 F3A5 rep movsw ; copy start sector (LBA) and sector count 9511 9512 ; get next extended partition (logical -dos- drive) data 9513 00003082 8A4404 mov al, [si+ptFileSystemID] 9514 00003085 20C0 and al, al ; EMPTY 9515 00003087 74A9 jz short iept_0 ; end of logical -dos- drive chain 9516 9517 00003089 3C05 cmp al, 5 ; EXTENDED 9518 ;jne short iept_stc_retn ; 2nd PTE must have 9519 ; ; extended partition ID 9520 0000308B 7404 je short iept_4 9521 ; 24/10/2020 9522 0000308D 3C0F cmp al, 0Fh ; EXTENDED (LBA) 9523 0000308F 75A0 jne short iept_stc_retn ; 2nd PTE must have 9524 ; extended partition ID 9525 iept_4: 9526 ; 05/03/2019 9527 00003091 FE06[2A6D] inc byte [ldrives] ; logical (dos) drive count 9528 9529 ;cmp byte [ldrives], al ; 5 9530 00003095 80FB04 cmp bl, 4 ; number of logical dos drives (till here) 9531 00003098 733D jnb short iept_3 9532 9533 0000309A 83C608 add si, 8 9534 9535 0000309D AD lodsw 9536 0000309E 89C2 mov dx, ax ; start sector 9537 000030A0 AD lodsw 9538 000030A1 92 xchg dx, ax ; start sector + 2 9539 9540 ; 04/03/2019 9541 000030A2 0306[326F] add ax, [ep_StartSector] 9542 000030A6 1316[346F] adc dx, [ep_StartSector+2] 9543 9544 000030AA 30FF xor bh, bh 9545 000030AC C0E302 shl bl, 2 ; *4 9546 9547 ; 28/02/2019 9548 000030AF 8987[8670] mov [bx+ldd_start], ax ; start of (next) LDD (partition) 9549 000030B3 8997[8870] mov [bx+ldd_start+2], dx 9550 9551 ; 03/03/2019 9552 ; set partition size for logical dos drive 9553 000030B7 8B0C mov cx, [si] 9554 000030B9 898F[9670] mov [bx+ldd_size], cx 9555 000030BD 8B4C02 mov cx, [si+2] 9556 000030C0 898F[9870] mov [bx+ldd_size+2], cx 9557 9558 000030C4 BB[306D] mov bx, ebr_buffer 9559 ; dx:ax = Extended partition address 9560 ; es:bx = Extended partition buffer 9561 000030C7 E8DFEA call read_hd_sector 9562 000030CA 720B jc short iept_3 ; 03/03/2019 9563 9564 ; Check EBR if it is valid or not 9565 000030CC 813E[2E6F]55AA cmp word [ebr_buffer+510], 0AA55h 9566 000030D2 0F845DFF je iept_1 9567 9568 000030D6 F9 stc 9569 iept_3: 9570 000030D7 C3 retn 9571 9572 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9573 ; delete logical -dos- drives in extended partition 9574 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9575 ; 18/10/2020 (fdisk3.s) 9576 9577 delete_logical_drives: 9578 ; 27/02/2019 (hdimage.s) 9579 9580 ; Delete Method: ; 04/03/2019 9581 ;LDD 5 <- LDD_START3, ebr 2nd entry 9582 ;LDD 4 <- LDD_START2, ebr 2nd entry 9583 ;LDD 3 <- LDD_START1, ebr 2nd entry 9584 ;LDD 2 <- LDD_START0, ebr 2nd entry 9585 ;LDD 1 <- LDD_START0, ebr 1st entry 9586 9587 ;cmp byte [ldrives], 0 9588 ;jna short dld_stc 9589 9590 ;mov al, 5 ; extended partition (logical drives) 9591 ;call display_partition_table 9592 ; 12/03/2021 9593 000030D8 E814F7 call display_partition_table_x 9594 9595 000030DB A0[2A6D] mov al, [ldrives] 9596 000030DE 0430 add al, '0' 9597 000030E0 A2[0560] mov [lddp_num], al 9598 9599 000030E3 BE[B25F] mov si, msg_delete_ldd 9600 000030E6 E8B1EA call print_msg 9601 9602 000030E9 BE[FE4D] mov si, msg_press_esc_to_cancel 9603 000030EC E8ABEA call print_msg 9604 dld_0: 9605 000030EF 30E4 xor ah, ah 9606 000030F1 CD16 int 16h 9607 9608 000030F3 80FC53 cmp ah, 53h ; DELETE or DEL key 9609 000030F6 751C jne short dld_1 9610 9611 ; Delete PTE 1 & PTE 2 on EBR 1 9612 000030F8 30E4 xor ah, ah 9613 000030FA A0[2A6D] mov al, [ldrives] 9614 000030FD FEC8 dec al 9615 000030FF 7518 jnz short dld_2 9616 9617 00003101 BF[EE6E] mov di, ebr_buffer+446 9618 00003104 B91000 mov cx, 16 9619 00003107 F3AB rep stosw 9620 9621 ; 04/03/2019 9622 ; Clear ldd data in extended partition table/structure 9623 00003109 BF[E86F] mov di, ext_table_boot_ind 9624 0000310C B109 mov cl, 9 9625 0000310E F3AB rep stosw 9626 00003110 31F6 xor si, si 9627 00003112 EB40 jmp short dld_3 9628 dld_1: 9629 00003114 3C1B cmp al, 27 ; ESC key 9630 00003116 75D7 jne short dld_0 9631 dld_5: 9632 00003118 C3 retn 9633 9634 ;dld_stc: 9635 ; stc 9636 ; retn 9637 9638 dld_2: 9639 ; 04/03/2019 9640 ; Delete 2nd PTE on EBR 2 to 4 9641 00003119 FEC8 dec al 9642 0000311B C0E002 shl al, 2 ; * 4 9643 0000311E 89C6 mov si, ax 9644 9645 00003120 8B84[8670] mov ax, [si+ldd_start] 9646 00003124 8B94[8870] mov dx, [si+ldd_start+2] 9647 00003128 BB[306D] mov bx, ebr_buffer 9648 0000312B E87BEA call read_hd_sector 9649 0000312E 7238 jc short dld_4 9650 9651 00003130 BF[FE6E] mov di, ebr_buffer+446+16 9652 00003133 B90800 mov cx, 8 9653 00003136 29C0 sub ax, ax 9654 00003138 F3AB rep stosw 9655 9656 ; 04/03/2019 9657 ;cmp byte [ldrives], 5 9658 ;jnb short dld_3 9659 0000313A 8A26[2A6D] mov ah, [ldrives] 9660 0000313E 80FC05 cmp ah, 5 9661 00003141 7311 jnb short dld_3 9662 9663 ; Clear ldd data in extended partition table/structure 9664 ;mov ah, [ldrives] 9665 00003143 FECC dec ah 9666 00003145 B012 mov al, 18 9667 00003147 F6E4 mul ah 9668 00003149 BF[E86F] mov di, ext_table_boot_ind 9669 0000314C 01C7 add di, ax 9670 ;mov cx, 9 9671 0000314E B109 mov cl, 9 9672 ;xor ax, ax 9673 00003150 30C0 xor al, al 9674 00003152 F3AB rep stosw 9675 dld_3: 9676 ; Write changed EBR 9677 00003154 8B84[8670] mov ax, [si+ldd_start] 9678 00003158 8B94[8870] mov dx, [si+ldd_start+2] 9679 0000315C BB[306D] mov bx, ebr_buffer 9680 0000315F E89DEA call write_hd_sector 9681 00003162 7204 jc short dld_4 9682 9683 ; 28/02/2019 9684 00003164 FE0E[2A6D] dec byte [ldrives] 9685 dld_4: 9686 00003168 803E[2A6D]00 cmp byte [ldrives], 0 9687 0000316D 0F8767FF ja delete_logical_drives 9688 9689 00003171 C3 retn 9690 9691 ;============================================================================= 9692 ; initialized data 9693 ;============================================================================= 9694 9695 ; 12/10/2020 9696 00003172 00 int13h_x: db 0 9697 9698 TRDOS386_MASTERBOOT_SECTOR: 9699 00003173 incbin 'FS1_MBR.BIN' ; Singlix FS1 MBR 9700 9701 TRDOS_FAT_hd_bs: 9702 ;incbin 'TRHDBS.BIN' 9703 ; 04/05/2024 9704 TRDOS_FAT32_hd_bs: 9705 ;incbin 'FAT32_BS.BIN' ; 27/04/2024 9706 00003373 incbin 'RD5HDBS3.BIN' ; 29/01/2026 9707 TRDOS_FAT16_hd_bs: 9708 ;incbin 'FAT16_BS.BIN' ; 26/12/2017 9709 00003773 incbin 'RD5HDBS2.BIN' ; 20/04/2024 9710 TRDOS_FAT12_hd_bs: 9711 ;incbin 'FAT12_BS.BIN' ; 26/12/2017 9712 00003973 incbin 'RD5HDBS1.BIN' ; 20/04/2024 9713 9714 TRDOS_TRFS1_chs_bs: 9715 00003B73 incbin 'TRFS1CHS.BIN' ; Singlix FS1 (CHS+LBA Disk) BS 9716 TRDOS_TRFS1_lba_bs: 9717 00003D73 incbin 'TRFS1LBA.BIN' ; Singlix FS1 (LBA Disk) BS 9718 9719 00003F73 00 db 0 9720 9721 hexchrs: 9722 00003F74 303132333435363738- db '0123456789ABCDEF' 9722 00003F7D 39414243444546 9723 9724 ; 05/11/2020 9725 00003F84 00 db 0 9726 9727 00003F85 90 align 2 9728 9729 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 9730 9731 sectors: ; sectors per track (63) 9732 00003F86 3F00 dw 63 9733 heads: ; number of heads (16 or 32 or 64) 9734 00003F88 1000 dw 16 9735 cylinders: ; number of cylinders (16 to 1024) 9736 00003F8A 0004 dw 1024 9737 00003F8C 0000 dw 0 ; 16/10/2020 (double word) 9738 9739 ; 05/11/2020 9740 9741 ;random: 9742 ; db 0 ; random write to file (0 = sequental) 9743 ;newdisk: 9744 ; db 0 9745 9746 FileSys_Names: ; 2003-2017 9747 ; (Valid FileSystems for TRDOS 386, SINGLIX, RETRO UNIX OS projects in 2017) 9748 00003F8E 464154313220202020- FS_FAT12: db "FAT12 " ; 01h = FAT12 9748 00003F97 2020202020 9749 00003F9C 58454E495820202020- FS_XENIX: db "XENIX " ; 02h , XENIX System V root 9749 00003FA5 2020202020 9750 00003FAA 58454E495820757372- FS_XENIX_USR: db "XENIX usr " ; 03h , XENIX System V user 9750 00003FB3 2020202020 9751 00003FB8 464154313620283034- FS_FAT16: db "FAT16 (04h) " ; 04h = FAT16 < 32MB 9751 00003FC1 6829202020 9752 00003FC6 455854454E44454420- FS_EXT_CHS: db "EXTENDED (CHS)" ; 05h = Extended DOS Partition 9752 00003FCF 2843485329 9753 00003FD4 464154313620283036- FS_FAT16_BIG: db "FAT16 (06h) " ; 06h = FAT16 > 32MB, CHS mode 9753 00003FDD 6829202020 9754 00003FE2 4E5446532020202020- FS_NTFS: db "NTFS " ; 07h , WINDOWS NTFS Partition 9754 00003FEB 2020202020 9755 00003FF0 464154333220284348- FS_FAT32_CHS: db "FAT32 (CHS) " ; 0Bh = FAT32, CHS mode 9755 00003FF9 5329202020 9756 00003FFE 464154333220284C42- FS_FAT32_LBA: db "FAT32 (LBA) " ; 0Ch = FAT32, LBA mode 9756 00004007 4129202020 9757 0000400C 464154313620284C42- FS_FAT16_LBA: db "FAT16 (LBA) " ; 0Eh = FAT16, LBA mode 9757 00004015 4129202020 9758 0000401A 455854454E44454420- FS_EXT_LBA: db "EXTENDED (LBA)" ; 0Fh = Extented Partition, LBA mode 9758 00004023 284C424129 9759 00004028 554E49582053595354- FS_UNIX_SYSV: db "UNIX SYSTEM V " ; 63h , SCO UNIX, UNIXWARE, OPENSERVER 9759 00004031 454D205620 9760 00004036 524554524F20554E49- FS_RETROUNIX: db "RETRO UNIX " ; 71h , Retro UNIX 386 v2 Partition 9760 0000403F 5820202020 9761 00004044 554E49582056372020- FS_UNIX_V7: db "UNIX V7 " ; 72h , UNIX v7 x86 Partition 9761 0000404D 2020202020 9762 00004052 4C494E555820535741- FS_LINUXSWAP: db "LINUX SWAP " ; 82h , LINUX SWAP Partition 9762 0000405B 5020202020 9763 00004060 4C494E555820202020- FS_LINUX: db "LINUX " ; 83h , LINUX NATIVE (ext2) Partition 9763 00004069 2020202020 9764 0000406E 4C494E555820455854- FS_LINUXEXT: db "LINUX EXTENDED" ; 85h , LINUX EXTENDED Partition 9764 00004077 454E444544 9765 0000407C 524444202020202020- FS_TRDD: db "RDD " ; A0h , (Random Data Disk) LBA 9765 00004085 2020202020 9766 0000408A 53494E474C49582046- FS_TRFS: db "SINGLIX FS1 " ; A1h , (32 bit, 512 bytes per sector) 9766 00004093 5331202020 9767 00004098 554E4B4E4F574E2046- FS_OTHERS: db "UNKNOWN FS " ; Another or Unknown File Systems 9767 000040A1 5320202020 9768 9769 valid_partitions: ; (*) 9770 000040A6 01020304050607 db 01h, 02h, 03h, 04h, 05h, 06h, 07h 9771 000040AD 0B0C0E0F637172 db 0Bh, 0Ch, 0Eh, 0Fh, 63h, 71h, 72h 9772 000040B4 828385A0A1 db 82h, 83h, 85h, 0A0h, 0A1h 9773 9774 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9775 ; messages 9776 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9777 9778 CHS_msg: ; 80 bytes per row 9779 000040B9 507265737320274327- db "Press 'C' to set cylinders then press '+,-' keys to change number of cylinders. " 9779 000040C2 20746F207365742063- 9779 000040CB 796C696E6465727320- 9779 000040D4 7468656E2070726573- 9779 000040DD 7320272B2C2D27206B- 9779 000040E6 65797320746F206368- 9779 000040EF 616E6765206E756D62- 9779 000040F8 6572206F662063796C- 9779 00004101 696E646572732E20 9780 00004109 507265737320274827- db "Press 'H' to set heads then press '+,-' keys to change number of heads. " 9780 00004112 20746F207365742068- 9780 0000411B 65616473207468656E- 9780 00004124 20707265737320272B- 9780 0000412D 2C2D27206B65797320- 9780 00004136 746F206368616E6765- 9780 0000413F 206E756D626572206F- 9780 00004148 662068656164732E20- 9780 00004151 2020202020202020 9781 00004159 507265737320275327- db "Press 'S' to set sectors then press '+,-' keys to change numb of sectors/track. " 9781 00004162 20746F207365742073- 9781 0000416B 6563746F7273207468- 9781 00004174 656E20707265737320- 9781 0000417D 272B2C2D27206B6579- 9781 00004186 7320746F206368616E- 9781 0000418F 6765206E756D62206F- 9781 00004198 6620736563746F7273- 9781 000041A1 2F747261636B2E20 9782 000041A9 202020202020202020- db " " 9782 000041B2 202020202020202020- 9782 000041BB 202020202020202020- 9782 000041C4 202020202020202020- 9782 000041CD 202020202020202020- 9782 000041D6 202020202020202020- 9782 000041DF 202020202020202020- 9782 000041E8 202020202020202020- 9782 000041F1 2020202020202020 9783 000041F9 202020202020202020- db " " 9783 00004202 202020202020202020- 9783 0000420B 202020202020202020- 9783 00004214 202020202020202020- 9783 0000421D 202020202020202020- 9783 00004226 202020202020202020- 9783 0000422F 202020202020202020- 9783 00004238 202020202020202020- 9783 00004241 2020202020202020 9784 00004249 507265737320454E54- db "Press ENTER to use current CHS values. " 9784 00004252 455220746F20757365- 9784 0000425B 2063757272656E7420- 9784 00004264 4348532076616C7565- 9784 0000426D 732E20202020202020- 9784 00004276 202020202020202020- 9784 0000427F 202020202020202020- 9784 00004288 202020202020202020- 9784 00004291 2020202020202020 9785 00004299 202020202020202020- db " " 9785 000042A2 202020202020202020- 9785 000042AB 202020202020202020- 9785 000042B4 202020202020202020- 9785 000042BD 202020202020202020- 9785 000042C6 202020202020202020- 9785 000042CF 202020202020202020- 9785 000042D8 202020202020202020- 9785 000042E1 2020202020202020 9786 000042E9 507265737320455343- db "Press ESC to cancel. " 9786 000042F2 20746F2063616E6365- 9786 000042FB 6C2E20202020202020- 9786 00004304 202020202020202020- 9786 0000430D 202020202020202020- 9786 00004316 202020202020202020- 9786 0000431F 202020202020202020- 9786 00004328 202020202020202020- 9786 00004331 2020202020202020 9787 00004339 202020202020202020- db " " 9787 00004342 202020202020202020- 9787 0000434B 202020202020202020- 9787 00004354 202020202020202020- 9787 0000435D 202020202020202020- 9787 00004366 202020202020202020- 9787 0000436F 202020202020202020- 9787 00004378 202020202020202020- 9787 00004381 2020202020202020 9788 00004389 00 db 0 9789 9790 ; 04/05/2024 9791 TrDOS_Welcome: 9792 0000438A 0D0A db 0Dh, 0Ah 9793 ;db 'TR-DOS 386 Fixed Disk Partitioning Utility' 9794 0000438C 526574726F20444F53- db 'Retro DOS v5 Fixed Disk Partitioning Utility' 9794 00004395 207635204669786564- 9794 0000439E 204469736B20506172- 9794 000043A7 746974696F6E696E67- 9794 000043B0 205574696C697479 9795 000043B8 0D0A db 0Dh, 0Ah 9796 ;db "v1.1.240504 (c) Erdogan TAN 2021-2024" 9797 000043BA 464449534B33207632- db "FDISK3 v2.0.260129 (c) Erdogan TAN 2021-2026" 9797 000043C3 2E302E323630313239- 9797 000043CC 20286329204572646F- 9797 000043D5 67616E2054414E2032- 9797 000043DE 3032312D32303236 9798 000043E6 0D0A db 0Dh,0Ah 9799 000043E8 0D0A db 0Dh,0Ah 9800 000043EA 00 db 0 9801 TrDOS_Usage: 9802 000043EB 55736167653A206664- db 'Usage: fdisk3r5 ' 9802 000043F4 69736B337235203C68- 9802 000043FD 617264206469736B20- 9802 00004406 6E616D653E20 9803 0000440C 0D0A db 0Dh, 0Ah 9804 0000440E 0D0A db 0Dh, 0Ah 9805 00004410 48617264206469736B- db "Hard disk names: " 9805 00004419 206E616D65733A20 9806 00004421 0D0A db 0Dh, 0Ah 9807 00004423 0D0A db 0Dh, 0Ah 9808 00004425 20686430202E2E666F- db " hd0 ..for 1st hard disk " 9808 0000442E 722031737420686172- 9808 00004437 64206469736B20 9809 0000443E 0D0A db 0Dh, 0Ah 9810 00004440 20686431202E2E666F- db " hd1 ..for 2nd hard disk " 9810 00004449 7220326E6420686172- 9810 00004452 64206469736B20 9811 00004459 0D0A db 0Dh, 0Ah 9812 0000445B 20686432202E2E666F- db " hd2 ..for 3rd hard disk " 9812 00004464 722033726420686172- 9812 0000446D 64206469736B20 9813 00004474 0D0A db 0Dh, 0Ah 9814 00004476 20686433202E2E666F- db " hd3 ..for 4th hard disk " 9814 0000447F 722034746820686172- 9814 00004488 64206469736B20 9815 0000448F 0D0A00 db 0Dh, 0Ah, 0 9816 9817 TrDOS_Options: 9818 00004492 53656C656374206861- db "Select hard disk number (1 to " 9818 0000449B 7264206469736B206E- 9818 000044A4 756D62657220283120- 9818 000044AD 746F20 9819 TrDOS_dnmax: 9820 000044B0 3429206F7220707265- db "4) or press ESC to exit ..." 9820 000044B9 73732045534320746F- 9820 000044C2 2065786974202E2E2E 9821 000044CB 0D0A00 db 0Dh, 0Ah, 0 9822 TrDOS_hdrow: 9823 000044CE 0D0A db 0Dh, 0Ah 9824 000044D0 28 db "(" 9825 TrDOS_hdrow_n: 9826 000044D1 3029206864 db "0) hd" 9827 TrDOS_hdrow_i: 9828 000044D6 30202D204361706163- db "0 - Capacity : " 9828 000044DF 697479203A20 9829 000044E5 00 db 0 9830 TrDOS_hdrow_unit: 9831 000044E6 474220 db "GB " 9832 000044E9 0D0A00 db 0Dh, 0Ah, 0 9833 9834 TrDOS_hdrow_capacity: 9835 000044EC 303030302000 db "0000 ", 0 9836 000044F2 00 db 0 9837 9838 TrDOS_disksize: 9839 000044F3 0D0A db 0Dh, 0Ah 9840 000044F5 4469736B2073697A65- db "Disk size : " 9840 000044FE 203A20 9841 00004501 00 db 0 9842 9843 msg_fdisk_capacity_err: 9844 00004502 0D0A db 0Dh, 0Ah 9845 00004504 48756765206469736B- db "Huge disk !" 9845 0000450D 2021 9846 0000450F 0D0A db 0Dh, 0Ah 9847 00004511 546869732046444953- db "This FDISK version (v3) can work with disk sizes up to " 9847 0000451A 4B2076657273696F6E- 9847 00004523 20287633292063616E- 9847 0000452C 20776F726B20776974- 9847 00004535 68206469736B207369- 9847 0000453E 7A657320757020746F- 9847 00004547 20 9848 00004548 00 db 0 9849 9850 msg_any_key_esc_exit: 9851 00004549 0D0A db 0Dh, 0Ah 9852 0000454B 507265737320455343- db "Press ESC to exit or press another key to continue..." 9852 00004554 20746F206578697420- 9852 0000455D 6F7220707265737320- 9852 00004566 616E6F74686572206B- 9852 0000456F 657920746F20636F6E- 9852 00004578 74696E75652E2E2E 9853 00004580 00 db 0 9854 9855 msg_create_partition_h: 9856 00004581 0D0A db 0Dh, 0Ah 9857 00004583 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9857 0000458C 2D2D2D2D2D2D2D2D2D- 9857 00004595 2D2D2D2D2D2D2D2D2D- 9857 0000459E 2D2D2D2D2D2D2D2D2D- 9857 000045A7 2D2D2D2D2D2D2D2D2D- 9857 000045B0 2D2D2D2D2D2D2D2D2D- 9857 000045B9 2D2D2D2D2D2D2D2D2D- 9857 000045C2 2D2D2D2D2D2D2D2D2D- 9857 000045CB 2D2D2D2D2D2D2D2D 9858 000045D3 202020202020202020- db " Create Partition " 9858 000045DC 202020202020202020- 9858 000045E5 202020202020202020- 9858 000045EE 202020204372656174- 9858 000045F7 652050617274697469- 9858 00004600 6F6E20202020202020- 9858 00004609 202020202020202020- 9858 00004612 202020202020202020- 9858 0000461B 2020202020202020 9859 00004623 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9859 0000462C 2D2D2D2D2D2D2D2D2D- 9859 00004635 2D2D2D2D2D2D2D2D2D- 9859 0000463E 2D2D2D2D2D2D2D2D2D- 9859 00004647 2D2D2D2D2D2D2D2D2D- 9859 00004650 2D2D2D2D2D2D2D2D2D- 9859 00004659 2D2D2D2D2D2D2D2D2D- 9859 00004662 2D2D2D2D2D2D2D2D2D- 9859 0000466B 2D2D2D2D2D2D2D2D 9860 00004673 0D0A00 db 0Dh, 0Ah, 0 9861 msg_create_partition_m: 9862 00004676 53656C65637420616E- db "Select an option: " 9862 0000467F 206F7074696F6E3A20 9863 00004688 0D0A db 0Dh, 0Ah 9864 0000468A 0D0A db 0Dh, 0Ah 9865 0000468C 202031292043726561- db " 1) Create DOS partition ", 0Dh, 0Ah 9865 00004695 746520444F53207061- 9865 0000469E 72746974696F6E200D- 9865 000046A7 0A 9866 000046A8 202032292043726561- db " 2) Create SINGLIX FS partition ", 0Dh, 0Ah 9866 000046B1 74652053494E474C49- 9866 000046BA 582046532070617274- 9866 000046C3 6974696F6E200D0A 9867 000046CB 202033292043726561- db " 3) Create RETRO UNIX partition ", 0Dh, 0Ah 9867 000046D4 746520524554524F20- 9867 000046DD 554E49582070617274- 9867 000046E6 6974696F6E200D0A 9868 000046EE 202034292043726561- db " 4) Create another type of partition ", 0Dh, 0Ah 9868 000046F7 746520616E6F746865- 9868 00004700 722074797065206F66- 9868 00004709 20706172746974696F- 9868 00004712 6E200D0A 9869 00004716 0D0A db 0Dh, 0Ah 9870 00004718 507265737320455343- db "Press ESC or 0 to cancel .. " 9870 00004721 206F72203020746F20- 9870 0000472A 63616E63656C202E2E- 9870 00004733 20 9871 00004734 0D0A00 db 0Dh, 0Ah, 0 9872 9873 msg_create_primary_partition_h: 9874 00004737 0D0A db 0Dh, 0Ah 9875 00004739 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9875 00004742 2D2D2D2D2D2D2D2D2D- 9875 0000474B 2D2D2D2D2D2D2D2D2D- 9875 00004754 2D2D2D2D2D2D2D2D2D- 9875 0000475D 2D2D2D2D2D2D2D2D2D- 9875 00004766 2D2D2D2D2D2D2D2D2D- 9875 0000476F 2D2D2D2D2D2D2D2D2D- 9875 00004778 2D2D2D2D2D2D2D2D2D- 9875 00004781 2D2D2D2D2D2D2D2D 9876 00004789 202020202020202020- db " Create Primary DOS Partition " 9876 00004792 202020202020202020- 9876 0000479B 202020202020202043- 9876 000047A4 726561746520507269- 9876 000047AD 6D61727920444F5320- 9876 000047B6 506172746974696F6E- 9876 000047BF 202020202020202020- 9876 000047C8 202020202020202020- 9876 000047D1 2020202020202020 9877 000047D9 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9877 000047E2 2D2D2D2D2D2D2D2D2D- 9877 000047EB 2D2D2D2D2D2D2D2D2D- 9877 000047F4 2D2D2D2D2D2D2D2D2D- 9877 000047FD 2D2D2D2D2D2D2D2D2D- 9877 00004806 2D2D2D2D2D2D2D2D2D- 9877 0000480F 2D2D2D2D2D2D2D2D2D- 9877 00004818 2D2D2D2D2D2D2D2D2D- 9877 00004821 2D2D2D2D2D2D2D2D 9878 00004829 0D0A00 db 0Dh, 0Ah, 0 9879 9880 msg_create_dos_partition_h: 9881 0000482C 0D0A db 0Dh, 0Ah 9882 0000482E 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9882 00004837 2D2D2D2D2D2D2D2D2D- 9882 00004840 2D2D2D2D2D2D2D2D2D- 9882 00004849 2D2D2D2D2D2D2D2D2D- 9882 00004852 2D2D2D2D2D2D2D2D2D- 9882 0000485B 2D2D2D2D2D2D2D2D2D- 9882 00004864 2D2D2D2D2D2D2D2D2D- 9882 0000486D 2D2D2D2D2D2D2D2D2D- 9882 00004876 2D2D2D2D2D2D2D2D 9883 0000487E 202020202020202020- db " Create DOS Partition or Logical DOS Drive " 9883 00004887 202020202020202020- 9883 00004890 204372656174652044- 9883 00004899 4F5320506172746974- 9883 000048A2 696F6E206F72204C6F- 9883 000048AB 676963616C20444F53- 9883 000048B4 204472697665202020- 9883 000048BD 202020202020202020- 9883 000048C6 2020202020202020 9884 000048CE 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9884 000048D7 2D2D2D2D2D2D2D2D2D- 9884 000048E0 2D2D2D2D2D2D2D2D2D- 9884 000048E9 2D2D2D2D2D2D2D2D2D- 9884 000048F2 2D2D2D2D2D2D2D2D2D- 9884 000048FB 2D2D2D2D2D2D2D2D2D- 9884 00004904 2D2D2D2D2D2D2D2D2D- 9884 0000490D 2D2D2D2D2D2D2D2D2D- 9884 00004916 2D2D2D2D2D2D2D2D 9885 0000491E 0D0A00 db 0Dh, 0Ah, 0 9886 9887 msg_create_ext_partition_h: 9888 00004921 0D0A db 0Dh, 0Ah 9889 00004923 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9889 0000492C 2D2D2D2D2D2D2D2D2D- 9889 00004935 2D2D2D2D2D2D2D2D2D- 9889 0000493E 2D2D2D2D2D2D2D2D2D- 9889 00004947 2D2D2D2D2D2D2D2D2D- 9889 00004950 2D2D2D2D2D2D2D2D2D- 9889 00004959 2D2D2D2D2D2D2D2D2D- 9889 00004962 2D2D2D2D2D2D2D2D2D- 9889 0000496B 2D2D2D2D2D2D2D2D 9890 00004973 202020202020202020- db " Create Extended DOS Partition " 9890 0000497C 202020202020202020- 9890 00004985 202020202020204372- 9890 0000498E 656174652045787465- 9890 00004997 6E64656420444F5320- 9890 000049A0 506172746974696F6E- 9890 000049A9 202020202020202020- 9890 000049B2 202020202020202020- 9890 000049BB 2020202020202020 9891 000049C3 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9891 000049CC 2D2D2D2D2D2D2D2D2D- 9891 000049D5 2D2D2D2D2D2D2D2D2D- 9891 000049DE 2D2D2D2D2D2D2D2D2D- 9891 000049E7 2D2D2D2D2D2D2D2D2D- 9891 000049F0 2D2D2D2D2D2D2D2D2D- 9891 000049F9 2D2D2D2D2D2D2D2D2D- 9891 00004A02 2D2D2D2D2D2D2D2D2D- 9891 00004A0B 2D2D2D2D2D2D2D2D 9892 00004A13 0D0A00 db 0Dh, 0Ah, 0 9893 9894 msg_create_logical_drive_h: 9895 00004A16 0D0A db 0Dh, 0Ah 9896 00004A18 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9896 00004A21 2D2D2D2D2D2D2D2D2D- 9896 00004A2A 2D2D2D2D2D2D2D2D2D- 9896 00004A33 2D2D2D2D2D2D2D2D2D- 9896 00004A3C 2D2D2D2D2D2D2D2D2D- 9896 00004A45 2D2D2D2D2D2D2D2D2D- 9896 00004A4E 2D2D2D2D2D2D2D2D2D- 9896 00004A57 2D2D2D2D2D2D2D2D2D- 9896 00004A60 2D2D2D2D2D2D2D2D 9897 00004A68 202020202020202020- db " Create Logical DOS Drive " 9897 00004A71 202020202020202020- 9897 00004A7A 202020202020202020- 9897 00004A83 20437265617465204C- 9897 00004A8C 6F676963616C20444F- 9897 00004A95 532044726976652020- 9897 00004A9E 202020202020202020- 9897 00004AA7 202020202020202020- 9897 00004AB0 2020202020202020 9898 00004AB8 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9898 00004AC1 2D2D2D2D2D2D2D2D2D- 9898 00004ACA 2D2D2D2D2D2D2D2D2D- 9898 00004AD3 2D2D2D2D2D2D2D2D2D- 9898 00004ADC 2D2D2D2D2D2D2D2D2D- 9898 00004AE5 2D2D2D2D2D2D2D2D2D- 9898 00004AEE 2D2D2D2D2D2D2D2D2D- 9898 00004AF7 2D2D2D2D2D2D2D2D2D- 9898 00004B00 2D2D2D2D2D2D2D2D 9899 00004B08 0D0A00 db 0Dh, 0Ah, 0 9900 9901 msg_create_nondos_partition_h: 9902 00004B0B 0D0A db 0Dh, 0Ah 9903 00004B0D 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9903 00004B16 2D2D2D2D2D2D2D2D2D- 9903 00004B1F 2D2D2D2D2D2D2D2D2D- 9903 00004B28 2D2D2D2D2D2D2D2D2D- 9903 00004B31 2D2D2D2D2D2D2D2D2D- 9903 00004B3A 2D2D2D2D2D2D2D2D2D- 9903 00004B43 2D2D2D2D2D2D2D2D2D- 9903 00004B4C 2D2D2D2D2D2D2D2D2D- 9903 00004B55 2D2D2D2D2D2D2D2D 9904 00004B5D 202020202020202020- db " Create NON-DOS Partition " 9904 00004B66 202020202020202020- 9904 00004B6F 202020202020202020- 9904 00004B78 20437265617465204E- 9904 00004B81 4F4E2D444F53205061- 9904 00004B8A 72746974696F6E2020- 9904 00004B93 202020202020202020- 9904 00004B9C 202020202020202020- 9904 00004BA5 2020202020202020 9905 00004BAD 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9905 00004BB6 2D2D2D2D2D2D2D2D2D- 9905 00004BBF 2D2D2D2D2D2D2D2D2D- 9905 00004BC8 2D2D2D2D2D2D2D2D2D- 9905 00004BD1 2D2D2D2D2D2D2D2D2D- 9905 00004BDA 2D2D2D2D2D2D2D2D2D- 9905 00004BE3 2D2D2D2D2D2D2D2D2D- 9905 00004BEC 2D2D2D2D2D2D2D2D2D- 9905 00004BF5 2D2D2D2D2D2D2D2D 9906 00004BFD 0D0A00 db 0Dh, 0Ah, 0 9907 9908 msg_create_dos_partition_m: 9909 00004C00 53656C65637420616E- db "Select an option: " 9909 00004C09 206F7074696F6E3A20 9910 00004C12 0D0A db 0Dh, 0Ah 9911 00004C14 0D0A db 0Dh, 0Ah 9912 00004C16 202031292043726561- db " 1) Create Primary DOS partition ", 0Dh, 0Ah 9912 00004C1F 7465205072696D6172- 9912 00004C28 7920444F5320706172- 9912 00004C31 746974696F6E200D0A 9913 00004C3A 202032292043726561- db " 2) Create Extended DOS partition ", 0Dh, 0Ah 9913 00004C43 746520457874656E64- 9913 00004C4C 656420444F53207061- 9913 00004C55 72746974696F6E200D- 9913 00004C5E 0A 9914 00004C5F 202033292043726561- db " 3) Create Logical DOS drive(s) in Extended DOS partition ", 0Dh, 0Ah 9914 00004C68 7465204C6F67696361- 9914 00004C71 6C20444F5320647269- 9914 00004C7A 766528732920696E20- 9914 00004C83 457874656E64656420- 9914 00004C8C 444F53207061727469- 9914 00004C95 74696F6E200D0A 9915 00004C9C 0D0A db 0Dh, 0Ah 9916 00004C9E 507265737320455343- db "Press ESC or 0 to cancel .. " 9916 00004CA7 206F72203020746F20- 9916 00004CB0 63616E63656C202E2E- 9916 00004CB9 20 9917 00004CBA 0D0A00 db 0Dh, 0Ah, 0 9918 9919 msg_create_trdos_partition_s: 9920 00004CBD 53656C65637420616E- db "Select an option to set partition size: " 9920 00004CC6 206F7074696F6E2074- 9920 00004CCF 6F2073657420706172- 9920 00004CD8 746974696F6E207369- 9920 00004CE1 7A653A20 9921 00004CE5 0D0A db 0Dh, 0Ah 9922 00004CE7 0D0A db 0Dh, 0Ah 9923 00004CE9 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 9923 00004CF2 6E64657220636F756E- 9923 00004CFB 740D0A 9924 00004CFE 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 9924 00004D07 6D652070657263656E- 9924 00004D10 746167652028232325- 9924 00004D19 290D0A 9925 00004D1C 202053292053656374- db " S) Sectors (number of 512 bytes)", 0Dh, 0Ah 9925 00004D25 6F727320286E756D62- 9925 00004D2E 6572206F6620353132- 9925 00004D37 206279746573290D0A 9926 00004D40 20204B29204B696C6F- db " K) Kilo bytes (KB, 2*K sectors)", 0Dh, 0Ah 9926 00004D49 20627974657320284B- 9926 00004D52 422C20322A4B207365- 9926 00004D5B 63746F7273290D0A 9927 00004D63 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 9927 00004D6C 20627974657320284D- 9927 00004D75 422C20322A31303234- 9927 00004D7E 2A4D20736563746F72- 9927 00004D87 73290D0A 9928 00004D8B 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 9928 00004D94 206279746573202847- 9928 00004D9D 422C20322A31303234- 9928 00004DA6 2A313032342A472073- 9928 00004DAF 6563746F7273290D0A 9929 00004DB8 0D0A db 0Dh, 0Ah 9930 00004DBA 507265737320535041- db "Press SPACE to use whole disk or press ENTER to set sector count .. " 9930 00004DC3 434520746F20757365- 9930 00004DCC 2077686F6C65206469- 9930 00004DD5 736B206F7220707265- 9930 00004DDE 737320454E54455220- 9930 00004DE7 746F20736574207365- 9930 00004DF0 63746F7220636F756E- 9930 00004DF9 74202E2E20 9931 msg_press_esc_to_cancel: 9932 00004DFE 0D0A db 0Dh, 0Ah 9933 00004E00 285072657373204553- db "(Press ESC to CANCEL) " 9933 00004E09 4320746F2043414E43- 9933 00004E12 454C2920 9934 00004E16 0D0A00 db 0Dh, 0Ah, 0 9935 9936 msg_use_whole_disk: 9937 00004E19 446F20796F75207761- db "Do you want to use WHOLE disk !? (Y/N)", 0 9937 00004E22 6E7420746F20757365- 9937 00004E2B 2057484F4C45206469- 9937 00004E34 736B20213F2028592F- 9937 00004E3D 4E2900 9938 9939 msg_use_all_space: 9940 00004E40 446F20796F75207761- db "Do you want to use all of available space !? (Y/N)", 0 9940 00004E49 6E7420746F20757365- 9940 00004E52 20616C6C206F662061- 9940 00004E5B 7661696C61626C6520- 9940 00004E64 737061636520213F20- 9940 00004E6D 28592F4E2900 9941 9942 msg_use_entire_ep_space: 9943 00004E73 446F20796F75207761- db "Do you want to use entire extended partition space !? (Y/N)", 0 9943 00004E7C 6E7420746F20757365- 9943 00004E85 20656E746972652065- 9943 00004E8E 7874656E6465642070- 9943 00004E97 6172746974696F6E20- 9943 00004EA0 737061636520213F20- 9943 00004EA9 28592F4E2900 9944 9945 msg_partition_size: 9946 00004EAF 0D0A db 0Dh, 0Ah 9947 00004EB1 0D0A db 0Dh, 0Ah 9948 00004EB3 506172746974696F6E- db "Partition size (" 9948 00004EBC 2073697A652028 9949 msg_partition_size_x: 9950 00004EC3 3F29203A20 db "?) : " 9951 00004EC8 00 db 0 9952 9953 msg_partition_type: 9954 00004EC9 0D0A db 0Dh, 0Ah 9955 00004ECB 0D0A db 0Dh, 0Ah 9956 00004ECD 506172746974696F6E- db "Partition type : " 9956 00004ED6 2074797065203A20 9957 00004EDE 00 db 0 9958 9959 msg_ptype_num: 9960 00004EDF 3030680D0A00 db "00h", 0Dh, 0Ah, 0 9961 9962 msg_partition_type_error: 9963 00004EE5 506172746974696F6E- db "Partition size is not proper for selected partition type !" 9963 00004EEE 2073697A6520697320- 9963 00004EF7 6E6F742070726F7065- 9963 00004F00 7220666F722073656C- 9963 00004F09 656374656420706172- 9963 00004F12 746974696F6E207479- 9963 00004F1B 70652021 9964 00004F1F 0D0A db 0Dh, 0Ah 9965 msg_any_key_to_retry: 9966 00004F21 28507265737320616E- db "(Press any key to retry..)" 9966 00004F2A 79206B657920746F20- 9966 00004F33 72657472792E2E29 9967 00004F3B 0D0A00 db 0Dh, 0Ah, 0 9968 9969 msg_partition_size_overs: 9970 00004F3E 0D0A db 0Dh, 0Ah 9971 00004F40 506172746974696F6E- db "Partition size overs the disk capacity !" 9971 00004F49 2073697A65206F7665- 9971 00004F52 727320746865206469- 9971 00004F5B 736B20636170616369- 9971 00004F64 74792021 9972 00004F68 0D0A db 0Dh, 0Ah 9973 00004F6A 28507265737320454E- db "(Press ENTER to use WHOLE disk or press ESC key to retry..)" 9973 00004F73 54455220746F207573- 9973 00004F7C 652057484F4C452064- 9973 00004F85 69736B206F72207072- 9973 00004F8E 65737320455343206B- 9973 00004F97 657920746F20726574- 9973 00004FA0 72792E2E29 9974 00004FA5 0D0A00 db 0Dh, 0Ah, 0 9975 9976 msg_ext_partition_error: 9977 00004FA8 457874656E64656420- db "Extended partition must be created after primary partition !" 9977 00004FB1 706172746974696F6E- 9977 00004FBA 206D75737420626520- 9977 00004FC3 637265617465642061- 9977 00004FCC 66746572207072696D- 9977 00004FD5 617279207061727469- 9977 00004FDE 74696F6E2021 9978 00004FE4 0D0A00 db 0Dh, 0Ah,0 9979 9980 msg_logical_drive_error: 9981 00004FE7 5072696D6172792061- db "Primary and extended partitions must be created before logical drive !" 9981 00004FF0 6E6420657874656E64- 9981 00004FF9 656420706172746974- 9981 00005002 696F6E73206D757374- 9981 0000500B 206265206372656174- 9981 00005014 6564206265666F7265- 9981 0000501D 206C6F676963616C20- 9981 00005026 64726976652021 9982 0000502D 0D0A00 db 0Dh, 0Ah,0 9983 9984 msg_cylinder_boundary_set: 9985 00005030 0D0A db 0Dh, 0Ah 9986 00005032 446F20796F75207761- db "Do you want to adjust partition size to cylinder boundary ? (Y/N)" 9986 0000503B 6E7420746F2061646A- 9986 00005044 757374207061727469- 9986 0000504D 74696F6E2073697A65- 9986 00005056 20746F2063796C696E- 9986 0000505F 64657220626F756E64- 9986 00005068 617279203F2028592F- 9986 00005071 4E29 9987 00005073 00 db 0 9988 9989 ; 2019 - 2020 (hdimage.s) 9990 ;msg_selected_partition: 9991 ; db " PARTITION 0 " 9992 ; db "================================================================================" 9993 ; db " S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 9994 ; db "--------------------------------------------------------------------------------" 9995 ;pt_row: db " " 9996 ; db "================================================================================" 9997 ; db 0 9998 9999 ; 24/10/2020 (fdisk3.s) 10000 msg_selected_partition: 10001 00005074 202020202020202020- db " PARTITION 0 " 10001 0000507D 202020202020202020- 10001 00005086 202020202020202020- 10001 0000508F 202020202020504152- 10001 00005098 544954494F4E203020- 10001 000050A1 202020202020202020- 10001 000050AA 202020202020202020- 10001 000050B3 202020202020202020- 10001 000050BC 2020202020202020 10002 000050C4 3D3D3D3D3D3D3D3D3D- db "================================================================================" 10002 000050CD 3D3D3D3D3D3D3D3D3D- 10002 000050D6 3D3D3D3D3D3D3D3D3D- 10002 000050DF 3D3D3D3D3D3D3D3D3D- 10002 000050E8 3D3D3D3D3D3D3D3D3D- 10002 000050F1 3D3D3D3D3D3D3D3D3D- 10002 000050FA 3D3D3D3D3D3D3D3D3D- 10002 00005103 3D3D3D3D3D3D3D3D3D- 10002 0000510C 3D3D3D3D3D3D3D3D 10003 00005114 202020202020205320- db " S BH BS BC FS EH ES EC START SECT SECTORS FILE SYSTEM " 10003 0000511D 204248202042532020- 10003 00005126 424320204653202045- 10003 0000512F 482020455320204543- 10003 00005138 202020535441525420- 10003 00005141 534543542020202053- 10003 0000514A 4543544F5253202020- 10003 00005153 46494C452053595354- 10003 0000515C 454D202020202020 10004 00005164 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 10004 0000516D 2D2D2D2D2D2D2D2D2D- 10004 00005176 2D2D2D2D2D2D2D2D2D- 10004 0000517F 2D2D2D2D2D2D2D2D2D- 10004 00005188 2D2D2D2D2D2D2D2D2D- 10004 00005191 2D2D2D2D2D2D2D2D2D- 10004 0000519A 2D2D2D2D2D2D2D2D2D- 10004 000051A3 2D2D2D2D2D2D2D2D2D- 10004 000051AC 2D2D2D2D2D2D2D2D 10005 000051B4 202020202020202020- pt_row: db " " 10005 000051BD 202020202020202020- 10005 000051C6 202020202020202020- 10005 000051CF 202020202020202020- 10005 000051D8 202020202020202020- 10005 000051E1 202020202020202020- 10005 000051EA 202020202020202020- 10005 000051F3 202020202020202020- 10005 000051FC 2020202020202020 10006 00005204 3D3D3D3D3D3D3D3D3D- db "================================================================================" 10006 0000520D 3D3D3D3D3D3D3D3D3D- 10006 00005216 3D3D3D3D3D3D3D3D3D- 10006 0000521F 3D3D3D3D3D3D3D3D3D- 10006 00005228 3D3D3D3D3D3D3D3D3D- 10006 00005231 3D3D3D3D3D3D3D3D3D- 10006 0000523A 3D3D3D3D3D3D3D3D3D- 10006 00005243 3D3D3D3D3D3D3D3D3D- 10006 0000524C 3D3D3D3D3D3D3D3D 10007 00005254 00 db 0 10008 msg_boot_indicator: 10009 00005255 0D0A db 0Dh, 0Ah 10010 00005257 20202020426F6F7420- db " Boot Indicator : ", 0 ; "YES", "NO" 10010 00005260 496E64696361746F72- 10010 00005269 203A2000 10011 msg_starting_head: 10012 0000526D 0D0A db 0Dh, 0Ah 10013 0000526F 202020202053746172- db " Starting Head : ", 0 10013 00005278 74696E672048656164- 10013 00005281 203A2000 10014 msg_starting_sector: 10015 00005285 0D0A db 0Dh, 0Ah 10016 00005287 202020537461727469- db " Starting Sector : ", 0 10016 00005290 6E6720536563746F72- 10016 00005299 203A2000 10017 msg_starting_cylinder: 10018 0000529D 0D0A db 0Dh, 0Ah 10019 0000529F 205374617274696E67- db " Starting Cylinder : ", 0 10019 000052A8 2043796C696E646572- 10019 000052B1 203A2000 10020 msg_system_id: 10021 000052B5 0D0A db 0Dh, 0Ah 10022 000052B7 202020202020202020- db " System ID : ", 0 10022 000052C0 53797374656D204944- 10022 000052C9 203A2000 10023 msg_ending_head: 10024 000052CD 0D0A db 0Dh, 0Ah 10025 000052CF 20202020202020456E- db " Ending Head : ", 0 10025 000052D8 64696E672048656164- 10025 000052E1 203A2000 10026 msg_ending_sector: 10027 000052E5 0D0A db 0Dh, 0Ah 10028 000052E7 2020202020456E6469- db " Ending Sector : ", 0 10028 000052F0 6E6720536563746F72- 10028 000052F9 203A2000 10029 msg_ending_cylinder: 10030 000052FD 0D0A db 0Dh, 0Ah 10031 000052FF 202020456E64696E67- db " Ending Cylinder : ", 0 10031 00005308 2043796C696E646572- 10031 00005311 203A2000 10032 msg_relative_sectors: 10033 00005315 0D0A db 0Dh, 0Ah 10034 00005317 0D0A db 0Dh, 0Ah 10035 00005319 202052656C61746976- db " Relative Sectors : ", 0 10035 00005322 6520536563746F7273- 10035 0000532B 203A2000 10036 msg_total_sectors: 10037 0000532F 0D0A db 0Dh, 0Ah 10038 00005331 2020202020546F7461- db " Total Sectors : ", 0 10038 0000533A 6C20536563746F7273- 10038 00005343 203A2000 10039 10040 msg_format_stage: 10041 00005347 0D0A db 0Dh, 0Ah 10042 00005349 507265737320454E54- db "Press ENTER to FORMAT disk partition " 10042 00005352 455220746F20464F52- 10042 0000535B 4D4154206469736B20- 10042 00005364 706172746974696F6E- 10042 0000536D 20 10043 partition_num_chr: 10044 0000536E 30 db "0" 10045 0000536F 206F72207072657373- db " or press ESC to EXIT.." 10045 00005378 2045534320746F2045- 10045 00005381 5849542E2E 10046 00005386 00 db 0 10047 msg_partition_edit: 10048 00005387 0D0A db 0Dh, 0Ah 10049 00005389 2E2E206F7220707265- db ".. or press SPACE to EDIT partition table." 10049 00005392 737320535041434520- 10049 0000539B 746F20454449542070- 10049 000053A4 6172746974696F6E20- 10049 000053AD 7461626C652E 10050 000053B3 0D0A00 db 0Dh, 0Ah, 0 10051 10052 msg_edit_or_exit: 10053 000053B6 0D0A db 0Dh, 0Ah 10054 000053B8 507265737320454E54- db "Press ENTER to continue or press ESC to exit.." 10054 000053C1 455220746F20636F6E- 10054 000053CA 74696E7565206F7220- 10054 000053D3 707265737320455343- 10054 000053DC 20746F20657869742E- 10054 000053E5 2E 10055 000053E6 00 db 0 10056 10057 msg_overwrite_question1: 10058 000053E7 0D0A db 0Dh, 0Ah 10059 000053E9 446F20796F75207761- db 'Do you want to overwrite ' 10059 000053F2 6E7420746F206F7665- 10059 000053FB 72777269746520 10060 00005402 27 db 27h 10061 00005403 00 db 0 10062 10063 msg_overwrite_question2: 10064 00005404 27 db 27h 10065 00005405 2066696C6520 db ' file ' 10066 0000540B 00 db 0 10067 10068 msg_format_question: 10069 0000540C 0D0A db 0Dh, 0Ah 10070 0000540E 446F20796F75207761- db "Do you want to format partition " 10070 00005417 6E7420746F20666F72- 10070 00005420 6D6174207061727469- 10070 00005429 74696F6E20 10071 partition_num_txt: 10072 0000542E 3020 db "0 " 10073 msg_yes_no: 10074 00005430 285965732F4E6F293F- db '(Yes/No)? ', 0 10074 00005439 2000 10075 10076 msg_writing_mbr: 10077 0000543B 57726974696E67206D- db "Writing masterboot sector...", 0 10077 00005444 6173746572626F6F74- 10077 0000544D 20736563746F722E2E- 10077 00005456 2E00 10078 10079 msg_writing_disk_sectors: 10080 00005458 57726974696E672064- db "Writing disk sector: ", 0 10080 00005461 69736B20736563746F- 10080 0000546A 723A2000 10081 10082 Msg_Writing_Boot_Sector: 10083 0000546E 57726974696E672074- db "Writing trdos boot sector...", 0 10083 00005477 72646F7320626F6F74- 10083 00005480 20736563746F722E2E- 10083 00005489 2E00 10084 10085 Msg_Writing_Root_Dir: 10086 0000548B 57726974696E672072- db "Writing root directory sectors...", 0 10086 00005494 6F6F74206469726563- 10086 0000549D 746F72792073656374- 10086 000054A6 6F72732E2E2E00 10087 10088 Msg_Writing_Data_Sectors: 10089 000054AD 57726974696E672064- db "Writing data sector: ", 0 10089 000054B6 61746120736563746F- 10089 000054BF 723A2000 10090 10091 Sector_Str: 10092 000054C3 3030303030303000 db "0000000", 0 10093 Cursor_Pos: 10094 000054CB 0000 dw 0 10095 10096 Msg_Writing_FAT_Sectors: 10097 000054CD 57726974696E672046- db "Writing FAT sectors...", 0 10097 000054D6 415420736563746F72- 10097 000054DF 732E2E2E00 10098 10099 StrVolumeName: 10100 ;times 12 db 0 10101 000054E4 00 times 65 db 0 ; 05/01/2018 (fs1 volume name) 10102 10103 Msg_Volume_Name: 10104 00005525 0D0A db 0Dh, 0Ah 10105 00005527 0D0A db 0Dh, 0Ah 10106 00005529 566F6C756D65204E61- db "Volume Name: ", 0 10106 00005532 6D653A2000 10107 10108 Msg_Volume_Serial: 10109 00005537 566F6C756D65205365- db "Volume Serial No: " 10109 00005540 7269616C204E6F3A20 10110 Vol_Serial1: 10111 00005549 30303030 db "0000" 10112 0000554D 2D db "-" 10113 Vol_Serial2: 10114 0000554E 30303030 db "0000" 10115 00005552 0D0A00 db 0Dh, 0Ah, 0 10116 10117 msg_cluster_count: 10118 00005555 436C75737465722043- db "Cluster Count: ", 0 10118 0000555E 6F756E743A2000 10119 cluster_count_str: 10120 00005565 30303030303030 db "0000000" 10121 0000556C 0D0A00 db 0Dh, 0Ah, 0 10122 msg_formatting: 10123 0000556F 466F726D617474696E- db "Formatting ", 0 10123 00005578 672000 10124 format_percent_str: 10125 0000557B 30303025 db "000%" 10126 0000557F 00 db 0 10127 10128 Msg_3dot_OK: 10129 00005580 2E2E2E db "..." 10130 Msg_OK: 10131 00005583 204F4B2E db ' OK.' 10132 CRLF: 10133 00005587 0D0A00 db 0Dh, 0Ah, 0 10134 10135 Msg_Error: 10136 0000558A 0D0A db 0Dh, 0Ah 10137 0000558C 4572726F72202120 db 'Error ! ' 10138 00005594 28 db '(' 10139 error_code: 10140 00005595 3030 dw 3030h 10141 00005597 68 db 'h' 10142 00005598 2920 db ') ' 10143 0000559A 0D0A db 0Dh, 0Ah 10144 0000559C 00 db 0 10145 10146 msg_disk_sectors: 10147 0000559D 546F74616C20446973- db "Total Disk Sectors : ", 0 10147 000055A6 6B20536563746F7273- 10147 000055AF 203A2000 10148 10149 str_disk_sectors: 10150 ;times 8 db 0 10151 000055B3 00 times 11 db 0 ; 27/10/2020 10152 10153 msg_ep_size: 10154 000055BE 457874656E64656420- db "Extended Partition Size in Sectors: ", 0 10154 000055C7 506172746974696F6E- 10154 000055D0 2053697A6520696E20- 10154 000055D9 536563746F72733A20- 10154 000055E2 00 10155 10156 msg_press_any_key: 10157 000055E3 0D0A db 0Dh, 0Ah 10158 000055E5 50726573732061206B- db "Press a key to continue..." 10158 000055EE 657920746F20636F6E- 10158 000055F7 74696E75652E2E2E 10159 000055FF 0D0A00 db 0Dh, 0Ah, 0 10160 10161 align 2 10162 10163 ; Masterboot sector 10164 10165 MasterBootBuff: 10166 MasterBootCode: 10167 00005602 00 times 446 db 0 10168 PartitionTable: 10169 000057C0 00 times 64 db 0 10170 MBIDCode: 10171 00005800 0000 dw 0 10172 10173 PTable_Buffer: 10174 00005802 00 times 64 db 0 10175 10176 00005842 286329204572646F67- db '(c) Erdogan TAN 2019-2026' 10176 0000584B 616E2054414E203230- 10176 00005854 31392D32303236 10177 10178 ; 05/11/2020 10179 0000585B 00 db 0 10180 10181 ; 2019 - 2020 (hdimage.s) 10182 ;p_table_header: 10183 ; db " ?BR PARTITION TABLE " 10184 ; db "================================================================================" 10185 ; db " P S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 10186 ; db "--------------------------------------------------------------------------------" 10187 ; db 0 10188 ;p_table_footer: 10189 ; db "================================================================================" 10190 ; db 0Dh, 0Ah, 0 10191 10192 ; 24/10/2020 (fdisk3.s) 10193 p_table_header: 10194 0000585C 202020202020202020- db " ?BR PARTITION TABLE " 10194 00005865 202020202020202020- 10194 0000586E 202020202020202020- 10194 00005877 2020203F4252205041- 10194 00005880 52544954494F4E2054- 10194 00005889 41424C452020202020- 10194 00005892 202020202020202020- 10194 0000589B 202020202020202020- 10194 000058A4 2020202020202020 10195 000058AC 3D3D3D3D3D3D3D3D3D- db "================================================================================" 10195 000058B5 3D3D3D3D3D3D3D3D3D- 10195 000058BE 3D3D3D3D3D3D3D3D3D- 10195 000058C7 3D3D3D3D3D3D3D3D3D- 10195 000058D0 3D3D3D3D3D3D3D3D3D- 10195 000058D9 3D3D3D3D3D3D3D3D3D- 10195 000058E2 3D3D3D3D3D3D3D3D3D- 10195 000058EB 3D3D3D3D3D3D3D3D3D- 10195 000058F4 3D3D3D3D3D3D3D3D 10196 000058FC 202020502020205320- db " P S BH BS BC FS EH ES EC START SECT SECTORS FILE SYSTEM " 10196 00005905 204248202042532020- 10196 0000590E 424320204653202045- 10196 00005917 482020455320204543- 10196 00005920 202020535441525420- 10196 00005929 534543542020202053- 10196 00005932 4543544F5253202020- 10196 0000593B 2046494C4520535953- 10196 00005944 54454D2020202020 10197 0000594C 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 10197 00005955 2D2D2D2D2D2D2D2D2D- 10197 0000595E 2D2D2D2D2D2D2D2D2D- 10197 00005967 2D2D2D2D2D2D2D2D2D- 10197 00005970 2D2D2D2D2D2D2D2D2D- 10197 00005979 2D2D2D2D2D2D2D2D2D- 10197 00005982 2D2D2D2D2D2D2D2D2D- 10197 0000598B 2D2D2D2D2D2D2D2D2D- 10197 00005994 2D2D2D2D2D2D2D2D 10198 0000599C 00 db 0 10199 p_table_footer: 10200 0000599D 3D3D3D3D3D3D3D3D3D- db "================================================================================" 10200 000059A6 3D3D3D3D3D3D3D3D3D- 10200 000059AF 3D3D3D3D3D3D3D3D3D- 10200 000059B8 3D3D3D3D3D3D3D3D3D- 10200 000059C1 3D3D3D3D3D3D3D3D3D- 10200 000059CA 3D3D3D3D3D3D3D3D3D- 10200 000059D3 3D3D3D3D3D3D3D3D3D- 10200 000059DC 3D3D3D3D3D3D3D3D3D- 10200 000059E5 3D3D3D3D3D3D3D3D 10201 000059ED 0D0A00 db 0Dh, 0Ah, 0 10202 10203 mbr_editing_options: 10204 000059F0 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10205 000059F4 4D4252205061727469- db "MBR Partition Table Editing Options:" 10205 000059FD 74696F6E205461626C- 10205 00005A06 652045646974696E67- 10205 00005A0F 204F7074696F6E733A 10206 00005A18 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10207 00005A1C 20202020202020312E- db " 1. Create Partition", 0Dh, 0Ah 10207 00005A25 204372656174652050- 10207 00005A2E 6172746974696F6E0D- 10207 00005A37 0A 10208 00005A38 20202020202020322E- db " 2. Set Active Partition", 0Dh, 0Ah 10208 00005A41 205365742041637469- 10208 00005A4A 766520506172746974- 10208 00005A53 696F6E0D0A 10209 00005A58 20202020202020332E- db " 3. Delete Partition", 0Dh, 0Ah 10209 00005A61 2044656C6574652050- 10209 00005A6A 6172746974696F6E0D- 10209 00005A73 0A 10210 00005A74 20202020202020342E- db " 4. Write Current Partition Table", 0Dh, 0Ah, 0 10210 00005A7D 205772697465204375- 10210 00005A86 7272656E7420506172- 10210 00005A8F 746974696F6E205461- 10210 00005A98 626C650D0A00 10211 10212 enter_option_number_msg: 10213 00005A9E 0D0A db 0Dh, 0Ah 10214 00005AA0 456E74657220746865- db "Enter the option number or press ESC to exit ...", 0Dh, 0Ah 10214 00005AA9 206F7074696F6E206E- 10214 00005AB2 756D626572206F7220- 10214 00005ABB 707265737320455343- 10214 00005AC4 20746F206578697420- 10214 00005ACD 2E2E2E0D0A 10215 ;db 0Dh, 0Ah, 0 10216 00005AD2 00 db 0 10217 10218 msg_zero_partition_size: ; 19/02/2019 10219 00005AD3 0D0A db 0Dh, 0Ah 10220 00005AD5 506172746974696F6E- db "Partition size input must not be ZERO !", 0Dh, 0Ah 10220 00005ADE 2073697A6520696E70- 10220 00005AE7 7574206D757374206E- 10220 00005AF0 6F74206265205A4552- 10220 00005AF9 4F20210D0A 10221 00005AFE 285072657373204553- db "(Press ESC to exit or press another key to retry..)", 0Dh, 0Ah 10221 00005B07 4320746F2065786974- 10221 00005B10 206F72207072657373- 10221 00005B19 20616E6F7468657220- 10221 00005B22 6B657920746F207265- 10221 00005B2B 7472792E2E290D0A 10222 00005B33 00 db 0 10223 10224 msg_empty_pt: 10225 00005B34 0D0A db 0Dh, 0Ah 10226 00005B36 456D70747920706172- db "Empty partition table !", 0Dh, 0Ah 10226 00005B3F 746974696F6E207461- 10226 00005B48 626C6520210D0A 10227 00005B4F 28412076616C696420- db "(A valid partition must be created at first..)", 0Dh, 0Ah 10227 00005B58 706172746974696F6E- 10227 00005B61 206D75737420626520- 10227 00005B6A 637265617465642061- 10227 00005B73 742066697273742E2E- 10227 00005B7C 290D0A 10228 00005B7F 00 db 0 10229 10230 msg_full_pt: 10231 00005B80 0D0A db 0Dh, 0Ah 10232 00005B82 546865726520697320- db "There is not a free partition table entry ", 0 10232 00005B8B 6E6F74206120667265- 10232 00005B94 652070617274697469- 10232 00005B9D 6F6E207461626C6520- 10232 00005BA6 656E7472792000 10233 msg_to_create_new_p: 10234 00005BAD 746F20637265617465- db "to create a new partition !", 0Dh, 0Ah 10234 00005BB6 2061206E6577207061- 10234 00005BBF 72746974696F6E2021- 10234 00005BC8 0D0A 10235 00005BCA 00 db 0 10236 msg_no_free_space: 10237 00005BCB 0D0A db 0Dh, 0Ah 10238 00005BCD 546865726520697320- db "There is not (enough) free space ", 0 10238 00005BD6 6E6F742028656E6F75- 10238 00005BDF 676829206672656520- 10238 00005BE8 73706163652000 10239 10240 msg_enter_pn_to_del: 10241 00005BEF 0D0A db 0Dh, 0Ah 10242 00005BF1 456E74657220706172- db "Enter partition number to delete: " 10242 00005BFA 746974696F6E206E75- 10242 00005C03 6D62657220746F2064- 10242 00005C0C 656C6574653A20 10243 chr_del_pnum1: 10244 00005C13 00 db 0 10245 00005C14 0D0A00 db 0Dh, 0Ah, 0 10246 10247 msg_delete_partition_q: 10248 00005C17 0D0A db 0Dh, 0Ah 10249 00005C19 5741524E494E472120- db "WARNING! All of data in the selected partition will be lost", 0Dh, 0Ah 10249 00005C22 416C6C206F66206461- 10249 00005C2B 746120696E20746865- 10249 00005C34 2073656C6563746564- 10249 00005C3D 20706172746974696F- 10249 00005C46 6E2077696C6C206265- 10249 00005C4F 206C6F73740D0A 10250 00005C56 202020202020202020- db " after you write changed partition table to disk !!", 0Dh, 0Ah 10250 00005C5F 616674657220796F75- 10250 00005C68 207772697465206368- 10250 00005C71 616E67656420706172- 10250 00005C7A 746974696F6E207461- 10250 00005C83 626C6520746F206469- 10250 00005C8C 736B2021210D0A 10251 00005C93 0D0A db 0Dh, 0Ah 10252 00005C95 446F20796F75207761- db "Do you want to delete PARTITION " 10252 00005C9E 6E7420746F2064656C- 10252 00005CA7 657465205041525449- 10252 00005CB0 54494F4E20 10253 chr_del_pnum2: 10254 00005CB5 30 db '0' 10255 00005CB6 203F2028592F4E2920- db ' ? (Y/N) ', 0 10255 00005CBF 00 10256 10257 _msg_YES: 10258 00005CC0 20 db 20h 10259 msg_YES: 10260 00005CC1 5945532000 db 'YES ', 0 10261 _msg_NO: 10262 00005CC6 20 db 20h 10263 msg_NO: 10264 00005CC7 4E4F2000 db 'NO ', 0 10265 10266 ; 11/02/2019 10267 msg_write_masterboot_sector: 10268 00005CCB 0D0A db 0Dh, 0Ah 10269 00005CCD 577269746520437572- db "Write Current Partition Table:" 10269 00005CD6 72656E742050617274- 10269 00005CDF 6974696F6E20546162- 10269 00005CE8 6C653A 10270 00005CEB 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10271 00005CEF 20312E205772697465- db " 1. Write Partition Table only", 0Dh, 0Ah 10271 00005CF8 20506172746974696F- 10271 00005D01 6E205461626C65206F- 10271 00005D0A 6E6C790D0A 10272 00005D0F 20322E205772697465- db " 2. Write Partition Table and Singlix Master Boot Code", 0Dh, 0Ah 10272 00005D18 20506172746974696F- 10272 00005D21 6E205461626C652061- 10272 00005D2A 6E642053696E676C69- 10272 00005D33 78204D617374657220- 10272 00005D3C 426F6F7420436F6465- 10272 00005D45 0D0A 10273 enter_opt_num_cancel_msg: 10274 00005D47 0D0A db 0Dh, 0Ah 10275 00005D49 456E74657220746865- db "Enter the option number or press ESC to cancel ...", 0 10275 00005D52 206F7074696F6E206E- 10275 00005D5B 756D626572206F7220- 10275 00005D64 707265737320455343- 10275 00005D6D 20746F2063616E6365- 10275 00005D76 6C202E2E2E00 10276 10277 msg_writing_ptable: 10278 00005D7C 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10279 00005D80 57726974696E672070- db "Writing partition table on disk ... ", 0 10279 00005D89 6172746974696F6E20- 10279 00005D92 7461626C65206F6E20- 10279 00005D9B 6469736B202E2E2E20- 10279 00005DA4 00 10280 _msg_OK: 10281 ;db 7 10282 00005DA5 0D0A db 0Dh, 0Ah 10283 00005DA7 4F4B2021 db "OK !" 10284 00005DAB 0D0A00 db 0Dh, 0Ah, 0 10285 10286 option_input: 10287 00005DAE 205B205D00 db ' [ ]', 0 10288 10289 msg_enter_pn_to_act: 10290 00005DB3 0D0A db 0Dh, 0Ah 10291 00005DB5 456E74657220706172- db "Enter partition number to set as active: ", 0 10291 00005DBE 746974696F6E206E75- 10291 00005DC7 6D62657220746F2073- 10291 00005DD0 657420617320616374- 10291 00005DD9 6976653A2000 10292 10293 ; 04/05/2024 10294 ;trdos386_disk_chs_header: 10295 ; db 0Dh, 0Ah 10296 ; db " TRDOS 386 (SINGLIX) HARD DISK IMAGE " 10297 ; db 0 10298 10299 ;disk_chs_header: 10300 ; db 0Dh, 0Ah 10301 ; db " HARD DISK IMAGE " 10302 ; db 0 10303 10304 msg_partition_size_limit: 10305 00005DDF 0D0A db 0Dh, 0Ah 10306 00005DE1 506172746974696F6E- db "Partition size overs available free space !" 10306 00005DEA 2073697A65206F7665- 10306 00005DF3 727320617661696C61- 10306 00005DFC 626C65206672656520- 10306 00005E05 73706163652021 10307 00005E0C 0D0A db 0Dh, 0Ah 10308 00005E0E 4D61782E2061766169- db "Max. available free space is ", 0 10308 00005E17 6C61626C6520667265- 10308 00005E20 652073706163652069- 10308 00005E29 732000 10309 10310 msg_partition_size_limit_r: 10311 00005E2C 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10312 00005E30 28507265737320454E- db "(Press ENTER to use all of available space or press ESC key to retry..) " 10312 00005E39 54455220746F207573- 10312 00005E42 6520616C6C206F6620- 10312 00005E4B 617661696C61626C65- 10312 00005E54 207370616365206F72- 10312 00005E5D 207072657373204553- 10312 00005E66 43206B657920746F20- 10312 00005E6F 72657472792E2E2920 10313 00005E78 000A00 db 0D, 0Ah, 0 10314 10315 msg_cylinders: 10316 00005E7B 2063796C696E646572- db " cylinders", 0 10316 00005E84 7300 10317 msg_sectors: 10318 00005E86 20736563746F727300 db " sectors", 0 10319 10320 ; 02/03/2019 10321 msg_megabytes: 10322 00005E8F 206D65676162797465 db " megabyte" 10323 msg_megabytes_s: 10324 00005E98 0000 db 0, 0 10325 10326 msg_inv_pte: 10327 00005E9A 0D0A db 0Dh, 0Ah 10328 00005E9C 496E76616C69642070- db "Invalid partition table entry ! (P" 10328 00005EA5 6172746974696F6E20- 10328 00005EAE 7461626C6520656E74- 10328 00005EB7 72792021202850 10329 00005EBE 3F290D0A inv_pte_num: db "?)", 0Dh, 0Ah 10330 00005EC2 28507265737320454E- db "(Press ENTER to DELETE or press ESC to EXIT..)" 10330 00005ECB 54455220746F204445- 10330 00005ED4 4C455445206F722070- 10330 00005EDD 726573732045534320- 10330 00005EE6 746F20455849542E2E- 10330 00005EEF 29 10331 00005EF0 0D0A00 db 0Dh, 0Ah, 0 10332 10333 msg_ext_partition_exists: 10334 00005EF3 457874656E64656420- db "Extended partition already exists !" 10334 00005EFC 706172746974696F6E- 10334 00005F05 20616C726561647920- 10334 00005F0E 6578697374732021 10335 00005F16 0D0A00 db 0Dh, 0Ah, 0 10336 10337 msg_defective_pt: 10338 00005F19 0D0A db 0Dh, 0Ah 10339 00005F1B 446566656374697665- db "Defective partition table !", 0 10339 00005F24 20706172746974696F- 10339 00005F2D 6E207461626C652021- 10339 00005F36 00 10340 10341 ; 27/02/2019 10342 msg_ext_part_del_error: 10343 00005F37 0D0A db 0Dh, 0Ah 10344 00005F39 457874656E64656420- db "Extended partition must be deleted after logical drive(s) !" 10344 00005F42 706172746974696F6E- 10344 00005F4B 206D75737420626520- 10344 00005F54 64656C657465642061- 10344 00005F5D 66746572206C6F6769- 10344 00005F66 63616C206472697665- 10344 00005F6F 2873292021 10345 00005F74 0D0A00 db 0Dh, 0Ah, 0 10346 10347 msg_cancel_continue: 10348 00005F77 285072657373204553- db "(Press ESC to cancel or press another key to continue..)" 10348 00005F80 4320746F2063616E63- 10348 00005F89 656C206F7220707265- 10348 00005F92 737320616E6F746865- 10348 00005F9B 72206B657920746F20- 10348 00005FA4 636F6E74696E75652E- 10348 00005FAD 2E29 10349 00005FAF 0D0A00 db 0Dh, 0Ah, 0 10350 10351 msg_delete_ldd: 10352 00005FB2 0D0A db 0Dh, 0Ah 10353 00005FB4 0D0A db 0Dh, 0Ah 10354 00005FB6 44656C657465204C6F- db "Delete Logical (DOS) Drive:" 10354 00005FBF 676963616C2028444F- 10354 00005FC8 53292044726976653A 10355 00005FD1 0D0A db 0Dh, 0Ah 10356 00005FD3 50726573732044454C- db "Press DELETE key to delete logical disk partition " 10356 00005FDC 455445206B65792074- 10356 00005FE5 6F2064656C65746520- 10356 00005FEE 6C6F676963616C2064- 10356 00005FF7 69736B207061727469- 10356 00006000 74696F6E20 10357 00006005 3F2E lddp_num: db "?." 10358 00006007 0D0A00 db 0Dh, 0Ah, 0 10359 10360 msg_delete_ext_part: 10361 0000600A 0D0A db 0Dh, 0Ah 10362 0000600C 0D0A db 0Dh, 0Ah 10363 0000600E 44656C657465204578- db "Delete Extended (DOS) Partition:" 10363 00006017 74656E646564202844- 10363 00006020 4F5329205061727469- 10363 00006029 74696F6E3A 10364 0000602E 0D0A db 0Dh, 0Ah 10365 00006030 507265737320454E54- db "Press ENTER to delete or press ESC to cancel.." 10365 00006039 455220746F2064656C- 10365 00006042 657465206F72207072- 10365 0000604B 657373204553432074- 10365 00006054 6F2063616E63656C2E- 10365 0000605D 2E 10366 0000605E 0D0A00 db 0Dh, 0Ah, 0 10367 10368 str_display_ebr_pt: 10369 00006061 285072657373205350- db "(Press SPACE to edit EXTENDED Partition Table)", 0Dh, 0Ah, 0 10369 0000606A 41434520746F206564- 10369 00006073 697420455854454E44- 10369 0000607C 454420506172746974- 10369 00006085 696F6E205461626C65- 10369 0000608E 290D0A00 10370 10371 ebr_editing_options: 10372 00006092 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10373 00006096 457874656E64656420- db "Extended Partition Table Editing Options:" 10373 0000609F 506172746974696F6E- 10373 000060A8 205461626C65204564- 10373 000060B1 6974696E67204F7074- 10373 000060BA 696F6E733A 10374 000060BF 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 10375 000060C3 20202020202020312E- db " 1. Create Logical DOS Drive", 0Dh, 0Ah 10375 000060CC 20437265617465204C- 10375 000060D5 6F676963616C20444F- 10375 000060DE 532044726976650D0A 10376 000060E7 20202020202020322E- db " 2. Delete Logical (DOS) Drive(s)",0Dh, 0Ah, 0 10376 000060F0 2044656C657465204C- 10376 000060F9 6F676963616C202844- 10376 00006102 4F5329204472697665- 10376 0000610B 2873290D0A00 10377 10378 msg_delete_ldd_q: 10379 00006111 0D0A db 0Dh, 0Ah 10380 00006113 5741524E494E47210D- db "WARNING!", 0Dh, 0Ah 10380 0000611C 0A 10381 0000611D 416C6C206F66206461- db "All of data in logical (DOS) drive(s) will be lost !!", 0Dh, 0Ah 10381 00006126 746120696E206C6F67- 10381 0000612F 6963616C2028444F53- 10381 00006138 292064726976652873- 10381 00006141 292077696C6C206265- 10381 0000614A 206C6F73742021210D- 10381 00006153 0A 10382 00006154 0D0A db 0Dh, 0Ah 10383 00006156 446F20796F75207761- db "Do you want to continue ? (Y/N) ", 0 10383 0000615F 6E7420746F20636F6E- 10383 00006168 74696E7565203F2028- 10383 00006171 592F4E292000 10384 10385 msg_create_ldd_max_error: 10386 00006177 0D0A db 0Dh, 0Ah 10387 00006179 50726F6772616D206C- db "Program limit for logical dos drive count is 4 !" 10387 00006182 696D697420666F7220- 10387 0000618B 6C6F676963616C2064- 10387 00006194 6F7320647269766520- 10387 0000619D 636F756E7420697320- 10387 000061A6 342021 10388 000061A9 0D0A00 db 0Dh, 0Ah, 0 10389 10390 msg_c_ldd_unused_warning: 10391 000061AC 0D0A db 0Dh, 0Ah 10392 000061AE 546865726520697320- db "There is unused extended partition space after logical dos drive " 10392 000061B7 756E75736564206578- 10392 000061C0 74656E646564207061- 10392 000061C9 72746974696F6E2073- 10392 000061D2 706163652061667465- 10392 000061DB 72206C6F676963616C- 10392 000061E4 20646F732064726976- 10392 000061ED 6520 10393 char_lddn: 10394 000061EF 342021 db "4 !" 10395 000061F2 0D0A db 0Dh, 0Ah 10396 000061F4 285072657373204553- db "(Press ESC to add unused space or press ENTER to continue.)" 10396 000061FD 4320746F2061646420- 10396 00006206 756E75736564207370- 10396 0000620F 616365206F72207072- 10396 00006218 65737320454E544552- 10396 00006221 20746F20636F6E7469- 10396 0000622A 6E75652E29 10397 0000622F 0D0A00 db 0Dh, 0Ah, 0 10398 10399 msg_create_ldd_s: 10400 00006232 53656C65637420616E- db "Select an option to set logical dos drive size: " 10400 0000623B 206F7074696F6E2074- 10400 00006244 6F20736574206C6F67- 10400 0000624D 6963616C20646F7320- 10400 00006256 64726976652073697A- 10400 0000625F 653A20 10401 00006262 0D0A db 0Dh, 0Ah 10402 00006264 0D0A db 0Dh, 0Ah 10403 00006266 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 10403 0000626F 6E64657220636F756E- 10403 00006278 740D0A 10404 0000627B 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 10404 00006284 6D652070657263656E- 10404 0000628D 746167652028232325- 10404 00006296 290D0A 10405 00006299 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 10405 000062A2 20627974657320284D- 10405 000062AB 422C20322A31303234- 10405 000062B4 2A4D20736563746F72- 10405 000062BD 73290D0A 10406 000062C1 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 10406 000062CA 206279746573202847- 10406 000062D3 422C20322A31303234- 10406 000062DC 2A313032342A472073- 10406 000062E5 6563746F7273290D0A 10407 000062EE 0D0A db 0Dh, 0Ah 10408 000062F0 507265737320535041- db "Press SPACE to use entire space or press ENTER to set Megabytes .. ", 0 10408 000062F9 434520746F20757365- 10408 00006302 20656E746972652073- 10408 0000630B 70616365206F722070- 10408 00006314 7265737320454E5445- 10408 0000631D 5220746F2073657420- 10408 00006326 4D6567616279746573- 10408 0000632F 202E2E2000 10409 10410 msg_c_part_error: 10411 00006334 0D0A db 0Dh, 0Ah 10412 ;db "No free space for a new primary partition", 0Dh, 0Ah, 0 10413 ; 21/03/2021 10414 00006336 4E6F20667265652073- db "No free space for a new primary partition !", 0Dh, 0Ah, 0 10414 0000633F 7061636520666F7220- 10414 00006348 61206E657720707269- 10414 00006351 6D6172792070617274- 10414 0000635A 6974696F6E20210D0A- 10414 00006363 00 10415 ; 21/03/2021 10416 ;msg_c_ldd_error: 10417 ; db "and logical dos drives over program limit (4) !", 0Dh, 0Ah, 0 10418 msg_c_ldd_q: 10419 00006364 0D0A db 0Dh, 0Ah 10420 00006366 446F20796F75207761- db "Do you want to create logical dos drive in extended dos partition " 10420 0000636F 6E7420746F20637265- 10420 00006378 617465206C6F676963- 10420 00006381 616C20646F73206472- 10420 0000638A 69766520696E206578- 10420 00006393 74656E64656420646F- 10420 0000639C 732070617274697469- 10420 000063A5 6F6E20 10421 000063A8 3F2028592F4E2900 db '? (Y/N)', 0 10422 10423 msg_c_ldd_nofspc_error: 10424 000063B0 0D0A db 0Dh, 0Ah 10425 000063B2 4E6F20667265652073- db "No free space for a new logical dos drive !", 0Dh, 0Ah, 0 10425 000063BB 7061636520666F7220- 10425 000063C4 61206E6577206C6F67- 10425 000063CD 6963616C20646F7320- 10425 000063D6 647269766520210D0A- 10425 000063DF 00 10426 10427 ; 12/10/2020 10428 msg_drv_not_ready: 10429 000063E0 0D0A db 0Dh, 0Ah 10430 000063E2 4469736B2064726976- db "Disk drive not ready or read error ! " 10430 000063EB 65206E6F7420726561- 10430 000063F4 6479206F7220726561- 10430 000063FD 64206572726F722021- 10430 00006406 20 10431 00006407 0D0A00 db 0Dh, 0Ah, 0 10432 10433 msg_not_any_disks: 10434 0000640A 0D0A db 0Dh, 0Ah 10435 0000640C 546865726520697320- db "There is not a hard disk (ready) ! " 10435 00006415 6E6F74206120686172- 10435 0000641E 64206469736B202872- 10435 00006427 6561647929202120 10436 0000642F 0D0A00 db 0Dh, 0Ah, 0 10437 10438 00006432 90 align 4 10439 10440 msg_sectors_crlf: 10441 00006434 20736563746F72 db " sector" 10442 msg_sectors_crlf_s: 10443 0000643B 73 db "s" 10444 0000643C 0D0A00 db 0Dh, 0Ah, 0 10445 10446 vname_length: 10447 0000643F 00 db 0 ; 05/01/2018 10448 10449 bs_oem_name: 10450 ;db 'TRDOS2.0', 0 10451 ; 04/05/2024 10452 00006440 524554524F444F5300 db 'RETRODOS', 0 10453 00006449 90 align 2 10454 10455 no_name: 10456 0000644A 4E4F204E414D452020- db 'NO NAME ', 0 10456 00006453 202000 10457 10458 align 2 10459 10460 FDFORMAT_SECBUFFER: 10461 HDFORMAT_SECBUFFER: 10462 00006456 F6 times 512 db 0F6h 10463 HDFORMAT_FSINFO_BUFF: 10464 00006656 52526141 dd 41615252h ; FSI_LeadSig 10465 0000665A 00 times 480 db 0 ; FSI_Reserved1 10466 0000683A 72724161 dd 61417272h ; FSI_StrucSig 10467 0000683E FFFFFFFF dd 0FFFFFFFFh ; FSI_Free_Count 10468 00006842 02000000 dd 000000002h ; FSI_Nxt_Free 10469 00006846 00 times 12 db 0 ; FSI_Reserved2 10470 00006852 000055AA dd 0AA550000h ; FSI_TrailSig 10471 10472 ; 29/10/2020 10473 msg_100: 10474 00006856 31303000 db '100', 0 10475 10476 SizeOfFile equ $-100 10477 10478 ; 03/02/2019 10479 10480 ;============================================================================= 10481 ; uninitialized data 10482 ;============================================================================= 10483 10484 bss_start: 10485 10486 ABSOLUTE bss_start 10487 10488 ; 12/10/2020 10489 0000685A ?? DrvNum: resb 1 10490 0000685B ?? hdc: resb 1 10491 ;hs: resw 1 ; (bios/dos virtual) head*sectors ; 16/10/2020 10492 0000685C ?? rw: resb 1 10493 0000685D ?? rcnt: resb 1 ; 18/10/2020 10494 total_sectors: 10495 0000685E ???????? disksize: resd 1 10496 00006862 ???????? chs_limit: resd 1 10497 10498 ; 16/10/2020 10499 ;lba_cyls: resd 1 ; cylinder count calculated from LBA sectors 10500 00006866 ???? lba_chs_remain: resw 1 ; remain sectors after the last cylinder 10501 10502 alignb 2 10503 00006868 ???? old_sp: resw 1 10504 10505 HDFORMAT_FATBUFFER: 10506 HDFORMAT_EMPTY_BUFF: 10507 0000686A resb 512 10508 10509 00006A6A ???????? data_start: resd 1 10510 00006A6E ???????? data_sectors: resd 1 10511 00006A72 ???????? cluster_count: resd 1 10512 00006A76 ???? root_dir_secs: resw 1 10513 00006A78 ???? format_percent: resw 1 10514 00006A7A ?? prev_percent: resb 1 10515 00006A7B ?? rsvdbyte: resb 1 10516 10517 alignb 4 10518 10519 ; 05/01/2018 10520 00006A7C fs_volume_name: resb 64 10521 00006ABC ???????? fs_volume_serial: resd 1 10522 00006AC0 ???? DAT_FFBit: resw 1 10523 00006AC2 ???? DAT_FFSector: resw 1 10524 00006AC4 ???? resw 1 ; 19/03/2021 10525 00006AC6 ???? DAT_LFBit: resw 1 10526 00006AC8 ???? DAT_LFSector: resw 1 10527 00006ACA ???? resw 1 ; 19/03/2021 10528 10529 ;alignb 4 10530 10531 FS_MAT_Buffer: ; TRFS1 Master Allocation Table (05/01/2018) 10532 00006ACC ?????? MAT_Sign: resb 3 ; Offset 0 ; 'MAT' 10533 00006ACF ?? MAT_Version: resb 1 ; 3 ; 0 10534 00006AD0 ???????? MAT_VolumeSize: resd 1 ; 4 ; FS1 Volume Size 10535 00006AD4 ???????? MAT_BeginSector: resd 1 ; 8 ; FS1 Start Sector 10536 00006AD8 ???????? DAT_Address: resd 1 ; 12 ; Offset (=2) 10537 00006ADC ???????? DAT_SectorCount: resd 1 ; 16 10538 00006AE0 ???????? MAT_FreeSectors: resd 1 ; 20 10539 00006AE4 ???????? MAT_FirstFreeSector: resd 1 ; 24 10540 ;MAT_OS_Reserved: 10541 ; resb 9 10542 ;MAT_Unused: 10543 ; resb 112 10544 FS_DAT_Buffer: ; TRFS1 Disk Allocation Table (05/01/2018) 10545 FS_RDT_Buffer: ; TRFS1 Root Directory Description Table (05/01/2018) 10546 00006AE8 resb 512 10547 ;alignb 4 10548 10549 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 10550 10551 ;total_sectors: resd 1 10552 00006CE8 ???????? pType: resb 4 10553 00006CEC ???????? file_size: resd 1 10554 00006CF0 ???????? pp_StartSector: resd 1 10555 00006CF4 ???????? pp_Sectors: resd 1 10556 00006CF8 ?? wholedisk: resb 1 10557 00006CF9 ?? pp_type: resb 1 ; Primary partition type (for this program) 10558 00006CFA ?? pp_type_user: resb 1 10559 00006CFB ?? chs_focus: resb 1 10560 00006CFC ???????? pSize_temp: resd 1 10561 00006D00 ???????? pSize_multiplier: resd 1 10562 00006D04 ?? pSize_maxdigits: resb 1 10563 00006D05 ?? pSize_digitpos: resb 1 10564 msg_psize_unit: 10565 00006D06 ???? pSize_unit: resw 1 10566 00006D08 ?? resb 1 10567 ; 06/11/2020 10568 ;reserved_bytes: resb 3 ; for 11 bytes of numbers 10569 msg_partition_sectors: 10570 ;resb 8 10571 00006D09 resb 11 ; 06/11/2020 10572 00006D14 ?? resb 1 10573 00006D15 ?? format_q: resb 1 ; 03/02/2018 10574 10575 ;alignb 2 10576 00006D16 ?? pType_pos: resb 1 10577 00006D17 ?? pType_num: resb 1 10578 00006D18 ?? resb 1 10579 ;cylinder_boundary: 10580 00006D19 ?? resb 1 10581 ; 05/11/2020 10582 10583 alignb 2 10584 10585 00006D1A ?? GetChar: resb 1 ; 11/02/2019 10586 00006D1B ?? existingfile: resb 1 ; 12/02/2019 10587 10588 hs: ; 17/10/2020 ; (bios/dos virtual) head*sectors 10589 00006D1C ???? min_sectors: resw 1 ; 08/02/2019 10590 00006D1E ???? pp_StartCylinder: resw 1 10591 00006D20 ???? pp_EndCylinder: resw 1 10592 10593 00006D22 ???????? ppn_Sectors: resd 1 ; 09/02/2019 10594 10595 00006D26 ???? input_col: resw 1 10596 00006D28 ?? No: resb 1 10597 00006D29 ?? Yes: resb 1 10598 10599 ; 26/02/2019 10600 00006D2A ?? ldrives: resb 1 10601 10602 ;sort_1: resb 1 10603 00006D2B ?? resb 1 ; 23/10/2020 10604 00006D2C ???????? sort: resb 4 10605 10606 ;max_sector: resb 8 10607 ebr_buffer: ; 26/02/2019 10608 00006D30 boot_record: resb 512 10609 10610 00006F30 ?? valid_input: resb 1 10611 00006F31 ?? resb 1 10612 10613 ; 26/02/2019 10614 00006F32 ???????? ep_StartSector: resd 1 10615 00006F36 ???????? ep_EndSector: resd 1 10616 00006F3A ???????? ep_Size: resd 1 10617 10618 ; 10/02/2019 10619 00006F3E ???????? valid_ppnums: resb 4 10620 10621 00006F42 ???? _i_: resw 1 10622 10623 00006F44 ???? freespace_count: resw 1 10624 00006F46 ?? last_found_partition: resb 1 10625 00006F47 ?? p_type: resb 1 10626 10627 ; 30/10/2020 10628 ;p_sorted: 10629 ; resb 1 10630 ;ep_sorted: 10631 ; resb 1 10632 10633 00006F48 ?? _e_: resb 1 10634 10635 act_part_num: 10636 cre_part_num: 10637 00006F49 ?? del_part_num: resb 1 ; 10/02/2019 10638 10639 alignb 2 10640 10641 00006F4A pte_row: resb 80 10642 10643 00006F9A ?? _zero_: resb 1 10644 10645 ;alignb 2 10646 10647 00006F9B ?? resb 1 10648 10649 bss_clear_end: ; 15/02/2019 10650 10651 ; PARTITION DATA STRUCTURE 10652 ; 4 partitions 10653 ; 18 byte partition data structure per partition 10654 ; 72 bytes (4*18) 10655 10656 00006F9C ?? part_table_boot_ind: resb 1 10657 00006F9D ?? part_table_start_head: resb 1 10658 00006F9E ?? part_table_start_sector: resb 1 10659 00006F9F ???? part_table_start_cyl: resw 1 10660 00006FA1 ?? part_table_sys_id: resb 1 10661 00006FA2 ?? part_table_end_head: resb 1 10662 00006FA3 ?? part_table_end_sector: resb 1 10663 00006FA4 ???? part_table_end_cyl: resw 1 10664 00006FA6 ???? part_table_rel_sec_lw: resw 1 10665 00006FA8 ???? part_table_rel_sec_hw: resw 1 10666 00006FAA ???? part_table_num_sec_lw: resw 1 10667 00006FAC ???? part_table_num_sec_hw: resw 1 10668 10669 00006FAE resb 54 ; 3*18 bytes 10670 10671 00006FE4 ?? pcount: resb 1 10672 00006FE5 ?? ppcount: resb 1 10673 00006FE6 ?? apcount: resb 1 10674 00006FE7 ?? epnumber: resb 1 10675 10676 ; LOGICAL PARTITION DATA STRUCTURE 10677 ; (for logical partitions in extended partition) 10678 10679 ; 1 extended partition 10680 ; 4 logical drives (18 bytes) 10681 ; 72 bytes (4*18) 10682 10683 00006FE8 ?? ext_table_boot_ind: resb 1 10684 00006FE9 ?? ext_table_start_head: resb 1 10685 00006FEA ?? ext_table_start_sector: resb 1 10686 00006FEB ???? ext_table_start_cyl: resw 1 10687 00006FED ?? ext_table_sys_id: resb 1 10688 00006FEE ?? ext_table_end_head: resb 1 10689 00006FEF ?? ext_table_end_sector: resb 1 10690 00006FF0 ???? ext_table_end_cyl: resw 1 10691 00006FF2 ???? ext_table_rel_sec_lw: resw 1 10692 00006FF4 ???? ext_table_rel_sec_hw: resw 1 10693 00006FF6 ???? ext_table_num_sec_lw: resw 1 10694 00006FF8 ???? ext_table_num_sec_hw: resw 1 10695 10696 00006FFA resb 54 ; 3*18 bytes 10697 10698 fspc: ; 5*8 words (for free space calculations) 10699 10700 ; Space 1 - unused cylinders before partition 0 10701 ; Space 2 - unused cylinders between partition 0 & 1 10702 ; Space 3 - unused cylinders between partition 1 & 2 10703 ; Space 4 - unused cylinders between partition 2 & 3 10704 ; Space 5 - unused cylinders after partition 3 10705 10706 00007030 ???? free_space.space: resw 1 10707 00007032 ???? free_space.start: resw 1 10708 00007034 ???? free_space.end: resw 1 10709 00007036 ???? free_space.percent_unused: resw 1 10710 00007038 ???????? free_space.sectors_unused: resd 1 10711 0000703C ???????? free_space.startsector: resd 1 ; 13/02/2019 10712 ;resw 4*6 10713 00007040 resw 4*8 ; 4*16 bytes ; 13/02/2019 10714 10715 ; 18/02/2019 10716 00007080 ???? c_cylinder: resw 1 10717 00007082 ???? c_fspc_offset: resw 1 10718 00007084 ?? cylinder_boundary: resb 1 10719 ;c_gap: resb 1 10720 00007085 ?? resb 1 10721 10722 ; 27/02/2019 10723 00007086 ldd_start: resd 4 10724 ; 03/03/2019 10725 00007096 ldd_size: resd 4 10726 ; 30/10/2020 10727 000070A6 ???????? ep_free_sectors: resd 1 10728 10729 ; 25/02/2019 10730 000070AA ???? pte_address: resw 1 10731 ; 02/03/2019 10732 000070AC ???? lcylinders: resw 1 10733 ; 01/11/2020 10734 000070AE ???? endcyl: resw 1 10735 10736 ;bss_clear_end: ; 18/02/2019 10737 10738 ; 11/10/2020 10739 ;gdp_buffer: resb 30 ; buffer for int 13h, ah = 48h 10740 000070B0 gdp_buffer: resb 26 ; buffer for int 13h, ah = 48h 10741 ; 19/03/2021 10742 000070CA ???? tempword: resw 1 10743 10744 bss_end: