1 ; **************************************************************************** 2 ; RD5HDIMG.S (RD5HDIMG.COM) - Retro DOS v5 Hard Disk Image Formatting Utility 3 ; (for MSDOS/WINDOWS) 4 ; **************************************************************************** 5 ; Last Update: 29/01/2026 6 ; ---------------------------------------------------------------------------- 7 ; Beginning: 03/12/2017 8 ; ---------------------------------------------------------------------------- 9 ; Assembler: NASM version 2.15 10 ; ---------------------------------------------------------------------------- 11 ; Modified from 'hdimage.s'(HDIMAGE.COM) source code by Erdogan Tan 12 ; (03/05/2024) - TRDOS 386 v2 hard disk image formatting utility - 13 ; **************************************************************************** 14 ; nasm hdimage.s -l hdimage.txt -o HDIMAGE.COM 15 16 ; DTA (PSP+80h= Offset 128) 17 DTA_Attrib equ 149 ; PDP+21 18 DTA_Time equ 150 ; PSP+22 19 DTA_Date equ 152 ; PSP 24 20 DTA_FileSize equ 154 ; PSP + 26 21 DTA_FileName equ 158 ; PSP + 30 22 23 ; Masterboot / Partition Table at Beginning+1BEh 24 ptBootable equ 0 25 ptBeginHead equ 1 26 ptBeginSector equ 2 27 ptBeginCylinder equ 3 28 ptFileSystemID equ 4 29 ptEndHead equ 5 30 ptEndSector equ 6 31 ptEndCylinder equ 7 32 ptStartSector equ 8 33 ptSectors equ 12 34 35 ; BIOS Disk Parameters 36 DPDiskNumber equ 0h 37 DPDType equ 1h 38 DPReturn equ 2h 39 DPHeads equ 3h 40 DPCylinders equ 4h 41 DPSecPerTrack equ 6h 42 DPDisks equ 7h 43 DPTableOff equ 8h 44 DPTableSeg equ 0Ah 45 DPNumOfSecs equ 0Ch 46 47 ; BIOS INT 13h Extensions (LBA extensions) 48 ; Just After DP Data (DPDiskNumber+) 49 DAP_PacketSize equ 10h ; If extensions present, this byte will be >=10h 50 DAP_Reserved1 equ 11h ; Reserved Byte 51 DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127 52 DAP_Reserved2 equ 13h ; Reserved Byte 53 DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET 54 DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1 55 ; C1= Selected Cylinder Number 56 ; H0= Number Of Heads (Maximum Head Number + 1) 57 ; H1= Selected Head Number 58 ; S0= Maximum Sector Number 59 ; S1= Selected Sector Number 60 ; QUAD WORD 61 ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh 62 ; QUAD WORD (Also, value in 0h must be 18h) 63 ; TR-DOS will not use 64 bit Flat Address 64 65 ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters" 66 ; Just After DP Data (DPDiskNumber+) 67 GetDParams_48h equ 20h ; Word. Data Lenght, must be 26 (1Ah) for short data. 68 GDP_48h_InfoFlag equ 22h ; Word 69 ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid. 70 GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders. 71 GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads. 72 GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track. 73 GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors. 74 GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector. 75 76 ; Cursor Location 77 CCCpointer equ 0450h ; BIOS data, current cursor column 78 79 ; MINIMUM & MAXIMUM SECTORS (partition and disk size limits in sectors) 80 MINPARTSIZE equ 4096 ; 2MB 81 MAXPARTSIZE equ 4128768 - 1 ; 2GB - masterboot sector 82 MINDISKSIZE equ 16384 ; 8MB 83 MAXDISKSIZE equ 4128768 ; 2GB 84 85 pTableOffset equ 1BEh ; 446 86 87 ; Convert LBA to CHS 88 ; 08/02/2019 89 90 ; LBA = ((C1*H0+H1)*S0)+S1-1 91 ; 92 ; C1 = Selected Cylinder Number 93 ; H0 = Number of Heads (Maximum Head Number + 1) 94 ; H1 = Selected Head Number 95 ; S0 = Maximum Sector Number 96 ; S1 = Selected Sector Number 97 ; 98 ; Phoenix, Enchanced Disk Drive Specicifications, v1.1, Page 8) 99 100 [BITS 16] 101 [ORG 100h] 102 103 ;cli 104 ;cld 105 ;push cs 106 ;pop ss 107 ;mov sp, 0FFFEh 108 ;sti 109 110 ;mov bx, SizeOfFile+100 111 112 00000000 BB[6C72] mov bx, bss_end 113 114 00000003 83C30F add bx, 15 115 00000006 D1EB shr bx, 1 116 00000008 D1EB shr bx, 1 117 0000000A D1EB shr bx, 1 118 0000000C D1EB shr bx, 1 119 0000000E B44A mov ah, 4Ah ; modify memory allocation 120 ;push cs 121 ;pop es 122 00000010 CD21 int 21h 123 124 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 125 ; clear BSS 126 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 127 ; 03/02/2019 128 129 ;mov cx, bss_end 130 00000012 B9[5E71] mov cx, bss_clear_end ; 15/02/2019 131 132 00000015 BF[226A] mov di, bss_start 133 00000018 29F9 sub cx, di 134 0000001A 41 inc cx 135 0000001B D1E9 shr cx, 1 136 0000001D 31C0 xor ax, ax 137 0000001F F3AB rep stosw 138 139 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 140 ; get hd image file name 141 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 142 143 00000021 BE8000 mov si, 80h ; PSP command tail 144 00000024 AC lodsb 145 00000025 08C0 or al, al ; command tail length 146 00000027 0F845B07 jz B_01 ; jump if zero 147 A_01: 148 0000002B AC lodsb 149 0000002C 3C20 cmp al, ' ' ; is it SPACE ? 150 0000002E 74FB je short A_01 151 00000030 0F825207 jb B_01 152 153 ; check hd image file name 154 A_02: 155 00000034 BF[9959] mov di, img_file_name 156 00000037 AA stosb 157 A_03: 158 00000038 AC lodsb 159 ;cmp al, 0Dh ; ENTER (CR) key 160 00000039 3C20 cmp al, 20h ; ' ' 161 0000003B 760C jna short A_04 162 0000003D AA stosb 163 0000003E 81FF[A559] cmp di, img_file_name + 12 164 00000042 72F4 jb short A_03 165 00000044 803C20 cmp byte [si], 20h 166 00000047 773F ja short A_10 167 A_04: 168 ;sub al, al 169 ;stosb 170 171 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 172 ; File name capitalization 173 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 174 175 00000049 BE[9959] mov si, img_file_name 176 0000004C 89F7 mov di, si 177 0000004E 89F3 mov bx, si 178 A_05: 179 00000050 AC lodsb 180 00000051 3C61 cmp al, 'a' 181 00000053 730D jnb short A_07 182 00000055 20C0 and al, al 183 00000057 7412 jz short A_08 184 00000059 3C2E cmp al, '.' 185 0000005B 7502 jne short A_06 186 0000005D 89FB mov bx, di ; dot position 187 A_06: 188 0000005F AA stosb 189 00000060 EBEE jmp short A_05 190 A_07: 191 00000062 3C7A cmp al, 'z' 192 00000064 77F9 ja short A_06 193 00000066 24DF and al, 0DFh ; NOT 32 194 00000068 AA stosb 195 00000069 EBE5 jmp short A_05 196 A_08: 197 0000006B 8805 mov [di], al 198 0000006D 4F dec di 199 0000006E 39FB cmp bx, di 200 00000070 7316 jnb short A_10 201 00000072 29DF sub di, bx 202 00000074 81EB[9959] sub bx, img_file_name 203 00000078 83FF03 cmp di, 3 204 0000007B 7606 jna short A_09 205 0000007D 21DB and bx, bx 206 0000007F 7507 jnz short A_10 207 00000081 EB0E jmp short A_11 208 A_09: 209 00000083 83FB08 cmp bx, 8 210 00000086 7609 jna short A_11 211 A_10: 212 00000088 BE[2A45] mov si, msg_inv_file_name 213 0000008B E8BB1D call print_msg 214 0000008E E9FB06 jmp B_02 215 216 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 217 ; Find image file 218 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 219 220 A_11: 221 00000091 BA[9959] mov dx, img_file_name 222 00000094 B93F00 mov cx, 3Fh ; File Attributes 223 00000097 B44E mov ah, 4Eh ; MS-DOS Function = Find First File 224 00000099 CD21 int 21h 225 ;jc B_05 226 0000009B 0F82F20A jc new_image ; 07/03/2019 227 228 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 229 ; Check image file features 230 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 231 232 A_12: 233 0000009F BE9500 mov si, DTA_Attrib 234 000000A2 8A04 mov al, [si] 235 000000A4 241F and al, 1Fh ; directory, volume label, system, hidden, read only 236 000000A6 0F85ED06 jnz B_04 237 000000AA BE9A00 mov si, DTA_FileSize 238 000000AD AD lodsw 239 ; max. size of hard disk image = 63sectors*64heads*1024cylinders 240 000000AE 8B14 mov dx, [si] 241 000000B0 81FA007E cmp dx, 7E00h ; 2GB upper limit (7E000000h) 242 000000B4 0F87DF06 ja B_04 243 000000B8 7208 jb short A_13 244 000000BA 21C0 and ax, ax 245 000000BC 0F85D706 jnz B_04 246 ; 20/09/2020 247 ;mov ax, 1024 248 ;jmp A_24 249 000000C0 EB0E jmp short A_14 250 A_13: 251 000000C2 A9FF01 test ax, 511 ; check file size for sector boundary 252 000000C5 0F85CE06 jnz B_04 253 000000C9 83FA7E cmp dx, 7Eh ; 8MB lower limit (7E0000h) 254 000000CC 0F82C706 jb B_04 255 A_14: 256 000000D0 A3[A86E] mov [file_size], ax 257 000000D3 8916[AA6E] mov [file_size+2], dx 258 259 ; convert (disk image) file size to sector count (disk size) 260 ; (dx:ax)/512 261 262 000000D7 B90002 mov cx, 512 263 000000DA E8590D call div32 264 265 ; 12/02/2019 266 000000DD A3[A06E] mov [total_sectors], ax 267 000000E0 8916[A26E] mov [total_sectors+2], dx 268 269 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 270 ; Load masterboot sector of HD image file 271 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 272 273 000000E4 BA[9959] mov dx, img_file_name 274 000000E7 B8023D mov ax, 3D02h ; open for reading and writing 275 000000EA CD21 int 21h 276 000000EC 0F82431D jc D_02 277 278 ;mov [img_file_handle], ax 279 000000F0 89C3 mov bx, ax 280 281 000000F2 B43F mov ah, 3Fh ; read file 282 000000F4 B90002 mov cx, 512 283 000000F7 BA[4057] mov dx, MasterBootBuff 284 000000FA CD21 int 21h 285 000000FC 9C pushf 286 000000FD 50 push ax 287 000000FE B43E mov ah, 3Eh ; close file 288 ;mov bx, [img_file_handle] 289 00000100 CD21 int 21h 290 00000102 58 pop ax 291 00000103 9D popf 292 00000104 0F822B1D jc D_02 293 294 ; 11/02/2019 295 ;mov word [img_file_handle], 0 ; disk image file is not open 296 297 ; 12/02/2019 298 299 00000108 813E[3E59]55AA cmp word [MBIDCode], 0AA55h 300 0000010E 0F858506 jne B_04 ; invalid disk image file ! 301 302 ; clear screen 303 00000112 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 304 00000115 CD10 int 10h 305 306 00000117 C606[D96E]01 mov byte [existingfile], 1 ; we are using existing disk image file 307 ; (not a new file) flag 308 309 ; Check for Singlix Master Boot code 310 0000011C 813E[FC58]BE07 cmp word [MasterBootBuff+444], 7BEh 311 00000122 7540 jne short A_15 ; no .. 312 313 ; It is seen as singlix MBR 314 ; Let's check for disk size words (CHS record) 315 00000124 8B0E[E458] mov cx, [MasterBootBuff+420] ; cylinders 316 00000128 83F910 cmp cx, 16 317 0000012B 7237 jb short A_15 ; invalid 318 0000012D A1[E658] mov ax, [MasterBootBuff+422] ; heads 319 00000130 83F802 cmp ax, 2 320 00000133 722F jb short A_15 ; invalid 321 00000135 8B16[E858] mov dx, [MasterBootBuff+424] ; sectors 322 00000139 83FA11 cmp dx, 17 323 0000013C 7226 jb short A_15 ; invalid 324 0000013E 890E[AE40] mov [cylinders], cx 325 00000142 A3[AC40] mov [heads], ax 326 00000145 8916[AA40] mov [sectors], dx 327 00000149 F7E2 mul dx 328 0000014B E8F60C call mul32 329 0000014E 09DB or bx, bx 330 00000150 7512 jnz short A_15 ; invalid 331 00000152 3B16[A26E] cmp dx, [total_sectors+2] 332 00000156 750C jne short A_15 333 00000158 3B06[A06E] cmp ax, [total_sectors] 334 0000015C 7506 jne short A_15 ; invalid 335 336 ; valid singlix MBR & disk image file 337 338 ; Display disk geometry 339 340 ;mov si, trdos386_disk_chs_header 341 ; 04/05/2024 342 0000015E BE[295F] mov si, retrodos5_disk_chs_header 343 ;call print_msg 344 ; 345 ;jmp A_27 346 ; 20/09/2020 347 00000161 E9D300 jmp A_24 348 349 A_15: 350 ; 17/10/2020 351 ;mov ax, [file_size] 352 ;mov dx, [file_size+2] 353 354 ;shr dx, 1 355 ;rcr ax, 1 ; / 2 356 ; / 256 357 ;mov al, ah 358 ;mov ah, dl 359 ;mov dl, dh 360 ;xor dh, dh 361 362 ; mov cl, 9 ; / 512 363 ;A_15shr32: 364 ; shr dx,1 365 ; rcr ax,1 366 ; dec cl 367 ; jnz short A_15shr32 368 369 ; 17/10/2020 370 00000164 A1[A06E] mov ax, [total_sectors] 371 00000167 8B16[A26E] mov dx, [total_sectors+2] 372 373 ; cylinders*63sectors*16heads (<=528MB) 374 ;cmp dx, 1F80h ; 1024*16*63 (1F800000h) 375 0000016B 83FA0F cmp dx, 0Fh ; 17/10/2020 376 0000016E 7774 ja short A_21 377 00000170 7213 jb short A_16 378 ;and ax, ax 379 ;jnz A_22 380 00000172 3D00C0 cmp ax, 0C000h ; 17/10/2020 381 00000175 0F878200 ja A_22 382 ; = 528MB (1024*16*63*512) 383 00000179 C706[AC40]1000 mov word [heads], 16 384 0000017F B80004 mov ax, 1024 385 00000182 E99C00 jmp A_25 386 A_16: 387 ; < 528MB 388 00000185 B9F003 mov cx, 63*16 ; 1008 389 ;div cx 390 ;and dx, dx 391 00000188 E8AB0C call div32 ; 16/10/2020 392 0000018B 21DB and bx, bx ; remainder 393 ;jnz B_04 394 ; 10/02/2019 395 0000018D 7509 jnz short A_17 ; 17 spt disk image check 396 0000018F C706[AC40]1000 mov word [heads], 16 397 00000195 E98900 jmp A_25 398 A_17: 399 ; 12/02/2019 400 ;mov ax, [file_size] 401 ;mov dx, [file_size+2] 402 403 ; 17/10/2020 404 00000198 A1[A06E] mov ax, [total_sectors] 405 0000019B 8B16[A26E] mov dx, [total_sectors+2] 406 407 ;; 10/02/2019 408 ;; Check 17 spt disk image 409 ;mov si, DTA_FileSize 410 ;lodsw 411 ;; max. size of hard disk image = 17sectors*16heads*1024cylinders 412 ;mov dx, [si] 413 414 ;cmp dx, 880h ; 136MB upper limit (8800000h) 415 0000019F 83FA04 cmp dx, 04h ;17/10/2020 416 000001A2 0F87F105 ja B_04 417 000001A6 7207 jb short A_49 418 419 000001A8 3D0040 cmp ax, 4000h ; 17/10/2020 420 000001AB 0F87E805 ja B_04 421 A_49: 422 ; 17/10/2020 423 ;mov cx, 512 424 ;call div32 425 426 ;mov [pp_Sectors], ax 427 ;mov [pp_Sectors+2], dx 428 429 ; Calculate with increased heads (count) order 430 ; (For example cyls = 1024 & heads = 8 is better than 431 ; cyls = 512 & heads = 16, for 17 SPT.v) 432 433 000001AF B92200 mov cx, 17*2 ; 34 ; heads = 2 434 A_18: 435 000001B2 E8810C call div32 436 ; If remainder = 0 437 ; it is 17 spt hard disk image file 438 000001B5 21DB and bx, bx 439 000001B7 7414 jz short A_20 440 A_19: 441 000001B9 83C111 add cx, 17 442 000001BC 81F91001 cmp cx, 17*16 ; 272 ; heads = 16 443 000001C0 0F87D305 ja B_04 ; invalid image file ! 444 445 ;mov ax, [pp_Sectors] 446 ;mov dx, [pp_Sectors+2] 447 448 ; 17/10/2020 449 000001C4 A1[A06E] mov ax, [total_sectors] 450 000001C7 8B16[A26E] mov dx, [total_sectors+2] 451 452 000001CB EBE5 jmp short A_18 453 454 A_20: 455 000001CD 3D0004 cmp ax, 1024 456 000001D0 77E7 ja short A_19 457 458 000001D2 B311 mov bl, 17 459 000001D4 881E[AA40] mov [sectors], bl ; 17 460 000001D8 A3[AE40] mov [cylinders], ax 461 462 000001DB 89C8 mov ax, cx 463 000001DD F6F3 div bl 464 ;xor ah, ah 465 000001DF A3[AC40] mov [heads], ax 466 467 000001E2 EB46 jmp short A_26 468 469 A_21: 470 ; cylinders*63sectors*32heads (>528MB, <=1GB) 471 ;cmp dx, 3F00h ; 1024*32*63 (3F000000h) 472 000001E4 83FA1F cmp dx, 1Fh ; 17/10/2020 473 000001E7 7726 ja short A_23 474 000001E9 7210 jb short A_22 475 ;and ax, ax 476 ;jnz short A_23 477 000001EB 3D0080 cmp ax, 8000h ; 17/10/2020 478 000001EE 771F ja short A_23 479 ; = 1GB (1024*32*63*512) 480 000001F0 C706[AC40]1000 mov word [heads], 16 481 000001F6 B80004 mov ax, 1024 482 000001F9 EB26 jmp short A_25 483 A_22: 484 000001FB B9E007 mov cx, 63*32 485 ;div cx 486 ;and dx, dx 487 000001FE E8350C call div32 ; 16/10/2020 488 00000201 21DB and bx, bx ; remainder 489 00000203 0F859005 jnz B_04 490 00000207 C706[AC40]2000 mov word [heads], 32 491 0000020D EB12 jmp short A_25 492 A_23: 493 ; cylinders*63sectors*64heads (>1GB, <=2GB) 494 0000020F B9C00F mov cx, 63*64 495 ;div cx 496 ;and dx, dx 497 00000212 E8210C call div32 ; 16/10/2020 498 00000215 21DB and bx, bx ; remainder 499 00000217 0F857C05 jnz B_04 500 ;A_24: 501 0000021B C706[AC40]4000 mov word [heads], 64 502 A_25: 503 00000221 C706[AA40]3F00 mov word [sectors], 63 504 00000227 A3[AE40] mov [cylinders], ax 505 A_26: 506 ; 08/02/2019 507 508 ; calculate total sectors (by using CHS values) 509 0000022A A1[AA40] mov ax, [sectors] 510 0000022D F726[AC40] mul word [heads] 511 00000231 A3[DA6E] mov [min_sectors], ax ; Minimum sectors 512 513 ; 17/10/2020 514 ;mov dx, [cylinders] 515 ;mul dx 516 ;mov [total_sectors], ax 517 ;mov [total_sectors+2], dx 518 519 ; 12/02/2019 520 00000234 BE[7C5F] mov si, disk_chs_header 521 A_24: ; 20/09/2020 522 00000237 E80F1C call print_msg 523 A_27: 524 0000023A E8F222 call init_partition_tables 525 0000023D 7307 jnc short A_28 526 527 ; 24/02/2019 528 0000023F E81129 call partition_table_fix 529 00000242 73F6 jnc short A_27 530 531 00000244 CD20 int 20h 532 A_28: 533 ; 26/02/2019 534 00000246 803E[A971]00 cmp byte [epnumber], 0 535 0000024B 7623 jna short A_29 536 537 ; Enable random access to disk image file 538 0000024D C606[B040]01 mov byte [random], 1 539 540 ;mov byte [ldrives], 255 ; invalid value 541 ; ; to prevent deleting 542 ; ; extended partition 543 544 ; Open disk image file again. 545 00000252 BA[9959] mov dx, img_file_name 546 00000255 B8023D mov ax, 3D02h ; open for reading and writing 547 00000258 CD21 int 21h 548 0000025A 7214 jc short A_29 549 550 0000025C A3[A840] mov [img_file_handle], ax 551 552 0000025F E87D2E call init_ext_partition_tables 553 554 ; Close file 555 00000262 8B1E[A840] mov bx, [img_file_handle] 556 00000266 B43E mov ah, 3Eh ; close file 557 00000268 CD21 int 21h 558 559 ; 28/02/2019 560 0000026A C706[A840]0000 mov word [img_file_handle], 0 561 A_29: 562 ; 08/03/2019 563 00000270 803E[D96E]00 cmp byte [existingfile], 0 564 00000275 7743 ja short A_32 565 566 00000277 B80300 mov ax, 3 ; clear screen 567 0000027A CD10 int 10h 568 569 0000027C E8121D call display_chs_table 570 571 0000027F BE[6756] mov si, CRLF 572 00000282 E8C41B call print_msg 573 574 ; 08/03/2019 575 00000285 C606[D96E]01 mov byte [existingfile], 1 576 577 0000028A E82A27 call dpt_1 578 579 0000028D BE[6756] mov si, CRLF 580 00000290 E8B61B call print_msg 581 582 00000293 BE[9654] mov si, msg_edit_or_exit 583 00000296 E8B01B call print_msg 584 A_30: 585 00000299 30E4 xor ah, ah 586 0000029B CD16 int 16h 587 588 0000029D 3C0D cmp al, 13 ; CR (ENTER) key 589 0000029F 7426 je short A_33 590 591 000002A1 3C1B cmp al, 27 ; ESCape key 592 000002A3 740D je short A_31 593 594 000002A5 3C20 cmp al, 32 ; SPACE key 595 000002A7 741E je short A_33 596 597 000002A9 3C03 cmp al, 3 ; CTRL+C 598 000002AB 7405 je short A_31 599 600 000002AD 83F800 cmp ax, 0 ; CTRL+BREAK 601 000002B0 77E7 ja short A_30 602 A_31: 603 000002B2 BE[6756] mov si, CRLF 604 000002B5 E8911B call print_msg 605 606 000002B8 CD20 int 20h 607 608 A_32: 609 ; initialize primary partition tables 610 611 000002BA E87222 call init_partition_tables 612 000002BD 7308 jnc short A_33 ; 24/02/2019 613 614 ; 24/02/2019 615 000002BF E89128 call partition_table_fix 616 000002C2 73F6 jnc short A_32 617 ; ESC key has been pressed for EXIT 618 000002C4 E9C504 jmp B_02 ; Terminate program 619 A_33: 620 ; 04/02/2019 621 000002C7 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 622 000002C9 E8D526 call display_partition_table 623 A_34: 624 000002CC 30C0 xor al, al ; 11/02/2019 625 000002CE 3806[A671] cmp byte [pcount], al ; 0 626 ;jna A_44 ; empty partition table 627 000002D2 7703 ja short A_35 628 ;inc al ; 11/02/2019 629 ; 10/02/2019 630 ;mov [newdisk], al ; 1 ; Continue as new disk image (with empty pt) 631 ;mov [random], al ; 1 ; next r/w is not sequental 632 000002D4 E9EF00 jmp A_44 633 A_35: 634 ; Check disk parameters with current CHS settings 635 000002D7 31DB xor bx, bx 636 000002D9 31C9 xor cx, cx 637 A_36: 638 000002DB 80BF[6371]00 cmp byte [part_table_sys_id+bx], 0 639 000002E0 767C jna A_37 640 641 000002E2 A1[AA40] mov ax, [sectors] 642 000002E5 F726[AC40] mul word [heads] 643 ; dx = 0, ax = heads*sectors 644 000002E9 8B97[6171] mov dx, [part_table_start_cyl+bx] 645 000002ED F7E2 mul dx 646 000002EF 89C6 mov si, ax 647 000002F1 89D7 mov di, dx 648 000002F3 8A87[5F71] mov al, [part_table_start_head+bx] 649 000002F7 F626[AA40] mul byte [sectors] 650 000002FB 01C6 add si, ax 651 000002FD 83D700 adc di, 0 652 00000300 8A87[6071] mov al, [part_table_start_sector+bx] 653 00000304 30E4 xor ah, ah 654 00000306 FEC8 dec al ; 1 -> 0 655 00000308 01C6 add si, ax 656 0000030A 83D700 adc di, 0 657 658 0000030D 3BBF[6A71] cmp di, [part_table_rel_sec_hw+bx] 659 ;jne B_04 ; invalid 660 00000311 7558 jne short A_38 661 00000313 3BB7[6871] cmp si, [part_table_rel_sec_lw+bx] 662 ;jne B_04 ; invalid 663 00000317 7552 jne short A_38 664 665 00000319 A1[AA40] mov ax, [sectors] 666 0000031C F726[AC40] mul word [heads] 667 ; dx = 0, ax = heads*sectors 668 00000320 8B97[6671] mov dx, [part_table_end_cyl+bx] 669 00000324 F7E2 mul dx 670 00000326 89C6 mov si, ax 671 00000328 89D7 mov di, dx 672 0000032A 8A87[6471] mov al, [part_table_end_head+bx] 673 0000032E F626[AA40] mul byte [sectors] 674 00000332 01C6 add si, ax 675 00000334 83D700 adc di, 0 676 00000337 8A87[6571] mov al, [part_table_end_sector+bx] 677 0000033B 30E4 xor ah, ah 678 ;dec al ; 63 -> 62 679 0000033D 01C6 add si, ax 680 0000033F 83D700 adc di, 0 681 682 00000342 8B87[6C71] mov ax, [part_table_num_sec_lw+bx] 683 00000346 8B97[6E71] mov dx, [part_table_num_sec_hw+bx] 684 685 0000034A 0387[6871] add ax, [part_table_rel_sec_lw+bx] 686 0000034E 1397[6A71] adc dx, [part_table_rel_sec_hw+bx] 687 688 00000352 39F0 cmp ax, si 689 ;jne B_04 ; invalid 690 00000354 7515 jne short A_38 691 692 00000356 39FA cmp dx, di 693 ;jne B_04 ; invalid 694 00000358 7511 jne short A_38 695 696 0000035A FE06[5C71] inc byte [goodpte] 697 A_37: 698 0000035E FEC1 inc cl 699 700 00000360 80F904 cmp cl, 4 701 00000363 7316 jnb short A_39 702 703 00000365 83C312 add bx, 18 ; partition table structure size 704 705 00000368 E970FF jmp A_36 706 A_38: 707 ; 24/02/2019 708 ; If defective pte count > 1 do not tolerate MBR. 709 0000036B B001 mov al, 1 710 0000036D 3806[5D71] cmp [badpte], al ; 1 711 00000371 0F872204 ja B_04 712 00000375 FE06[5D71] inc byte [badpte] 713 00000379 EBE3 jmp short A_37 714 A_39: 715 ; If defective pte count > good pte, we must not continue 716 0000037B A0[5D71] mov al, [badpte] 717 0000037E 20C0 and al, al 718 00000380 7410 jz short A_41 719 720 00000382 3A06[5C71] cmp al, [goodpte] 721 00000386 0F870D04 ja B_04 722 723 ; 24/02/2019 724 A_40: 725 0000038A BE[0961] mov si, msg_defective_pt 726 0000038D E8B91A call print_msg 727 00000390 EB34 jmp short A_44 728 729 A_41: 730 ; LBA and CHS values of all partitions are OK (here) 731 732 ; sort MBR (primary) partitions 733 734 00000392 E8E322 call sort_partition_table 735 736 ; Checking partition overlaps (via start and end cylinders) 737 738 00000395 31DB xor bx, bx 739 00000397 BA1200 mov dx, 18 740 A_42: 741 0000039A FEC3 inc bl 742 743 0000039C 8A87[EA6E] mov al, [bx+sort] 744 000003A0 F6E2 mul dl 745 000003A2 89C6 mov si, ax ; current 746 747 000003A4 80BC[6371]00 cmp byte [part_table_sys_id+si], 0 748 000003A9 7616 jna short A_43 749 750 000003AB 8A87[E96E] mov al, [bx+sort-1] 751 000003AF F6E2 mul dl 752 000003B1 89C7 mov di, ax ; previous 753 754 000003B3 8B85[6671] mov ax, [part_table_end_cyl+di] 755 000003B7 3B84[6171] cmp ax, [part_table_start_cyl+si] 756 000003BB 7204 jb short A_43 757 758 000003BD 21C0 and ax, ax 759 ;jnz B_04 ; overlap error (except empty entries) 760 ; 24/02/2019 761 000003BF 75C9 jnz short A_40 762 763 A_43: 764 000003C1 80FB03 cmp bl, 3 765 000003C4 72D4 jb short A_42 766 767 A_44: 768 000003C6 BE[3A5B] mov si, mbr_editing_options 769 000003C9 E87D1A call print_msg 770 771 000003CC BE[E85B] mov si, enter_option_number_msg 772 000003CF E8771A call print_msg 773 774 000003D2 803E[E86E]00 cmp byte [ldrives], 0 775 000003D7 760C jna short A_45 776 777 000003D9 BE[6756] mov si, CRLF 778 000003DC E86A1A call print_msg 779 780 000003DF BE[5162] mov si, str_display_ebr_pt 781 000003E2 E8641A call print_msg 782 A_45: 783 ;mov si, CRLF 784 ;call print_msg 785 786 A_46: 787 000003E5 30E4 xor ah, ah 788 000003E7 CD16 int 16h 789 790 000003E9 3C30 cmp al, '0' 791 000003EB 7428 je short A_47 792 793 000003ED 3C31 cmp al, '1' 794 000003EF 742D je short create_partition 795 000003F1 3C32 cmp al, '2' 796 000003F3 0F84F300 je activate_partition 797 000003F7 3C33 cmp al, '3' 798 000003F9 0F849001 je delete_partition 799 000003FD 3C34 cmp al, '4' 800 000003FF 0F849602 je write_pt_mbr 801 802 00000403 3C1B cmp al, 27 ; ESCape 803 00000405 740E je short A_47 804 805 ; 28/02/2019 806 00000407 803E[E86E]00 cmp byte [ldrives], 0 807 0000040C 76D7 jna short A_46 808 809 0000040E 3C20 cmp al, 20h ; SPACE 810 00000410 75D3 jne short A_46 811 812 00000412 E97127 jmp display_extended_pt 813 A_47: 814 ; terminate 815 00000415 CD20 int 20h 816 817 A_48: 818 ; 24/02/2019 819 00000417 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 820 00000419 E88525 call display_partition_table 821 0000041C EBA8 jmp short A_44 822 823 ;----------------------------------------------------------------------------- 824 825 create_partition: 826 ; 10/02/2019 827 0000041E 31C0 xor ax, ax 828 00000420 A2[B46E] mov byte [wholedisk], al ; 0 ; Reset wholedisk flag 829 830 ; 13/02/2019 831 00000423 3806[B140] cmp byte [newdisk], al ; 0 832 00000427 772E ja short cp_2 ; New disk image, continue 833 834 00000429 3806[A671] cmp byte [pcount], al ; 0 ; number of (valid) partitions 835 0000042D 7707 ja short cp_1 836 837 0000042F C606[B140]01 mov byte [newdisk], 1 838 00000434 EB21 jmp short cp_2 839 cp_1: 840 00000436 803E[A671]04 cmp byte [pcount], 4 841 0000043B 7339 jnb short cp_3 ; full pt ! 842 843 ; al = 0 844 0000043D E89B22 call find_part_free_space 845 ; Following values are for the max. free space on disk 846 847 00000440 21C9 and cx, cx 848 00000442 7445 jz short cp_4 ; there is not free space on disk 849 850 ;mov [c_cylinders], cx ; count of free cylinders in the gap 851 00000444 891E[4472] mov [c_fspc_offset], bx ; offset from beginning of 'fspc:' 852 ;mov [c_gap], al ; gap (space index) number of this free space 853 ; ; 0 -> before partition 1 (as PTE) 854 ; ; 1-2-3 -> between partitions 1 to 4 855 ; ; 4 -> after partition 4 (as PTE) 856 857 ; Start to job with non-aligned (full) free sectors of this max. space 858 859 00000448 8B87[FA71] mov ax, [free_space.sectors_unused+bx] 860 0000044C 8B97[FC71] mov dx, [free_space.sectors_unused+2+bx] 861 862 00000450 A3[B06E] mov [pp_Sectors], ax 863 00000453 8916[B26E] mov [pp_Sectors+2], dx 864 cp_2: 865 00000457 C606[B040]01 mov byte [random], 1 ; random access (use seek before reading) 866 867 0000045C 3906[A840] cmp [img_file_handle], ax ; 0 868 00000460 0F87000B ja B_49 869 870 ; Open disk image file again. 871 872 ; 25/02/2019 (Random access to disk image sectors must be enabled) 873 ;dec byte [random] ; 0 ; masterboot sector will be written 874 ; ; no need to seek file pointer 875 876 00000464 BA[9959] mov dx, img_file_name 877 00000467 B8023D mov ax, 3D02h ; open file for reading and writing 878 0000046A CD21 int 21h 879 0000046C 0F82C319 jc D_02 880 881 00000470 A3[A840] mov [img_file_handle], ax 882 883 00000473 E9EE0A jmp B_49 ; New/Empty disk, create partition menu 884 885 cp_3: 886 ; 13/02/2019 887 ; There is not a free pt entry to create a new partition 888 889 00000476 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 890 00000478 E82625 call display_partition_table 891 892 0000047B BE[CA5C] mov si, msg_full_pt 893 0000047E E8C819 call print_msg 894 00000481 BE[F75C] mov si, msg_to_create_new_p 895 00000484 E8C219 call print_msg 896 897 00000487 EB73 jmp ap_0 898 cp_4: 899 ; 02/03/2019 900 00000489 803E[A971]00 cmp byte [epnumber], 0 901 0000048E 7602 jna short cp_5 902 903 00000490 EB08 jmp short create_logical_drives 904 cp_5: 905 ; 15/02/2019 906 ; There is not (enough) free space to create a new partition 907 908 00000492 BE[155D] mov si, msg_no_free_space 909 00000495 E8B119 call print_msg 910 00000498 EB62 jmp ap_0 911 912 ;----------------------------------------------------------------------------- 913 914 create_logical_drives: 915 ; 05/03/2019 916 0000049A E8202A call check_ext_free_space 917 0000049D 7236 jc short cld_5 ; 19/10/2020 918 cld_1: 919 ; 05/03/2019 920 0000049F 803E[E86E]04 cmp byte [ldrives], 4 921 000004A4 7203 jb short cld_2 922 000004A6 E94F27 jmp eetc_2 923 cld_2: 924 000004A9 BE[8465] mov si, msg_c_ldd_q 925 000004AC E89A19 call print_msg 926 cld_3: 927 000004AF 28E4 sub ah, ah 928 000004B1 CD16 int 16h 929 930 000004B3 3C1B cmp al, 27 ; ESCAPE key 931 000004B5 0F846501 je cp_esc 932 000004B9 24DF and al, 0DFh 933 000004BB 3C4E cmp al, 'N' 934 000004BD 740D je short cld_4 935 000004BF 3C59 cmp al, 'Y' 936 000004C1 75EC jne short cld_3 937 000004C3 BE[0A5E] mov si, _msg_YES 938 000004C6 E88019 call print_msg 939 940 000004C9 E95927 jmp edit_ext_table_create_x 941 cld_4: 942 000004CC BE[105E] mov si, _msg_NO 943 000004CF E87719 call print_msg 944 945 000004D2 E94901 jmp cp_esc 946 cld_5: 947 000004D5 BE[2465] mov si, msg_c_part_error 948 000004D8 E86E19 call print_msg 949 950 000004DB 803E[E86E]03 cmp byte [ldrives], 3 951 000004E0 76C7 jna short cld_2 952 953 000004E2 BE[5265] mov si, msg_c_ldd_error 954 000004E5 E86119 call print_msg 955 956 000004E8 EB12 jmp short ap_0 957 958 ;----------------------------------------------------------------------------- 959 960 activate_partition: 961 ; 12/02/2019 962 000004EA 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 963 000004EC E8B224 call display_partition_table 964 965 000004EF 803E[A671]00 cmp byte [pcount], 0 966 000004F4 7713 ja short ap_1 967 968 000004F6 BE[7E5C] mov si, msg_empty_pt 969 000004F9 E84D19 call print_msg 970 971 ap_0: 972 000004FC BE[2057] mov si, msg_press_any_key 973 000004FF E84719 call print_msg 974 975 00000502 30E4 xor ah, ah 976 00000504 CD16 int 16h 977 978 00000506 E91501 jmp ap_esc 979 980 ap_1: 981 ; Set valid_ppnums (MBR partition IDs) list 982 00000509 BE[FE58] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 983 0000050C BB[FC70] mov bx, valid_ppnums 984 0000050F B104 mov cl, 4 985 ap_2: 986 00000511 8A4404 mov al, [si+ptFileSystemID] 987 00000514 8807 mov [bx], al 988 00000516 FEC9 dec cl 989 00000518 7406 jz short ap_3 990 0000051A 43 inc bx 991 0000051B 83C610 add si, 16 992 0000051E EBF1 jmp short ap_2 993 ap_3: 994 00000520 BE[FD5E] mov si, msg_enter_pn_to_act 995 00000523 E82319 call print_msg 996 ap_getchar: 997 00000526 30E4 xor ah, ah 998 00000528 CD16 int 16h 999 1000 ; 19/10/2020 1001 0000052A 3C1B cmp al, 27 1002 0000052C 0F84EE00 je ap_esc 1003 1004 ;cmp al, '0' 1005 ;je ap_esc 1006 1007 00000530 3C31 cmp al, '1' 1008 00000532 72F2 jb short ap_getchar 1009 00000534 3C34 cmp al, '4' 1010 00000536 77EE ja short ap_getchar 1011 1012 00000538 30E4 xor ah, ah 1013 0000053A 89C2 mov dx, ax 1014 1015 0000053C 80EA31 sub dl, '1' 1016 0000053F 89D6 mov si, dx 1017 00000541 38A4[FC70] cmp byte [si+valid_ppnums], ah ; 0 1018 00000545 76DF jna short ap_getchar ; Empty partition table entry, it is not shown 1019 1020 00000547 BB0700 mov bx, 07h 1021 0000054A B409 mov ah, 09h 1022 0000054C B90100 mov cx, 1 1023 0000054F CD10 int 10h 1024 1025 00000551 BE[FE58] mov si, MasterBootBuff+pTableOffset 1026 00000554 BF[5E71] mov di, part_table_boot_ind ; (**) 1027 1028 ; Clear all of possible active partition flags 1029 00000557 8834 mov [si], dh ; 0 1030 00000559 887410 mov [si+16], dh ; 0 1031 0000055C 887420 mov [si+32], dh ; 0 1032 0000055F 887430 mov [si+48], dh ; 0 1033 1034 ; This may not be needed !? 1035 ; (**) (Primary partitions structure/list) 1036 00000562 8835 mov [di], dh ; 0 1037 00000564 887512 mov [di+18], dh ; 0 1038 00000567 887524 mov [di+36], dh ; 0 1039 0000056A 887536 mov [di+54], dh ; 0 1040 1041 0000056D 20D2 and dl, dl 1042 0000056F 740D jz short ap_4 1043 1044 00000571 89D0 mov ax, dx 1045 1046 00000573 C0E004 shl al, 4 ; * 16 1047 00000576 01C6 add si, ax 1048 1049 00000578 B012 mov al, 18 1050 0000057A F6E2 mul dl ; 1 to 3 1051 0000057C 01C7 add di, ax 1052 ap_4: 1053 ; Then set active partition as requested by user 1054 0000057E C60480 mov byte [si], 80h 1055 00000581 C60580 mov byte [di], 80h ; (**) 1056 1057 00000584 BE[6756] mov si, CRLF ; Next line 1058 00000587 E8BF18 call print_msg 1059 1060 ; NOTE: Only the MBR buffer has been changed 1061 ; (Masterboot sector will not be updated unless/till 1062 ; MBR partition table -and MBR code- will be written 1063 ; to disk image as result of 'write part. table' command.) 1064 1065 ;; wait for 1 second 1066 ;mov ah, 02h 1067 ;int 1Ah 1068 ;mov [GetChar], dh 1069 ;ap_wait: 1070 ;mov ah, 02h 1071 ;int 1Ah 1072 ;cmp dh, [GetChar] 1073 ;je short ap_wait 1074 1075 ;jmp A_33 ; display partition table again 1076 0000058A E98AFE jmp A_48 ; 25/02/2019 1077 1078 ;----------------------------------------------------------------------------- 1079 1080 delete_partition: 1081 ; 19/10/2020 1082 ; 10/02/2019 1083 0000058D 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 1084 0000058F E80F24 call display_partition_table 1085 1086 00000592 803E[A671]00 cmp byte [pcount], 0 1087 00000597 7712 ja short dp_1 1088 1089 00000599 BE[7E5C] mov si, msg_empty_pt 1090 0000059C E8AA18 call print_msg 1091 1092 0000059F BE[2057] mov si, msg_press_any_key 1093 000005A2 E8A418 call print_msg 1094 1095 000005A5 30E4 xor ah, ah 1096 000005A7 CD16 int 16h 1097 1098 000005A9 EB73 jmp short dp_esc 1099 1100 dp_1: 1101 ; Set valid_ppnums (MBR partition IDs) list 1102 000005AB BE[FE58] mov si, MasterBootBuff+pTableOffset ; MasterBootBuff+446 1103 000005AE BB[FC70] mov bx, valid_ppnums 1104 000005B1 B104 mov cl, 4 1105 dp_2: 1106 000005B3 8A4404 mov al, [si+ptFileSystemID] 1107 000005B6 8807 mov [bx], al 1108 000005B8 FEC9 dec cl 1109 000005BA 7406 jz short dp_3 1110 000005BC 43 inc bx 1111 000005BD 83C610 add si, 16 1112 000005C0 EBF1 jmp short dp_2 1113 dp_3: 1114 000005C2 BE[395D] mov si, msg_enter_pn_to_del 1115 000005C5 E88118 call print_msg 1116 dp_getchar1: 1117 000005C8 30E4 xor ah, ah 1118 000005CA CD16 int 16h 1119 1120 ; 19/10/2020 1121 000005CC 3C1B cmp al, 27 1122 000005CE 744E je short dp_esc 1123 000005D0 3C30 cmp al, '0' 1124 000005D2 744A je short dp_esc 1125 ;cmp al, '1' 1126 000005D4 72F2 jb short dp_getchar1 1127 000005D6 3C34 cmp al, '4' 1128 000005D8 77EE ja short dp_getchar1 1129 1130 ;sub al, '0' 1131 000005DA 30FF xor bh, bh 1132 000005DC 88C3 mov bl, al 1133 ;dec bl 1134 000005DE 80EB31 sub bl, '1' 1135 000005E1 38BF[FC70] cmp byte [bx+valid_ppnums], bh ; 0 ; 12/02/2019 1136 000005E5 76E1 jna short dp_getchar1 ; Empty partition table entry, it is not shown 1137 1138 000005E7 881E[0971] mov [del_part_num], bl ; Selected partition number to be deleted. 1139 ;add al, '0' 1140 000005EB A2[5D5D] mov [chr_del_pnum1], al ; Partition number for "Enter ..." text 1141 000005EE A2[FF5D] mov [chr_del_pnum2], al ; Partition number for "Do you want ..." text 1142 1143 000005F1 BE[5D5D] mov si, chr_del_pnum1 ; write partition number (user input) 1144 000005F4 E85218 call print_msg 1145 1146 ;xor al, al 1147 000005F7 A2[5D5D] mov [chr_del_pnum1], al ; 0 ; reset 1148 1149 000005FA BE[615D] mov si, msg_delete_partition_q ; question for deleting (with warning) 1150 000005FD E84918 call print_msg 1151 1152 dp_getchar2: 1153 00000600 30E4 xor ah, ah 1154 00000602 CD16 int 16h 1155 1156 00000604 3C1B cmp al, 27 1157 00000606 7416 je short dp_esc 1158 1159 00000608 24DF and al, 0DFh 1160 0000060A 3C59 cmp al, 'Y' 1161 0000060C 7418 je short dp_yes 1162 0000060E 3C4E cmp al, 'N' 1163 00000610 75EE jne short dp_getchar2 1164 dp_no: 1165 00000612 BE[115E] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 1166 00000615 E83118 call print_msg 1167 1168 00000618 BE[6756] mov si, CRLF ; Next line 1169 0000061B E82B18 call print_msg 1170 1171 ;jmp short dp_esc 1172 1173 cp_esc: 1174 ap_esc: 1175 wptmbr_esc: 1176 dp_esc: 1177 0000061E 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 1178 00000620 E87E23 call display_partition_table 1179 00000623 E9A0FD jmp A_44 1180 1181 dp_yes: 1182 00000626 BE[0B5E] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 1183 00000629 E81D18 call print_msg 1184 1185 0000062C BF[FE58] mov di, MasterBootBuff+pTableOffset 1186 0000062F A0[0971] mov al, [del_part_num] 1187 00000632 20C0 and al, al 1188 00000634 7406 jz short dp_4 1189 00000636 98 cbw 1190 ;xor ah, ah 1191 00000637 C0E004 shl al, 4 ; * 16 1192 0000063A 01C7 add di, ax 1193 dp_4: 1194 0000063C BE[6756] mov si, CRLF ; Next line 1195 0000063F E80718 call print_msg 1196 1197 ; 27/02/2019 1198 00000642 807D0405 cmp byte [di+ptFileSystemID], 5 1199 00000646 7547 jne short dp_5 1200 1201 00000648 3806[E86E] cmp byte [ldrives], al ; 0 1202 0000064C 7641 jna short dp_5 1203 1204 0000064E BE[2761] mov si, msg_ext_part_del_error 1205 00000651 E8F517 call print_msg 1206 00000654 BE[6761] mov si, msg_cancel_continue 1207 00000657 E8EF17 call print_msg 1208 1209 0000065A 30E4 xor ah, ah 1210 0000065C CD16 int 16h 1211 1212 0000065E 3C1B cmp al, 27 ; ESCape 1213 00000660 74BC je short dp_esc 1214 1215 00000662 E87B2B call delete_logical_drives 1216 1217 ; 28/02/2019 1218 00000665 803E[E86E]01 cmp byte [ldrives], 1 1219 0000066A 73B2 jnb short dp_esc 1220 1221 0000066C 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 1222 0000066E E83023 call display_partition_table 1223 1224 00000671 BE[FA61] mov si, msg_delete_ext_part 1225 00000674 E8D217 call print_msg 1226 1227 dp_ask_again: 1228 00000677 28E4 sub ah, ah 1229 00000679 CD16 int 16h 1230 1231 0000067B 3C1B cmp al, 27 ; ESCape 1232 0000067D 749F je short dp_esc 1233 1234 0000067F 3C0D cmp al, 13 ; ENTER/CR 1235 00000681 75F4 jne short dp_ask_again 1236 1237 00000683 BF[FE58] mov di, MasterBootBuff+pTableOffset 1238 00000686 A0[0971] mov al, [del_part_num] 1239 00000689 98 cbw 1240 0000068A C0E004 shl al, 4 ; * 16 1241 0000068D 01C7 add di, ax 1242 dp_5: 1243 0000068F 31C0 xor ax, ax 1244 1245 ; clear partition table entry in MBR buffer 1246 00000691 B90800 mov cx, 8 1247 00000694 F3AB rep stosw 1248 1249 ; NOTE: Only the MBR buffer will be cleared 1250 ; (Masterboot sector will not be updated unless/till 1251 ; MBR partition table -and MBR code- will be written 1252 ; to disk image as result of 'write part. table' command.) 1253 1254 00000696 E9A1FB jmp A_27 ; 08/03/2019 1255 1256 ;----------------------------------------------------------------------------- 1257 1258 write_pt_mbr: 1259 ; 11/02/2019 1260 00000699 30C0 xor al, al ; MBR/PRIMARY PARTITIONS 1261 0000069B E80323 call display_partition_table 1262 1263 0000069E BE[155E] mov si, msg_write_masterboot_sector 1264 000006A1 E8A517 call print_msg 1265 1266 000006A4 A2[D86E] mov [GetChar], al ; 0 1267 1268 000006A7 BE[F85E] mov si, option_input 1269 000006AA E89C17 call print_msg 1270 1271 000006AD B403 mov ah, 3 1272 ;mov bx, 7 1273 000006AF CD10 int 10h ; Return Cursor Position 1274 ; DL = Column 1275 1276 000006B1 FECA dec dl ; previous char ; ']' 1277 000006B3 FECA dec dl ; previous char ; '[ ]' 1278 1279 000006B5 B402 mov ah, 2 1280 ;mov bx, 7 1281 000006B7 CD10 int 10h ; Set Cursor Position 1282 1283 ; write char at current cursor position 1284 1285 000006B9 B030 mov al, '0' ; Write default char 1286 1287 ;;mov bx, 07h 1288 000006BB B409 mov ah, 09h 1289 000006BD B90100 mov cx, 1 1290 000006C0 CD10 int 10h 1291 1292 wptmbr_getchar: 1293 000006C2 30E4 xor ah, ah 1294 000006C4 CD16 int 16h 1295 1296 000006C6 3C1B cmp al, 1Bh ; 27 1297 000006C8 0F8452FF je wptmbr_esc ; 19/10/2020 1298 1299 000006CC 3C0D cmp al, 0Dh ; 13 1300 000006CE 7414 je short wptmbr_1 1301 1302 000006D0 3C31 cmp al, '1' 1303 000006D2 72EE jb short wptmbr_getchar 1304 1305 000006D4 3C32 cmp al, '2' 1306 000006D6 77EA ja short wptmbr_getchar 1307 1308 000006D8 A2[D86E] mov [GetChar], al 1309 1310 ;;mov bx, 07h 1311 000006DB B409 mov ah, 09h 1312 000006DD B90100 mov cx, 1 1313 000006E0 CD10 int 10h 1314 000006E2 EBDE jmp short wptmbr_getchar 1315 1316 wptmbr_1: 1317 000006E4 803E[D86E]00 cmp byte [GetChar], 0 1318 000006E9 76D7 jna short wptmbr_getchar 1319 1320 000006EB BE[C65E] mov si, msg_writing_ptable 1321 000006EE E85817 call print_msg 1322 1323 000006F1 803E[D86E]32 cmp byte [GetChar], '2' 1324 000006F6 7471 je short wptmbr_5 1325 1326 wptmbr_2: 1327 ; this may not be needed here (?) 1328 ; ('seek' file pointer is needed flag) 1329 000006F8 C606[B040]01 mov byte [random], 1 1330 1331 000006FD 833E[A840]00 cmp word [img_file_handle], 0 1332 00000702 7713 ja short wptmbr_3 1333 1334 ; Open disk image file again. 1335 1336 00000704 FE0E[B040] dec byte [random] ; 0 ; masterboot sector will be written 1337 ; no need to seek file pointer 1338 1339 00000708 BA[9959] mov dx, img_file_name 1340 0000070B B8023D mov ax, 3D02h ; open file for reading and writing 1341 0000070E CD21 int 21h 1342 00000710 0F821F17 jc D_02 1343 1344 00000714 A3[A840] mov [img_file_handle], ax 1345 wptmbr_3: 1346 00000717 31C0 xor ax, ax ; 0 1347 00000719 31D2 xor dx, dx ; 0 1348 ; DX_AX = Masterboot Sector = 0 1349 0000071B BB[4057] mov bx, MasterBootBuff 1350 ; ES:BX = Sector Buffer 1351 0000071E E83717 call write_hd_sector 1352 00000721 0F820417 jc D_01 ; ! display error msg and then exit ! 1353 1354 00000725 BE[EF5E] mov si, _msg_OK 1355 00000728 E81E17 call print_msg 1356 1357 0000072B 803E[B040]00 cmp byte [random], 0 1358 00000730 7712 ja short wptmbr_4 1359 1360 ;mov byte [random], 1 1361 1362 00000732 8B1E[A840] mov bx, [img_file_handle] 1363 00000736 B43E mov ah, 3Eh ; close file 1364 00000738 CD21 int 21h 1365 0000073A 0F82F516 jc D_02 1366 1367 0000073E C706[A840]0000 mov word [img_file_handle], 0 1368 1369 wptmbr_4: 1370 ; wait for 1 second 1371 00000744 B402 mov ah, 02h 1372 00000746 CD1A int 1Ah 1373 00000748 8836[D86E] mov [GetChar], dh 1374 wptmbr_wait: 1375 0000074C B402 mov ah, 02h 1376 0000074E CD1A int 1Ah 1377 00000750 3A36[D86E] cmp dh, [GetChar] 1378 00000754 74F6 je short wptmbr_wait 1379 1380 00000756 BE[2057] mov si, msg_press_any_key 1381 00000759 E8ED16 call print_msg 1382 1383 0000075C 30E4 xor ah, ah ; "Press any key to continue" 1384 0000075E CD16 int 16h 1385 1386 00000760 BE[6756] mov si, CRLF 1387 00000763 E8E316 call print_msg 1388 1389 00000766 E9B5FE jmp wptmbr_esc 1390 1391 wptmbr_5: 1392 00000769 BE[9632] mov si, TRDOS386_MASTERBOOT_SECTOR 1393 0000076C B9DF00 mov cx, 446/2 ; Copy Singlix FS 1 MBR code 1394 ; except Partition Table 1395 0000076F BF[4057] mov di, MasterBootBuff 1396 00000772 F3A5 rep movsw 1397 1398 ; This (Below) is not needed; because, if MBR magicword 1399 ; would not be 0AA55h, we would not be able to come here! 1400 ;;add di, 64 ; skip partition table 1401 ;;mov ax, 0AA55h 1402 ;;stosw 1403 ;mov word [MBIDCode], 0AA55h 1404 1405 ; 12/02/2019 1406 ; Copy CHS parameters to Singlix MBR (on disk) 1407 1408 00000774 BF[E458] mov di, MasterBootBuff+420 1409 1410 00000777 A1[AE40] mov ax, [cylinders] 1411 0000077A AB stosw ; cylinders 1412 0000077B A1[AC40] mov ax, [heads] 1413 0000077E AB stosw ; heads 1414 0000077F A1[AA40] mov ax, [sectors] 1415 00000782 AB stosw ; sectors 1416 1417 00000783 E972FF jmp wptmbr_2 1418 1419 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1420 ; Nextline & Exit 1421 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1422 ; 25/02/2019 1423 1424 B_01: 1425 ;mov si, TrDOS_Welcome 1426 ; 04/05/2024 1427 00000786 BE[AE44] mov si, RD5_Welcome 1428 00000789 E8BD16 call print_msg 1429 B_02: 1430 0000078C BE[6756] mov si, CRLF 1431 B_03: 1432 0000078F E8B716 call print_msg 1433 00000792 B8004C mov ax, 4C00h ; terminate 1434 00000795 CD21 int 21h 1435 B_04: 1436 00000797 BE[6C45] mov si, msg_inv_image_file 1437 0000079A EBF3 jmp short B_03 ; 03/10/2020 (short jump) 1438 1439 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1440 ; Display create partition menu & get partition type input 1441 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1442 1443 create_partition_input: 1444 ; 15/02/2019 1445 ; clear screen 1446 0000079C B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1447 0000079F CD10 int 10h 1448 1449 000007A1 BE[6146] mov si, msg_create_partition_h ; header 1450 000007A4 E8A216 call print_msg 1451 000007A7 BE[5647] mov si, msg_create_partition_m ; menu 1452 000007AA E89C16 call print_msg 1453 cpi_1: 1454 000007AD 30E4 xor ah, ah 1455 000007AF CD16 int 16h 1456 000007B1 3C1B cmp al, 27 ; ESC key 1457 ;;je B_47 1458 ;je A_48 ; A_33 1459 000007B3 7445 je short cpi_4 ; 25/02/2019 1460 000007B5 3C30 cmp al, '0' 1461 ;;je B_47 1462 ;je A_48 ; A_33 1463 000007B7 7441 je short cpi_4 ; 25/02/2019 1464 000007B9 72F2 jb short cpi_1 1465 000007BB 3C34 cmp al, '4' 1466 000007BD 77EE ja short cpi_1 1467 1468 000007BF 30E4 xor ah, ah 1469 000007C1 2C30 sub al, '0' 1470 1471 ;mov [pp_type], al 1472 1473 ;mov byte [pp_type_user], 0 1474 1475 000007C3 3C01 cmp al, 1 ; DOS partition 1476 000007C5 7536 jne short cpi_5 ; ah = 0 1477 ; (al = 2 -> singlix, al = 3 -> retro unix) 1478 cpi_2: 1479 ; clear screen 1480 000007C7 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 1481 000007CA CD10 int 10h 1482 1483 000007CC BE[0C49] mov si, msg_create_dos_partition_h ; header 1484 000007CF E87716 call print_msg 1485 000007D2 BE[E04C] mov si, msg_create_dos_partition_m ; menu 1486 000007D5 E87116 call print_msg 1487 cpi_3: 1488 000007D8 30E4 xor ah, ah 1489 000007DA CD16 int 16h 1490 000007DC 3C1B cmp al, 27 ; ESC key 1491 ;je short B_47 1492 000007DE 741A je short cpi_4 1493 000007E0 3C30 cmp al, '0' 1494 ;je short B_47 1495 000007E2 7416 je short cpi_4 1496 000007E4 72F2 jb short cpi_3 1497 000007E6 3C33 cmp al, '3' 1498 000007E8 77EE ja short cpi_3 1499 1500 000007EA 30E4 xor ah, ah 1501 000007EC 2C30 sub al, '0' 1502 000007EE 3C01 cmp al, 1 1503 000007F0 7420 je short cpi_6 ; ah = 0 (al = primary dos partition) 1504 1505 ;mov byte [pp_type], 5 1506 1507 000007F2 3C02 cmp al, 2 1508 000007F4 761D jna short cpi_7 1509 1510 000007F6 B80600 mov ax, 6 ; ah = 0 (al = logical dos drive/partition) 1511 000007F9 C3 retn 1512 1513 cpi_4: 1514 000007FA 31C0 xor ax, ax ; ah = 0 (al = 0 -> ESCape/Cancel) 1515 000007FC C3 retn 1516 cpi_5: 1517 000007FD 3C04 cmp al, 4 ; option num. for partition type (user) input 1518 000007FF 7511 jne short cpi_6 1519 1520 00000801 E8631A call partition_type_input 1521 1522 00000804 B404 mov ah, 4 ; user/another type partition flag 1523 ; al = Partition ID 1524 00000806 50 push ax 1525 00000807 BE[2057] mov si, msg_press_any_key 1526 0000080A E83C16 call print_msg 1527 0000080D 28E4 sub ah, ah 1528 0000080F CD16 int 16h 1529 00000811 58 pop ax 1530 cpi_6: 1531 00000812 C3 retn 1532 cpi_7: 1533 00000813 B80500 mov ax, 5 ; ah = 0 (al = extended dos partition) 1534 00000816 C3 retn 1535 1536 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1537 ; Create primary (dos or non-dos) partition 1538 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1539 ; 16/02/2019 1540 ; (This procedure must be called after 'find_part_free_space') 1541 1542 create_primary_partition: 1543 ; 16/02/2019 1544 1545 ; INPUT: 1546 ; none 1547 ; (CHS parameters and free space calculation result will be used.) 1548 ; 1549 ; OUTPUT: 1550 ; Partition table in MBR buffer will be updated. 1551 ; 1552 ; (Modified registers: ax, bx, cx, dx, si, di) 1553 1554 ; Create primary dos or non-dos partition, 1555 ; make partition table entry 1556 1557 00000817 803E[B140]00 cmp byte [newdisk], 0 1558 0000081C 760A jna short cpp_0 1559 1560 ; cylinder = 0, head = 1, sector = 1 1561 ; LBA = (((cylinder*heads)+head)*sectors)+sector-1 1562 1563 0000081E BE[FE58] mov si, MasterBootBuff+pTableOffset 1564 1565 00000821 A1[AA40] mov ax, [sectors] ; LBA = 17 or 63 1566 00000824 31D2 xor dx, dx 1567 00000826 EB56 jmp short cpp_4 1568 cpp_0: 1569 ; 16/02/2019 1570 00000828 E82F21 call get_first_free_pte 1571 ; CX = First free PTE number, 0 to 3 1572 ; (CX = 3 if there is not a free PTE, and CF = 1) 1573 ; ((But CF = 1 is not possible here because pcount < 4)) 1574 ; SI = PTE address/offset in MBR buffer 1575 1576 ;mov si, MasterBootBuff+pTableOffset 1577 ;shl cl, 4 ; * 16 1578 ;add si, cx 1579 1580 ; 18/02/2019 1581 0000082B 8B3E[4472] mov di, [c_fspc_offset] 1582 0000082F 8B9D[F471] mov bx, [di+free_space.start] 1583 00000833 A0[AC40] mov al, [heads] 1584 00000836 F626[AA40] mul byte [sectors] 1585 0000083A F7E3 mul bx 1586 ; DX:AX = LBA of start cylinder, head 0, sector 1 1587 1588 0000083C 8A0E[4672] mov cl, [cylinder_boundary] 1589 1590 ;cmp cl, 0 ; Default (partition size unit is one of C, G, M) 1591 ; boundary alignment is forced as default 1592 ;je short cpp_4 1593 1594 ; 20/02/2019 1595 ;and cl, cl 1596 ;jz short cpp_1 1597 1598 00000840 80F959 cmp cl, 'Y' 1599 00000843 7439 je short cpp_4 ; cylinder boundary option (answer) = YES 1600 1601 00000845 80F94E cmp cl, 'N' 1602 00000848 750A jne short cpp_1 ; cylinder boundary option (answer) = YES/NO 1603 1604 ; cylinder boundary option (answer) = NO 1605 0000084A 8B85[FE71] mov ax, [di+free_space.startsector] 1606 0000084E 8B95[0072] mov dx, [di+free_space.startsector+2] 1607 00000852 EB2A jmp short cpp_4 1608 cpp_1: 1609 ;cmp cl, 27 ; ESCape 1610 ;jne short cpp_4 ; 'Y' 1611 1612 ; check cylinder boundary alignment of the start sector 1613 1614 ; if start sector is not aligned, end sector must not be aligned 1615 ; (this rule is valid for ESCape key from the user) 1616 1617 00000854 C606[4672]59 mov byte [cylinder_boundary], 'Y' ; YES for end sector check 1618 1619 00000859 8B8D[FE71] mov cx, [di+free_space.startsector] 1620 1621 0000085D 09DB or bx, bx 1622 1623 0000085F 8B9D[0072] mov bx, [di+free_space.startsector+2] 1624 1625 00000863 7508 jnz short cpp_2 ; start cylinder > 0 1626 1627 ;and bx, bx 1628 ;jnz short cpp_3 1629 1630 00000865 3B0E[AA40] cmp cx, [sectors] 1631 00000869 7413 je short cpp_4 ; start sector is as aligned 1632 0000086B EB08 jmp short cpp_3 1633 cpp_2: 1634 0000086D 39C8 cmp ax, cx 1635 0000086F 7504 jne short cpp_3 1636 00000871 39DA cmp dx, bx 1637 00000873 7409 je short cpp_4 1638 cpp_3: 1639 00000875 89C8 mov ax, cx 1640 00000877 89DA mov dx, bx 1641 00000879 C606[4672]4E mov byte [cylinder_boundary], 'N' 1642 cpp_4: 1643 0000087E 894408 mov [si+ptStartSector], ax 1644 00000881 89540A mov [si+ptStartSector+2], dx 1645 1646 ; save start sector (for partition formatting procedure) 1647 00000884 A3[AC6E] mov [pp_StartSector], ax 1648 00000887 8916[AE6E] mov [pp_StartSector+2], dx 1649 1650 0000088B 803E[B140]00 cmp byte [newdisk], 0 1651 00000890 763F jna short cpp_5 1652 1653 00000892 31C9 xor cx, cx 1654 00000894 894C03 mov [si+ptBeginCylinder], cx ; 0 1655 00000897 FEC1 inc cl ; 1 1656 00000899 884C02 mov [si+ptBeginSector], cl ; 1 1657 0000089C 884C01 mov [si+ptBeginHead], cl ; 1 1658 1659 ; set active partition flag 1660 ;mov byte [si+ptBootable], 80h ; bootable/active partition 1661 0000089F C60480 mov byte [si], 80h ; bootable/active partition 1662 1663 ; 18/02/2019 1664 1665 000008A2 8B0E[E06E] mov cx, [ppn_Sectors] 1666 000008A6 8B1E[E26E] mov bx, [ppn_Sectors+2] 1667 1668 000008AA 803E[B46E]00 cmp byte [wholedisk], 0 1669 000008AF 0F86FE00 jna cpp_12 1670 1671 000008B3 A0[AC40] mov al, [heads] 1672 000008B6 FEC8 dec al 1673 000008B8 884405 mov [si+ptEndHead], al 1674 000008BB A0[AA40] mov al, [sectors] 1675 000008BE 884406 mov [si+ptEndSector], al 1676 000008C1 A1[AE40] mov ax, [cylinders] 1677 000008C4 48 dec ax 1678 000008C5 884407 mov [si+ptEndCylinder], al 1679 000008C8 C0E406 shl ah, 6 1680 000008CB 086406 or [si+ptEndSector], ah 1681 1682 ;jmp cpp_16 1683 000008CE E95501 jmp cpp_15 ; 06/03/2019 1684 cpp_5: 1685 ; 18/02/2019 1686 1687 000008D1 803E[4672]59 cmp byte [cylinder_boundary], 'Y' 1688 000008D6 7525 jne short cpp_7 1689 1690 000008D8 30DB xor bl, bl ; head = 0 1691 1692 000008DA 8B8D[F471] mov cx, [di+free_space.start] 1693 1694 ; 06/03/2019 1695 ;or ax, ax 1696 ;jnz short cpp_6 1697 1698 ;and cx, cx ; start cylinder = 0 ? 1699 ;jnz short cpp_6 1700 1701 000008DE 09C8 or ax, cx 1702 000008E0 7513 jnz short cpp_6 1703 1704 000008E2 A1[AA40] mov ax, [sectors] 1705 1706 000008E5 894408 mov [si+ptStartSector], ax 1707 ;mov [si+ptStartSector+2], cx ; 0 1708 1709 000008E8 A3[AC6E] mov [pp_StartSector], ax 1710 ;mov [pp_StartSector+2], cx 1711 1712 000008EB 2906[B06E] sub [pp_Sectors], ax 1713 000008EF 190E[B26E] sbb [pp_Sectors+2], cx ; 0 1714 1715 ; cylinder 0, head 1, sector 1 (LBA = 17 or 63) 1716 000008F3 FEC3 inc bl ; head = 1 1717 cpp_6: 1718 000008F5 89C8 mov ax, cx 1719 000008F7 C6440201 mov byte [si+ptBeginSector], 1 ; sector = 1 1720 000008FB EB16 jmp short cpp_8 1721 cpp_7: 1722 ; 18/02/2019 1723 1724 ; [wholedisk] = 0 1725 1726 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 1727 ; (DOS partition size will be changed -down- to 65535 sectors, 1728 ; if it is 65536 sectors.) 1729 1730 000008FD E83601 call fix_32mb_dos_psize 1731 1732 ;cylinder = LBA / (heads_per_cylinder * sectors_per_track) 1733 ;temp = LBA % (heads_per_cylinder * sectors_per_track) 1734 ;head = temp / sectors_per_track 1735 ;sector = temp % sectors_per_track + 1 1736 1737 ; Convert LBA sector address to CHS parameters 1738 00000900 8B0E[AA40] mov cx, [sectors] 1739 00000904 E82F05 call div32 1740 ; BX = Sector number - 1 1741 00000907 FEC3 inc bl ; sector number (1 based) 1742 00000909 885C02 mov [si+ptBeginSector], bl 1743 ; DX_AX = cylinders * heads + head 1744 0000090C 8B0E[AC40] mov cx, [heads] 1745 00000910 E82305 call div32 1746 cpp_8: 1747 ; BX = Head number 1748 00000913 885C01 mov [si+ptBeginHead], bl 1749 ; AX = Cylinder number 1750 ;and ax, 1023 1751 00000916 884403 mov [si+ptBeginCylinder], al 1752 00000919 C0E406 shl ah, 6 1753 0000091C 086402 or [si+ptBeginSector], ah 1754 1755 ; clear active partition flag (for now) 1756 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 1757 0000091F C60400 mov byte [si], 0 ; not bootable/active partition 1758 1759 ;mov di, [c_fspc_offset] 1760 1761 00000922 803E[4672]59 cmp byte [cylinder_boundary], 'Y' 1762 00000927 7579 jne short cpp_11 1763 1764 00000929 8A0E[AC40] mov cl, [heads] 1765 0000092D A0[AA40] mov al, [sectors] 1766 00000930 88C5 mov ch, al 1767 00000932 F6E1 mul cl 1768 ; ax = heads*sectors 1769 1770 00000934 8B9D[F671] mov bx, [di+free_space.end] ; end cylinder of the partition 1771 1772 00000938 803E[B46E]00 cmp byte [wholedisk], 0 ; entire free space ? 1773 0000093D 7726 ja short cpp_10 1774 1775 0000093F 89C3 mov bx, ax 1776 00000941 A1[E06E] mov ax, [ppn_Sectors] 1777 00000944 8B16[E26E] mov dx, [ppn_Sectors+2] 1778 00000948 0306[AC6E] add ax, [pp_StartSector] 1779 0000094C 1316[AE6E] adc dx, [pp_StartSector+2] 1780 00000950 83E801 sub ax, 1 1781 00000953 83DA00 sbb dx, 0 1782 ; dx:ax = end sector 1783 00000956 F7F3 div bx 1784 ; ax = cylinder count 1785 00000958 21D2 and dx, dx 1786 0000095A 7401 jz short cpp_9 1787 0000095C 40 inc ax ; + 1 (because of remainder > 0) 1788 cpp_9: 1789 0000095D 93 xchg ax, bx 1790 ; bx = end cylinder 1791 ; ax = heads*sectors 1792 ; free space limit check 1793 0000095E 3B9D[F671] cmp bx, [di+free_space.end] 1794 00000962 7601 jna short cpp_10 ; ok 1795 ; end cylinder is out of free space 1796 00000964 4B dec bx ; decrease end cylinder number 1797 cpp_10: 1798 00000965 F7E3 mul bx 1799 ; dx:ax = (end cylinder)*heads*sectors 1800 00000967 52 push dx ; ** 1801 00000968 50 push ax ; * 1802 00000969 FEC9 dec cl ; heads - 1 = end head 1803 1804 0000096B 884C05 mov [si+ptEndHead], cl 1805 1806 ;mov al, [sectors] 1807 0000096E 88E8 mov al, ch 1808 00000970 885C07 mov [si+ptEndCylinder], bl 1809 00000973 88C3 mov bl, al 1810 00000975 C0E706 shl bh, 6 ; shift high bytes (2 bits) of end cyl num 1811 ; to 6 bits left 1812 00000978 08DF or bh, bl ; combine high bits of end cyl num and end sector 1813 0000097A 887C06 mov [si+ptEndSector], bh 1814 0000097D 30FF xor bh, bh ; clear bh 1815 0000097F FECB dec bl ; sectors - 1 ; 22/02/2019 1816 00000981 F6E1 mul cl 1817 00000983 5A pop dx ; * 1818 ; 22/02/2019 1819 00000984 31C9 xor cx, cx 1820 00000986 01D0 add ax, dx 1821 00000988 5A pop dx ; ** 1822 00000989 11CA adc dx, cx ; 0 1823 0000098B 01D8 add ax, bx 1824 0000098D 11CA adc dx, cx ; 0 1825 ; dx:ax = ((([end cylinder]*heads)+[end head])*sectors)+sectors-1 1826 1827 ; calculate aligned partition size in sectors 1828 0000098F 89C1 mov cx, ax 1829 00000991 89D3 mov bx, dx 1830 00000993 83C101 add cx, 1 1831 00000996 83D300 adc bx, 0 1832 00000999 2B4C08 sub cx, [si+ptStartSector] 1833 0000099C 1B5C0A sbb bx, [si+ptStartSector+2] 1834 ; bx:cx = partition size 1835 ;mov [ppn_Sectors], cx 1836 ;mov [ppn_Sectors+2], bx 1837 ;jmp cpp_16 1838 0000099F E98400 jmp cpp_15 ; 06/03/2019 1839 cpp_11: 1840 ; 20/02/2019 1841 000009A2 8B0E[E06E] mov cx, [ppn_Sectors] 1842 000009A6 8B1E[E26E] mov bx, [ppn_Sectors+2] 1843 1844 ;;mov ax, [di+free_space.startsector] 1845 ;;mov ax, [di+free_space.startsector+2] 1846 ;mov ax, [si+ptStartSector] 1847 ;mov dx, [si+ptStartSector+2] 1848 000009AA A1[AC6E] mov ax, [pp_StartSector] 1849 000009AD 8B16[AE6E] mov dx, [pp_StartSector+2] 1850 cpp_12: 1851 ; 18/02/2019 1852 1853 ; [wholedisk] = 0 1854 1855 ; Fix partition size for MSDOS 3.3 (Retro DOS 3.0) compatibility. 1856 ; (DOS partition size will be changed -down- to 65535 sectors, 1857 ; if it is 65536 sectors.) 1858 1859 000009B1 E88200 call fix_32mb_dos_psize 1860 1861 000009B4 01C8 add ax, cx 1862 000009B6 11DA adc dx, bx 1863 1864 ; Convert LBA sector address to CHS parameters 1865 000009B8 83E801 sub ax, 1 ; locate on to end sector of the partition 1866 000009BB 83DA00 sbb dx, 0 1867 1868 ; 06/03/2019 1869 000009BE 803E[4672]59 cmp byte [cylinder_boundary],'Y' 1870 ;jne short cpp_15 1871 000009C3 753A jne short cpp_14 1872 1873 000009C5 89C1 mov cx, ax 1874 000009C7 A0[AC40] mov al, [heads] 1875 000009CA F626[AA40] mul byte [sectors] 1876 000009CE 89C7 mov di, ax ; [heads]*[sectors] 1877 000009D0 91 xchg ax, cx 1878 ; cx = heads*spt 1879 000009D1 E86204 call div32 1880 ; dx = 0 1881 ; ax = end cylinder 1882 ; bx = remainder 1883 ;and bx, bx 1884 ;jz short cpp_13 1885 ;inc ax 1886 ;cpp_13: 1887 ;cmp ax, [cylinders] 1888 ;jb short cpp_14 1889 ;dec ax 1890 ;cpp_14: 1891 000009D4 8B1E[AC40] mov bx, [heads] 1892 000009D8 FECB dec bl 1893 000009DA 885C05 mov [si+ptEndHead], bl 1894 000009DD 8B0E[AA40] mov cx, [sectors] 1895 000009E1 88E2 mov dl, ah 1896 000009E3 C0E206 shl dl, 6 1897 000009E6 08CA or dl, cl 1898 000009E8 885406 mov [si+ptEndSector], dl 1899 000009EB 884407 mov [si+ptEndCylinder], al 1900 ;mul di ; [cylinders]*[heads]*[sectors] 1901 ;;sub di, cx ; ([heads] - 1) * [sectors] 1902 ;add ax, di 1903 ;adc dx, 0 1904 ;;add ax, cx 1905 ;;adc dx, 0 1906 000009EE 40 inc ax 1907 000009EF F7E7 mul di ; result = start LBA of next cylinder 1908 ; dx:ax = end sector LBA + 1 (as cyl. boundary aligned) 1909 000009F1 2B06[AC6E] sub ax, [pp_StartSector] 1910 000009F5 1B16[AE6E] sbb dx, [pp_StartSector+2] ; 26/10/2020 1911 1912 000009F9 89C1 mov cx, ax 1913 000009FB 89D3 mov bx, dx 1914 ;jmp short cpp_16 1915 000009FD EB27 jmp short cpp_15 1916 ;cpp_15: 1917 cpp_14: 1918 000009FF 8B0E[AA40] mov cx, [sectors] 1919 00000A03 E83004 call div32 1920 ; BX = Sector number - 1 1921 00000A06 FEC3 inc bl ; sector number (1 based) 1922 00000A08 885C06 mov [si+ptEndSector], bl 1923 ; DX_AX = cylinders * heads + head 1924 00000A0B 8B0E[AC40] mov cx, [heads] 1925 00000A0F E82404 call div32 1926 ; BX = Head number 1927 00000A12 885C05 mov [si+ptEndHead], bl 1928 ; AX = Cylinder number 1929 ;and ax, 1023 1930 00000A15 884407 mov [si+ptEndCylinder], al 1931 ; 18/02/2019 1932 00000A18 C0E406 shl ah, 6 1933 00000A1B 086406 or [si+ptEndSector], ah 1934 1935 00000A1E 8B0E[E06E] mov cx, [ppn_Sectors] 1936 00000A22 8B1E[E26E] mov bx, [ppn_Sectors+2] 1937 ;cpp_16: 1938 cpp_15: 1939 00000A26 894C0C mov [si+ptSectors], cx 1940 00000A29 895C0E mov [si+ptSectors+2], bx 1941 1942 ; set partition ID after checking DOS FAT limits 1943 00000A2C E8CD00 call set_partition_id 1944 ; al = partition ID 1945 1946 00000A2F A2[B56E] mov [pp_type], al 1947 1948 00000A32 884404 mov [si+ptFileSystemID], al 1949 1950 00000A35 C3 retn 1951 1952 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1953 ; Decrease DOS partition size when it is (exact) 65536 sectors 1954 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1955 ; 18/02/2019 1956 1957 fix_32mb_dos_psize: ; call this if [wholedisk] = 0 1958 1959 ; Purpose: 1960 ; If a DOS partition's size is 65536 sectors 1961 ; MSDOS 3.3 can not use it. (FAT 16 partition ID = 06h) 1962 ; Decreasing partition size to 65535 sectors will ensure 1963 ; MSDOS 3.3 compatibility (FAT 16 partition ID will be 04h). 1964 1965 ; INPUT: 1966 ; BX:CX = partition size in sectors 1967 ; [pp_type] = partition type dos, non-dos, user input 1968 ; 1969 ; OUTPUT: 1970 ; Partition size will be changed to 65535 sectors, if 1971 ; - partition size is 65536 sectors and 1972 ; - [pp_type] is 1 (DOS) 1973 ; 1974 ; [ppn_Sectors] = 65535 (if it will be changed) 1975 ; 1976 ; (Modified registers: cx, bx) 1977 1978 ;mov cx, [ppn_Sectors] 1979 ;mov bx, [ppn_Sectors+2] 1980 1981 00000A36 803E[B56E]01 cmp byte [pp_type], 1 ; DOS partition 1982 00000A3B 7513 jne short psfx_0 ; non-dos partition or user input 1983 ; nothing to do ! 1984 00000A3D 09C9 or cx, cx 1985 00000A3F 750F jnz short psfx_0 ; <> 65536 sectors 1986 00000A41 83FB01 cmp bx, 1 1987 00000A44 750A jne short psfx_0 1988 00000A46 4B dec bx 1989 ;mov [wholedisk], bx ; 0 1990 00000A47 49 dec cx ; bx:cx = 65535 1991 00000A48 890E[E06E] mov [ppn_Sectors], cx 1992 00000A4C 891E[E26E] mov [ppn_Sectors+2], bx 1993 psfx_0: 1994 00000A50 C3 retn 1995 1996 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1997 ; Create extended dos partition 1998 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1999 ; 16/02/2019 2000 ; (This procedure must be called after 'find_part_free_space') 2001 2002 create_extended_partition: 2003 ; 15/02/2019 2004 2005 ; INPUT: 2006 ; none 2007 ; (CHS parameters and free space calculation result will be used.) 2008 ; 2009 ; OUTPUT: 2010 ; Partition table in MBR buffer will be updated. 2011 ; 2012 ; (Modified registers: ax, bx, cx, dx, si, di) 2013 2014 ; Create extended dos partition, make partition table entry 2015 ; (Extended partition will be created on cylinder bounds.) 2016 2017 ; 16/02/2019 2018 00000A51 E8061F call get_first_free_pte 2019 ; CX = First free PTE number, 0 to 3 2020 ; (CX = 3 if there is not a free PTE, and CF = 1) 2021 ; ((But CF = 1 is not possible here because pcount < 4)) 2022 ; SI = PTE addres/offset in MBR buffer 2023 2024 ;mov si, MasterBootBuff+pTableOffset 2025 ;shl cl, 4 ; * 16 2026 ;add si, cx 2027 2028 00000A54 8B1E[4472] mov bx, [c_fspc_offset] 2029 2030 00000A58 8B87[F471] mov ax, [bx+free_space.start] 2031 00000A5C 89C7 mov di, ax 2032 2033 ;mov cx, 1 2034 00000A5E B101 mov cl, 1 2035 2036 ;mov byte [si+ptBootable], 0 ; not bootable/active partition 2037 00000A60 882C mov [si], ch ; 0 ; not bootable/active partition 2038 00000A62 886C01 mov [si+ptBeginHead], ch ; Head 0 2039 00000A65 C0E406 shl ah, 6 2040 00000A68 08E1 or cl, ah 2041 00000A6A 884C02 mov [si+ptBeginSector], cl ; Sector 1 2042 00000A6D 884403 mov [si+ptBeginCylinder], al 2043 2044 00000A70 A0[AC40] mov al, [heads] 2045 00000A73 F626[AA40] mul byte [sectors] 2046 ; ax = heads*sectors 2047 00000A77 F7E7 mul di ; AX * cylinder count before start cylinder 2048 ; DX:AX = LBA of cylinder DI, head 0, sector 1 2049 2050 00000A79 894408 mov [si+ptStartSector], ax 2051 00000A7C 89540A mov [si+ptStartSector+2], dx 2052 2053 ; This is not needed for extended partition. 2054 ; 16/02/2019 2055 ;mov [pp_StartSector], ax 2056 ;mov [pp_StartSector+2], dx 2057 2058 ; 16/02/2019 2059 00000A7F 803E[B46E]00 cmp byte [wholedisk], 0 2060 00000A84 772A ja short cep_2 ; all of free space will be used 2061 ; ([bx+free_space.end] will be end cyl) 2062 2063 ; calculate cylinder count (from partition size input) 2064 00000A86 A0[AC40] mov al, [heads] 2065 00000A89 F626[AA40] mul byte [sectors] 2066 00000A8D 89C1 mov cx, ax 2067 00000A8F A1[E06E] mov ax, [ppn_Sectors] 2068 00000A92 8B16[E26E] mov dx, [ppn_Sectors+2] 2069 00000A96 E89D03 call div32 2070 ; ax = cylinders 2071 ; bx = remainder 2072 00000A99 21DB and bx, bx 2073 00000A9B 7401 jz short cep_1 2074 2075 00000A9D 40 inc ax ; round up 2076 cep_1: 2077 ; 16/02/2019 2078 ; DI = extended partition's start cylinder 2079 00000A9E 89C2 mov dx, ax ; cylinder count 2080 00000AA0 01FA add dx, di ; result is end cyl + 1 2081 00000AA2 4A dec dx ; decrease number for current end cylinder 2082 00000AA3 8B1E[4472] mov bx, [c_fspc_offset] 2083 00000AA7 3B97[F671] cmp dx, [bx+free_space.end] 2084 00000AAB 7607 jna short cep_3 2085 ; 24/10/2020 2086 ;dec ax ; decrease cylinder count down to the limit 2087 00000AAD 4A dec dx ; decrease end cylinder down to the limit 2088 00000AAE EB04 jmp short cep_3 2089 cep_2: 2090 00000AB0 8B97[F671] mov dx, [bx+free_space.end] 2091 ; 24/10/2020 2092 ;mov ax, [bx+free_space.space] 2093 cep_3: 2094 00000AB4 8A2E[AC40] mov ch, [heads] 2095 00000AB8 FECD dec ch 2096 00000ABA 8A0E[AA40] mov cl, [sectors] 2097 00000ABE 886C05 mov [si+ptEndHead], ch 2098 ; 23/02/2019 2099 00000AC1 88F3 mov bl, dh 2100 00000AC3 C0E306 shl bl, 6 2101 00000AC6 08CB or bl, cl 2102 ;or [si+ptEndSector], bl 2103 ; 24/10/2020 2104 00000AC8 885C06 mov [si+ptEndSector], bl 2105 00000ACB 885407 mov [si+ptEndCylinder], dl 2106 2107 00000ACE A0[AC40] mov al, [heads] 2108 ;mul byte [sectors] 2109 00000AD1 F6E1 mul cl 2110 ; ax = heads*sectors 2111 00000AD3 F7E2 mul dx ; AX * cylinder count before end cylinder 2112 ; DX:AX = LBA of cylinder DX, head 0, sector 1 2113 00000AD5 52 push dx 2114 00000AD6 50 push ax 2115 00000AD7 88E8 mov al, ch ; [heads] - 1 2116 00000AD9 8B0E[AA40] mov cx, [sectors] ; 63 or 17 2117 00000ADD F6E1 mul cl 2118 ; ax = (heads-1)*sectors 2119 00000ADF 5A pop dx 2120 00000AE0 01D0 add ax, dx 2121 00000AE2 5A pop dx 2122 00000AE3 83D200 adc dx, 0 2123 ; dx:ax = ((end cylinder)*heads)+(heads-1)*sectors 2124 00000AE6 01C8 add ax, cx 2125 00000AE8 83D200 adc dx, 0 2126 ; dx:ax = (((end cylinder)*heads)+(heads-1)*sectors) + sectors 2127 ; dx:ax = LBA of the partition's end sector + 1 2128 00000AEB 2B4408 sub ax, [si+ptStartSector] 2129 00000AEE 1B540A sbb dx, [si+ptStartSector+2] 2130 2131 00000AF1 89440C mov [si+ptSectors], ax 2132 00000AF4 89540E mov [si+ptSectors+2], dx 2133 2134 ;mov [pp_type], al 2135 2136 00000AF7 C6440405 mov byte [si+ptFileSystemID], 5 2137 2138 00000AFB C3 retn 2139 2140 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2141 ; Set DOS (and non-dos) partition ID according to partition size 2142 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2143 ; 18/02/2019 2144 2145 set_partition_id: 2146 ; 18/02/2019 2147 ;mov cx, [ppn_Sectors] 2148 ;mov bx, [ppn_Sectors+2] 2149 2150 00000AFC A0[B56E] mov al, [pp_type] 2151 2152 ;cmp byte [pp_type], 1 2153 00000AFF 3C01 cmp al, 1 ; primary DOS (FAT12, FAT16, FAT32) 2154 00000B01 7519 jne short spid_2 2155 2156 ;mov al, 1 ; FAT12 2157 2158 00000B03 09DB or bx, bx 2159 00000B05 750A jnz short spid_1 2160 2161 00000B07 81F9A87F cmp cx, 32680 2162 00000B0B 763A jna short spid_8 ; FAT12 file system 2163 2164 00000B0D B004 mov al, 4 ; FAT16 (< 32MB) 2165 2166 00000B0F EB36 jmp short spid_8 ; FAT16 (CHS) file system 2167 2168 spid_1: 2169 00000B11 B00B mov al, 0Bh ; FAT32 (CHS) 2170 2171 00000B13 83FB10 cmp bx, 10h 2172 00000B16 732F jnb short spid_8 ; FAT32 (CHS) file system 2173 2174 00000B18 B006 mov al, 6 ; FAT16 (>= 32MB) 2175 2176 00000B1A EB2B jmp short spid_8 ; FAT16 big (CHS) file system 2177 2178 spid_2: 2179 ;cmp byte [pp_type], 2 ; Singlix FS 2180 00000B1C 3C02 cmp al, 2 2181 00000B1E 7504 jne short spid_3 2182 00000B20 B0A1 mov al, 0A1h 2183 00000B22 EB23 jmp short spid_8 2184 spid_3: 2185 ;cmp byte [pp_type], 3 ; Retro Unix FS 2186 00000B24 3C03 cmp al, 3 2187 00000B26 7504 jne short spid_4 2188 00000B28 B071 mov al, 71h 2189 00000B2A EB1B jmp short spid_8 2190 2191 spid_4: 2192 ; another partition type (user input) 2193 2194 ; [pp_type] = 4 2195 2196 00000B2C A0[B66E] mov al, [pp_type_user] 2197 2198 ; Check FAT12 fs size validation 2199 2200 00000B2F 3C01 cmp al, 1 ; FAT12 2201 00000B31 7715 ja short spid_9 2202 2203 00000B33 21DB and bx, bx 2204 00000B35 750A jnz short spid_6 2205 2206 00000B37 81F9A87F cmp cx, 32680 2207 00000B3B 760A jna short spid_8 2208 spid_5: 2209 00000B3D B004 mov al, 4 ; FAT16 (<= 32MB) 2210 00000B3F EB06 jmp short spid_8 2211 spid_6: 2212 ;;cmp bx, 10h ; 512MB (16*32MB) 2213 ;cmp bx, 40h ; 2GB (64*32MB) 2214 ;jnb short spid_7 2215 2216 00000B41 B006 mov al, 6 2217 00000B43 EB02 jmp short spid_8 2218 spid_7: 2219 00000B45 B00B mov al, 0Bh ; FAT32 (CHS) partition 2220 spid_8: 2221 00000B47 C3 retn 2222 spid_9: 2223 00000B48 3C04 cmp al, 4 ; FAT16 (< 32 MB) 2224 00000B4A 7505 jne short spid_10 2225 2226 00000B4C 09DB or bx, bx 2227 00000B4E 75F1 jnz short spid_6 2228 2229 00000B50 C3 retn ; FAT16 (< 32 MB) partition 2230 spid_10: 2231 00000B51 3C06 cmp al, 6 ; FAT 16 big partition 2232 00000B53 750E jne short spid_13 ; Extended partition or another type 2233 2234 00000B55 21DB and bx, bx 2235 00000B57 7401 jz short spid_11 2236 2237 ;;cmp bx, 10h ; 512MB (16*32MB) 2238 ;cmp bx, 40h ; 2GB (64*32MB) 2239 ;jnb short spid_7 2240 2241 00000B59 C3 retn 2242 spid_11: 2243 ;cmp ax, 4150 ; 4085 + 32 + 32 + 1 2244 00000B5A 81F93610 cmp cx, 4150 ; 14/09/2020 (BugFix) 2245 00000B5E 73DD jnb short spid_5 2246 spid_12: 2247 00000B60 B001 mov al, 1 ; FAT12 partition 2248 00000B62 C3 retn 2249 spid_13: 2250 ; 14/09/2020 2251 00000B63 3C0B cmp al, 0Bh ; FAT 32 (CHS) partition 2252 00000B65 7419 je short spid_15 ; FAT 32 CHS 2253 00000B67 3C0C cmp al, 0Ch 2254 00000B69 750C jne short spid_14 2255 ; FAT 32 LBA 2256 00000B6B 21DB and bx, bx ; < 33 MB 2257 00000B6D 74EB jz short spid_11 ; force to FAT 16 CHS or FAT 12 2258 00000B6F 83FB10 cmp bx, 10h ; 512 MB 2259 00000B72 73D3 jnb short spid_8 ; OK, FAT 32 LBA has been confirmed 2260 00000B74 B00E mov al, 0Eh ; force to FAT 16 LBA 2261 00000B76 C3 retn 2262 spid_14: 2263 ; 14/09/2020 2264 00000B77 3C0E cmp al, 0Eh 2265 00000B79 75CC jne short spid_8 ; non-dos or extended partition 2266 ; FAT 16 LBA 2267 00000B7B 09DB or bx, bx 2268 00000B7D 74DB jz short spid_11 2269 ;cmp bx, 20h ; 1 GB 2270 ;jb short spid_8 2271 ;mov al, 0Ch ; FAT 32 LBA 2272 00000B7F C3 retn 2273 spid_15: 2274 ; Minimum size of FAT 32 FS = 65525 + 512 + 512 + 32 2275 ; >= 66581 sectors (or >= 65525 data clusters) 2276 00000B80 83FB01 cmp bx, 1 2277 00000B83 72D5 jb short spid_11 ; invalid! (< 33 MB) 2278 00000B85 77C0 ja short spid_8 2279 00000B87 81F91504 cmp cx, 1045 2280 00000B8B 7201 jb short spid_16 ; invalid! (< 33 MB) 2281 00000B8D C3 retn 2282 spid_16: 2283 00000B8E B006 mov al, 6 2284 00000B90 C3 retn 2285 2286 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2287 ; Set disk size before creating hd image file 2288 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2289 2290 new_image: 2291 ; 07/03/2019 2292 00000B91 B80300 mov ax, 3 ; set video mode to 3 (clear video page) 2293 00000B94 CD10 int 10h 2294 B_05: 2295 ;mov byte [existingfile], 0 ; 12/02/2019 2296 00000B96 E8F813 call display_chs_table 2297 B_06: 2298 00000B99 30E4 xor ah, ah 2299 00000B9B CD16 int 16h 2300 00000B9D 3C61 cmp al, 'a' 2301 00000B9F 7206 jb short B_07 2302 00000BA1 3C7A cmp al, 'z' 2303 00000BA3 7702 ja short B_07 2304 00000BA5 24DF and al, 0DFh 2305 B_07: 2306 00000BA7 3C43 cmp al, 'C' 2307 00000BA9 752C jne short B_12 2308 B_08: 2309 00000BAB 833E[AE40]00 cmp word [cylinders], 0 2310 00000BB0 7706 ja short B_09 2311 00000BB2 C706[AE40]0004 mov word [cylinders], 1024 2312 B_09: 2313 00000BB8 833E[AC40]00 cmp word [heads], 0 2314 00000BBD 7706 ja short B_10 2315 00000BBF C706[AC40]1000 mov word [heads], 16 2316 B_10: 2317 00000BC5 833E[AA40]00 cmp word [sectors], 0 2318 00000BCA 7706 ja short B_11 2319 00000BCC C706[AA40]3F00 mov word [sectors], 63 2320 B_11: 2321 00000BD2 A2[B76E] mov byte [chs_focus], al 2322 00000BD5 EBBF jmp short B_05 2323 B_12: 2324 00000BD7 3C48 cmp al, 'H' 2325 00000BD9 74D0 je short B_08 2326 00000BDB 3C53 cmp al, 'S' 2327 00000BDD 74CC je short B_08 2328 00000BDF 3C1B cmp al, 27 ; ESC key 2329 00000BE1 0F848D00 je B_18 2330 00000BE5 3C0D cmp al, 13 ; ENTER key 2331 00000BE7 0F85EF00 jne B_21 2332 2333 00000BEB 833E[AA40]3F cmp word [sectors], 63 2334 00000BF0 730D jnb short B_13 2335 00000BF2 833E[AC40]10 cmp word [heads], 16 2336 00000BF7 7606 jna short B_13 2337 00000BF9 C706[AC40]1000 mov word [heads], 16 2338 B_13: 2339 00000BFF A1[AA40] mov ax, [sectors] 2340 00000C02 F726[AC40] mul word [heads] 2341 00000C06 A3[DA6E] mov [min_sectors], ax ; 08/02/2019 2342 00000C09 8B16[AE40] mov dx, [cylinders] 2343 00000C0D F7E2 mul dx 2344 00000C0F A3[A06E] mov [total_sectors], ax 2345 00000C12 8916[A26E] mov [total_sectors+2], dx 2346 2347 ; 05/02/2019 2348 00000C16 BF[9356] mov di, str_disk_sectors 2349 2350 00000C19 89E5 mov bp, sp 2351 00000C1B B90A00 mov cx, 10 2352 B_14: 2353 00000C1E E81502 call div32 2354 2355 00000C21 80C330 add bl, '0' 2356 00000C24 53 push bx 2357 00000C25 21C0 and ax, ax 2358 00000C27 75F5 jnz short B_14 2359 00000C29 21D2 and dx, dx 2360 00000C2B 75F1 jnz short B_14 2361 2362 00000C2D 29E5 sub bp, sp 2363 00000C2F D1ED shr bp, 1 2364 B_15: 2365 00000C31 58 pop ax 2366 00000C32 AA stosb 2367 00000C33 4D dec bp 2368 00000C34 75FB jnz short B_15 2369 2370 00000C36 30C0 xor al, al 2371 00000C38 AA stosb 2372 2373 00000C39 A1[A06E] mov ax, [total_sectors] 2374 00000C3C 8B16[A26E] mov dx, [total_sectors+2] 2375 00000C40 B90002 mov cx, 512 2376 00000C43 E8FE01 call mul32 2377 00000C46 A3[A86E] mov [file_size], ax 2378 00000C49 8916[AA6E] mov [file_size+2], dx 2379 2380 00000C4D BF[D656] mov di, str_file_size 2381 2382 00000C50 89E5 mov bp, sp 2383 00000C52 B90A00 mov cx, 10 2384 B_16: 2385 00000C55 E8DE01 call div32 2386 2387 00000C58 80C330 add bl, '0' 2388 00000C5B 53 push bx 2389 00000C5C 21C0 and ax, ax 2390 00000C5E 75F5 jnz short B_16 2391 00000C60 21D2 and dx, dx 2392 00000C62 75F1 jnz short B_16 2393 2394 00000C64 29E5 sub bp, sp 2395 00000C66 D1ED shr bp, 1 2396 B_17: 2397 00000C68 58 pop ax 2398 00000C69 AA stosb 2399 00000C6A 4D dec bp 2400 00000C6B 75FB jnz short B_17 2401 2402 00000C6D 30C0 xor al, al 2403 00000C6F AA stosb 2404 2405 00000C70 B00D mov al, 13 ; ENTER (Carriage Return) key 2406 B_18: 2407 00000C72 50 push ax 2408 2409 00000C73 C606[B76E]00 mov byte [chs_focus], 0 2410 00000C78 E81613 call display_chs_table 2411 2412 00000C7B 58 pop ax 2413 2414 00000C7C 3C0D cmp al, 13 ; CR ? 2415 00000C7E 7402 je short B_20 ; print total sectors and file size.. 2416 B_19: 2417 00000C80 CD20 int 20h 2418 B_20: 2419 00000C82 BE[7D56] mov si, msg_disk_sectors 2420 00000C85 E8C111 call print_msg 2421 00000C88 BE[9356] mov si, str_disk_sectors 2422 00000C8B E8BB11 call print_msg 2423 00000C8E BE[6756] mov si, CRLF 2424 00000C91 E8B511 call print_msg 2425 00000C94 BE[C056] mov si, msg_file_size 2426 00000C97 E8AF11 call print_msg 2427 00000C9A BE[D656] mov si, str_file_size 2428 00000C9D E8A911 call print_msg 2429 00000CA0 BE[E156] mov si, msg_bytes 2430 00000CA3 E8A311 call print_msg 2431 00000CA6 BE[EA56] mov si, msg_enter_cancel 2432 00000CA9 E89D11 call print_msg 2433 00000CAC 30E4 xor ah, ah 2434 00000CAE CD16 int 16h 2435 00000CB0 3C1B cmp al, 1Bh ; ESC key 2436 00000CB2 74CC je short B_19 2437 00000CB4 3C0D cmp al, 0Dh ; Enter key 2438 00000CB6 0F85DCFE jne B_05 2439 2440 00000CBA 833E[A26E]00 cmp word [total_sectors+2], 0 2441 00000CBF 0F879501 ja B_42 2442 2443 00000CC3 813E[A06E]003F cmp word [total_sectors], 16128 ; 63*16*16 2444 00000CC9 0F838B01 jnb B_42 2445 2446 00000CCD BE[C645] mov si, msg_min_8mb_disk 2447 00000CD0 E87611 call print_msg 2448 2449 00000CD3 30E4 xor ah, ah 2450 00000CD5 CD16 int 16h 2451 2452 00000CD7 E9BCFE jmp B_05 2453 2454 B_21: 2455 00000CDA 3C20 cmp al, 20h 2456 00000CDC 745A je short B_25 2457 00000CDE 3C2D cmp al, '-' 2458 00000CE0 0F84E200 je B_34 2459 00000CE4 3C2B cmp al, '+' 2460 00000CE6 7450 je short B_25 2461 00000CE8 80FC51 cmp ah, 51h ; Pg Down 2462 00000CEB 7416 je short B_23 2463 00000CED 80FC49 cmp ah, 49h ; Pg Up 2464 00000CF0 742F je short B_24 2465 B_22: 2466 00000CF2 803E[B76E]00 cmp byte [chs_focus], 0 2467 00000CF7 0F869EFE jna B_06 2468 00000CFB C606[B76E]00 mov byte [chs_focus], 0 2469 00000D00 E993FE jmp B_05 2470 B_23: 2471 00000D03 803E[B76E]43 cmp byte [chs_focus], 'C' 2472 ;jne short B_22 2473 00000D08 0F85BA00 jne B_34 ; 10/02/2019 2474 00000D0C 832E[AE40]10 sub word [cylinders], 16 2475 00000D11 0F82C500 jc B_35 2476 00000D15 833E[AE40]10 cmp word [cylinders], 16 2477 00000D1A 0F82BC00 jb B_35 2478 00000D1E E975FE jmp B_05 2479 B_24: 2480 00000D21 803E[B76E]43 cmp byte [chs_focus], 'C' 2481 ;jne short B_22 2482 00000D26 752E jne short B_27 ; 10/02/2019 2483 00000D28 8306[AE40]10 add word [cylinders], 16 2484 00000D2D 813E[AE40]0004 cmp word [cylinders], 1024 2485 00000D33 7718 ja short B_26 2486 00000D35 E95EFE jmp B_05 2487 B_25: 2488 00000D38 803E[B76E]43 cmp byte [chs_focus], 'C' 2489 00000D3D 7517 jne short B_27 2490 00000D3F FF06[AE40] inc word [cylinders] 2491 00000D43 813E[AE40]0004 cmp word [cylinders], 1024 2492 00000D49 0F8649FE jna B_05 2493 B_26: 2494 00000D4D C706[AE40]1000 mov word [cylinders], 16 ; minimum cylinders 2495 00000D53 E940FE jmp B_05 2496 B_27: 2497 00000D56 803E[B76E]48 cmp byte [chs_focus], 'H' 2498 00000D5B 7547 jne short B_32 2499 00000D5D 833E[AC40]10 cmp word [heads], 16 2500 00000D62 7307 jnb short B_28 2501 00000D64 FF06[AC40] inc word [heads] 2502 00000D68 E92BFE jmp B_05 2503 B_28: 2504 00000D6B 833E[AA40]3F cmp word [sectors], 63 2505 00000D70 7212 jb short B_29 2506 00000D72 833E[AC40]20 cmp word [heads], 32 2507 00000D77 7722 ja short B_31 2508 00000D79 7217 jb short B_30 2509 00000D7B C706[AC40]4000 mov word [heads], 64 2510 00000D81 E912FE jmp B_05 2511 B_29: 2512 00000D84 833E[AC40]10 cmp word [heads], 16 2513 00000D89 7310 jnb short B_31 2514 00000D8B FF06[AC40] inc word [heads] 2515 00000D8F E904FE jmp B_05 2516 B_30: 2517 00000D92 C706[AC40]2000 mov word [heads], 32 2518 00000D98 E9FBFD jmp B_05 2519 B_31: 2520 00000D9B C706[AC40]0200 mov word [heads], 2 2521 00000DA1 E9F2FD jmp B_05 2522 B_32: 2523 00000DA4 803E[B76E]53 cmp byte [chs_focus], 'S' 2524 00000DA9 0F85E9FD jne B_05 2525 00000DAD 833E[AA40]3F cmp word [sectors], 63 2526 00000DB2 7509 jne short B_33 2527 00000DB4 C706[AA40]1100 mov word [sectors], 17 2528 00000DBA E9D9FD jmp B_05 2529 B_33: 2530 00000DBD C706[AA40]3F00 mov word [sectors], 63 2531 00000DC3 E9D0FD jmp B_05 2532 B_34: 2533 00000DC6 803E[B76E]43 cmp byte [chs_focus], 'C' 2534 00000DCB 7516 jne short B_36 2535 00000DCD FF0E[AE40] dec word [cylinders] 2536 00000DD1 833E[AE40]10 cmp word [cylinders], 16 2537 00000DD6 0F83BCFD jnb B_05 2538 B_35: 2539 00000DDA C706[AE40]0004 mov word [cylinders], 1024 2540 00000DE0 E9B3FD jmp B_05 2541 B_36: 2542 00000DE3 803E[B76E]48 cmp byte [chs_focus], 'H' 2543 00000DE8 75BA jne short B_32 2544 2545 00000DEA 833E[AA40]3F cmp word [sectors], 63 2546 00000DEF 721E jb short B_38 2547 2548 00000DF1 833E[AC40]02 cmp word [heads], 2 2549 00000DF6 760E jna short B_37 2550 00000DF8 833E[AC40]10 cmp word [heads], 16 2551 00000DFD 771E ja short B_39 2552 00000DFF FF0E[AC40] dec word [heads] 2553 00000E03 E990FD jmp B_05 2554 B_37: 2555 00000E06 C706[AC40]4000 mov word [heads], 64 2556 00000E0C E987FD jmp B_05 2557 B_38: 2558 00000E0F 833E[AC40]02 cmp word [heads], 2 2559 00000E14 760E jna short B_40 2560 00000E16 FF0E[AC40] dec word [heads] 2561 00000E1A E979FD jmp B_05 2562 B_39: 2563 00000E1D 833E[AC40]20 cmp word [heads], 32 2564 00000E22 7709 ja short B_41 2565 B_40: 2566 00000E24 C706[AC40]1000 mov word [heads], 16 2567 00000E2A E969FD jmp B_05 2568 B_41: 2569 00000E2D C706[AC40]2000 mov word [heads], 32 2570 00000E33 E960FD jmp B_05 2571 2572 ;----------------------------------------------------------------------------- 2573 2574 div32: 2575 ; DX_AX/CX 2576 ; Result: DX_AX, BX (remainder) 2577 00000E36 89C3 mov bx, ax 2578 ;or dx, ax ; * DX_AX = 0 ? 2579 ;jz short div32_retn ; yes, do not divide! 2580 00000E38 89D0 mov ax, dx 2581 00000E3A 31D2 xor dx, dx 2582 00000E3C F7F1 div cx ; at first, divide DX 2583 ; remainder is in DX 2584 00000E3E 93 xchg ax, bx ; now quotient is in BX 2585 ; and initial AX value is in AX 2586 00000E3F F7F1 div cx ; now, DX_AX has been divided and 2587 ; AX has quotient 2588 ; DX has remainder 2589 00000E41 87D3 xchg dx, bx ; finally, BX has remainder 2590 ;div32_retn: 2591 00000E43 C3 retn 2592 2593 ;----------------------------------------------------------------------------- 2594 2595 mul32: 2596 ; DX_AX*CX 2597 ; Result: BX_DX_AX 2598 00000E44 51 push cx 2599 00000E45 89D3 mov bx, dx 2600 00000E47 F7E1 mul cx 2601 00000E49 93 xchg ax, bx 2602 00000E4A 52 push dx 2603 00000E4B F7E1 mul cx 2604 00000E4D 59 pop cx 2605 00000E4E 01C8 add ax, cx 2606 00000E50 83D200 adc dx, 0 2607 00000E53 93 xchg bx, ax 2608 00000E54 87D3 xchg dx, bx 2609 00000E56 59 pop cx 2610 00000E57 C3 retn 2611 2612 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2613 ; Create a new hard disk image file 2614 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2615 2616 B_42: 2617 00000E58 BA[9959] mov dx, img_file_name 2618 00000E5B B90000 mov cx, 0 ; File Attributes 2619 00000E5E B43C mov ah, 3Ch ; MS-DOS Function = Create File 2620 00000E60 CD21 int 21h 2621 00000E62 0F8222F2 jc A_10 2622 2623 00000E66 BE[6756] mov si, CRLF 2624 00000E69 E8DD0F call print_msg 2625 2626 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2627 ; Open image file for writing 2628 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2629 2630 00000E6C B002 mov al, 2 ; open for reading and writing 2631 ;mov dx, img_file_name 2632 00000E6E B43D mov ah, 3Dh ; open file 2633 00000E70 CD21 int 21h 2634 00000E72 0F82BD0F jc D_02 2635 2636 00000E76 A3[A840] mov [img_file_handle], ax 2637 2638 00000E79 BE[1B55] mov si, msg_writing_mbr 2639 00000E7C E8CA0F call print_msg 2640 2641 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2642 ; Writing/Saving CHS parameters into (Singlix FS1) MBR 2643 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2644 ; Note: Partition Table will be left empty at this stage 2645 2646 ;cmp word [TRDOS386_MASTERBOOT_SECTOR+417], 417 2647 ;jne short B_43 2648 2649 00000E7F 8B0E[AE40] mov cx, [cylinders] 2650 00000E83 890E[3A34] mov [TRDOS386_MASTERBOOT_SECTOR+420], cx ; pt_cylinders 2651 00000E87 8B0E[AC40] mov cx, [heads] 2652 00000E8B 890E[3C34] mov [TRDOS386_MASTERBOOT_SECTOR+422], cx ; pt_heads 2653 00000E8F 8B0E[AA40] mov cx, [sectors] 2654 00000E93 890E[3E34] mov [TRDOS386_MASTERBOOT_SECTOR+424], cx ; pt_sectors 2655 2656 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2657 ; writing masterboot sector 2658 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2659 2660 B_43: 2661 00000E97 8B1E[A840] mov bx, [img_file_handle] 2662 00000E9B BA[9632] mov dx, TRDOS386_MASTERBOOT_SECTOR ; Singlix FS1 MBR 2663 00000E9E B90002 mov cx, 512 2664 00000EA1 B440 mov ah, 40h ; write to file 2665 00000EA3 CD21 int 21h 2666 00000EA5 0F82800F jc D_01 2667 2668 00000EA9 BE[6356] mov si, Msg_OK 2669 00000EAC E89A0F call print_msg 2670 2671 00000EAF BE[3855] mov si, msg_writing_disk_sectors 2672 00000EB2 E8940F call print_msg 2673 00000EB5 B403 mov ah, 3 2674 00000EB7 BB0700 mov bx, 7 2675 00000EBA CD10 int 10h ; Return Cursor Position 2676 ; DL = Column, DH = Line 2677 00000EBC 8916[AB55] mov [Cursor_Pos], dx 2678 2679 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2680 ; writing disk sectors (with F6h -format- bytes) 2681 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2682 2683 00000EC0 31D2 xor dx, dx 2684 00000EC2 B80100 mov ax, 1 2685 2686 ; 63 (17) sectors (after MBR) will be filled with ZERO 2687 B_44: 2688 00000EC5 52 push dx 2689 00000EC6 50 push ax 2690 00000EC7 BE[A955] mov si, Sector_Str + 6 2691 00000ECA E80410 call bin_to_decimal 2692 00000ECD 8B16[AB55] mov dx, [Cursor_Pos] 2693 00000ED1 BB0700 mov bx, 7 2694 00000ED4 B402 mov ah, 2 2695 00000ED6 CD10 int 10h ; Set Cursor Position 2696 00000ED8 E86E0F call print_msg 2697 00000EDB 58 pop ax 2698 00000EDC 5A pop dx 2699 00000EDD BB[246A] mov bx, HDFORMAT_FATBUFFER ; Empty Sector 2700 00000EE0 E8750F call write_hd_sector 2701 00000EE3 0F82420F jc D_01 2702 ;inc ax 2703 00000EE7 FEC0 inc al 2704 00000EE9 3B06[AA40] cmp ax, [sectors] ; 63 or 17 2705 00000EED 76D6 jna short B_44 2706 2707 ; writing other sectors upto [total sectors] - 1 2708 B_45: 2709 00000EEF 52 push dx 2710 00000EF0 50 push ax 2711 00000EF1 BE[A955] mov si, Sector_Str + 6 2712 00000EF4 E8DA0F call bin_to_decimal 2713 00000EF7 8B16[AB55] mov dx, [Cursor_Pos] 2714 00000EFB BB0700 mov bx, 7 2715 00000EFE B402 mov ah, 2 2716 00000F00 CD10 int 10h ; Set Cursor Position 2717 00000F02 E8440F call print_msg 2718 00000F05 58 pop ax 2719 00000F06 5A pop dx 2720 00000F07 BB[2266] mov bx, HDFORMAT_SECBUFFER ; F6h filled sectors 2721 00000F0A E84B0F call write_hd_sector 2722 00000F0D 0F82180F jc D_01 2723 00000F11 83C001 add ax, 1 2724 00000F14 83D200 adc dx, 0 2725 00000F17 3B16[A26E] cmp dx, [total_sectors+2] 2726 00000F1B 72D2 jb short B_45 2727 00000F1D 7706 ja short B_46 2728 00000F1F 3B06[A06E] cmp ax, [total_sectors] 2729 00000F23 72CA jb short B_45 2730 B_46: 2731 00000F25 BE[6056] mov si, Msg_3dot_OK 2732 00000F28 E81E0F call print_msg 2733 2734 00000F2B BE[2946] mov si, msg_any_key_esc_exit 2735 00000F2E E8180F call print_msg 2736 2737 00000F31 30E4 xor ah, ah 2738 00000F33 CD16 int 16h 2739 2740 00000F35 3C1B cmp al, 27 ; 1Bh, ESC key 2741 00000F37 7508 jne short B_48 2742 B_47: 2743 00000F39 BE[6756] mov si, CRLF 2744 00000F3C E80A0F call print_msg 2745 2746 00000F3F CD20 int 20h 2747 B_48: 2748 00000F41 FE06[B040] inc byte [random] ; next r/w is not sequental 2749 00000F45 FE06[B140] inc byte [newdisk] ; will be used by partitioning 2750 2751 ; 11/02/2019 2752 ; Copy Singlix FS (TRDOS 386) MBR to MasterBoot buffer 2753 00000F49 B90001 mov cx, 256 2754 00000F4C BE[9632] mov si, TRDOS386_MASTERBOOT_SECTOR ; Singlix FS1 MBR 2755 00000F4F BF[4057] mov di, MasterBootBuff 2756 00000F52 F3A5 rep movsw 2757 2758 ; 26/02/2019 2759 ; Clear partition table structure 2760 ; (for preventing wrong partition data display for new disk image) 2761 00000F54 BF[5E71] mov di, part_table_boot_ind 2762 00000F57 31C0 xor ax, ax 2763 00000F59 B92400 mov cx, 4*18/2 2764 00000F5C F3AB rep stosw 2765 2766 ; 08/03/2019 2767 ; Clear pcount, epnumber values 2768 00000F5E A3[A671] mov [pcount], ax ; reset (pcount & ppcount) 2769 00000F61 A3[A871] mov [apcount], ax ; reset (apcount & epnumber) 2770 B_49: 2771 ; 06/03/2019 2772 00000F64 C606[C26E]4D mov byte [pSize_unit], 'M' ; default (for 'whole' disk/space) 2773 ; 15/02/2019 2774 00000F69 E830F8 call create_partition_input 2775 B_50: 2776 00000F6C 21C0 and ax, ax 2777 ;jz short B_47 ; 0 = none or not a valid input 2778 00000F6E 0F84A5F4 jz A_48 ; 25/02/2019 2779 2780 ;or ah, ah 2781 ;jz short B_51 2782 2783 ; 23/02/2019 2784 00000F72 80FC04 cmp ah, 4 ; user's partition type input ? 2785 00000F75 7505 jne short B_51 ; no 2786 2787 ; user type input 2788 00000F77 A2[B66E] mov [pp_type_user], al 2789 00000F7A 88E0 mov al, ah ; mov al, 4 2790 B_51: 2791 00000F7C A2[B56E] mov [pp_type], al 2792 2793 ; clear screen 2794 00000F7F B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 2795 00000F82 CD10 int 10h 2796 2797 00000F84 A0[B56E] mov al, [pp_type] 2798 00000F87 3C01 cmp al, 1 2799 00000F89 7705 ja short B_52 2800 2801 00000F8B BE[0C49] mov si, msg_create_dos_partition_h ; header 2802 00000F8E EB69 jmp short B_57 2803 B_52: 2804 00000F90 3C05 cmp al, 5 2805 00000F92 7262 jb short B_56 2806 ;ja short B_55 2807 00000F94 7741 ja short B_106 ; 26/10/2020 2808 2809 ; 23/02/2019 2810 00000F96 BE[014A] mov si, msg_create_ext_partition_h 2811 00000F99 E8AD0E call print_msg 2812 2813 ; 24/02/2019 2814 00000F9C 803E[A971]00 cmp byte [epnumber], 0 2815 00000FA1 7613 jna short B_53 2816 2817 00000FA3 BE[E360] mov si, msg_ext_partition_exists 2818 00000FA6 E8A00E call print_msg 2819 2820 00000FA9 BE[2057] mov si, msg_press_any_key 2821 00000FAC E89A0E call print_msg 2822 2823 00000FAF 30E4 xor ah, ah 2824 00000FB1 CD16 int 16h 2825 2826 ;jmp A_33 2827 00000FB3 E961F4 jmp A_48 2828 B_53: 2829 00000FB6 803E[A771]00 cmp byte [ppcount], 0 ; primary partition count 2830 00000FBB 773F ja short B_58 2831 2832 ; 09/02/2019 2833 00000FBD BE[8850] mov si, msg_ext_partition_error 2834 00000FC0 E8860E call print_msg 2835 B_54: 2836 00000FC3 BE[2057] mov si, msg_press_any_key 2837 00000FC6 E8800E call print_msg 2838 2839 00000FC9 30E4 xor ah, ah 2840 00000FCB CD16 int 16h 2841 2842 00000FCD C606[B56E]01 mov byte [pp_type], 1 2843 2844 00000FD2 E8F2F7 call cpi_2 ; 15/02/2019 2845 00000FD5 EB95 jmp B_50 2846 B_106: 2847 ; 26/10/2020 2848 00000FD7 803E[A771]00 cmp byte [ppcount], 0 ; primary partition count 2849 00000FDC 760A jna short B_55 2850 00000FDE 803E[A971]00 cmp byte [epnumber], 0 2851 ; is there an extended partition ? 2852 00000FE3 7603 jna short B_55 2853 00000FE5 E9B2F4 jmp create_logical_drives 2854 B_55: 2855 00000FE8 BE[F64A] mov si, msg_create_logical_drive_h 2856 00000FEB E85B0E call print_msg 2857 2858 00000FEE BE[C750] mov si, msg_logical_drive_error 2859 00000FF1 E8550E call print_msg 2860 00000FF4 EBCD jmp short B_54 2861 2862 ; mov si, msg_use_entire_ep_space 2863 ; jmp short B_60 2864 2865 B_56: 2866 00000FF6 BE[EB4B] mov si, msg_create_nondos_partition_h 2867 B_57: 2868 00000FF9 E84D0E call print_msg 2869 B_58: 2870 ; 15/02/2019 2871 00000FFC 803E[B140]00 cmp byte [newdisk], 0 2872 00001001 7705 ja short B_59 2873 2874 00001003 BE[204F] mov si, msg_use_all_space 2875 00001006 EB03 jmp short B_60 2876 B_59: 2877 00001008 BE[F94E] mov si, msg_use_whole_disk ; partition size: whole disk 2878 B_60: 2879 0000100B E83B0E call print_msg 2880 B_61: 2881 0000100E 30E4 xor ah, ah 2882 00001010 CD16 int 16h 2883 2884 00001012 3C1B cmp al, 27 ; ESCAPE key 2885 ;;je B_47 2886 ;je A_33 2887 00001014 0F84FFF3 je A_48 ; 25/02/2019 2888 00001018 24DF and al, 0DFh 2889 0000101A 3C4E cmp al, 'N' 2890 0000101C 740D je short B_62 ;02/03/2019 2891 0000101E 3C59 cmp al, 'Y' 2892 00001020 75EC jne short B_61 2893 2894 00001022 FE06[B46E] inc byte [wholedisk] 2895 2896 ; 02/03/2019 2897 00001026 BE[0A5E] mov si, _msg_YES 2898 ;call print_msg 2899 00001029 EB03 jmp short B_63 2900 B_62: 2901 0000102B BE[105E] mov si, _msg_NO 2902 B_63: ; 06/03/2019 2903 0000102E E8180E call print_msg 2904 2905 ; 15/02/2019 2906 00001031 29DB sub bx, bx 2907 00001033 381E[B140] cmp byte [newdisk], bl ; 0 2908 00001037 7708 ja short B_64 ; 23/02/2019 2909 00001039 381E[B46E] cmp byte [wholedisk], bl ; 0 2910 0000103D 0F870E01 ja B_75 ; 23/02/2019 2911 B_64: 2912 ; 08/02/2019 2913 ;sub bx, bx 2914 00001041 A1[A06E] mov ax, [total_sectors] 2915 00001044 8B16[A26E] mov dx, [total_sectors+2] 2916 00001048 2B06[AA40] sub ax, [sectors] 2917 0000104C 19DA sbb dx, bx ; sbb dx, 0 2918 2919 0000104E A3[B06E] mov [pp_Sectors], ax ; = [total_sectors] - [sectors] 2920 00001051 8916[B26E] mov [pp_Sectors+2], dx ; = [total_sectors+2] - carry bit 2921 B_65: 2922 00001055 381E[B46E] cmp byte [wholedisk], bl ; 0 2923 00001059 0F87F900 ja B_76 ; 09/02/2019 2924 B_66: 2925 ; clear screen 2926 0000105D B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 2927 00001060 CD10 int 10h 2928 2929 00001062 BE[0C49] mov si, msg_create_dos_partition_h ; header 2930 00001065 E8E10D call print_msg 2931 00001068 BE[9D4D] mov si, msg_create_dos_partition_s ; size options 2932 0000106B E8DB0D call print_msg 2933 B_67: 2934 0000106E 30E4 xor ah, ah 2935 00001070 CD16 int 16h 2936 2937 ; 24/02/2019 2938 00001072 3C1B cmp al, 27 ; ESCAPE key 2939 00001074 0F849FF3 je A_48 ; Cancel 2940 2941 00001078 3C20 cmp al, 32 ; SPACE key 2942 0000107A 751F jne short B_69 2943 2944 ; Entire space 2945 0000107C A1[B06E] mov ax, [pp_Sectors] 2946 0000107F 8B16[B26E] mov dx, [pp_Sectors+2] 2947 2948 00001083 C606[B46E]01 mov byte [wholedisk], 1 ; 09/02/2019 2949 00001088 EB58 jmp short B_71 2950 2951 B_68: 2952 ; ZERO partition size message 2953 0000108A BE[1D5C] mov si, msg_zero_partition_size 2954 0000108D E8B90D call print_msg 2955 2956 00001090 30E4 xor ah, ah 2957 00001092 CD16 int 16h 2958 00001094 3C1B cmp al, 27 ; ESCAPE key 2959 00001096 75C5 jne short B_66 ; Retry 2960 2961 00001098 E99EFE jmp B_47 ; exit 2962 2963 B_69: 2964 0000109B C606[C26E]25 mov byte [pSize_unit], '%' 2965 000010A0 3C25 cmp al, '%' 2966 000010A2 7422 je short B_70 2967 000010A4 C606[C26E]53 mov byte [pSize_unit], 'S' 2968 000010A9 3C0D cmp al, 13 ; 0Dh, Carriage Return key 2969 000010AB 7419 je short B_70 2970 000010AD 24DF and al, 0DFh 2971 000010AF 3C53 cmp al, 'S' 2972 000010B1 7413 je short B_70 2973 000010B3 A2[C26E] mov [pSize_unit], al 2974 000010B6 3C4B cmp al, 'K' 2975 000010B8 740C je short B_70 2976 000010BA 3C4D cmp al, 'M' 2977 000010BC 7408 je short B_70 2978 000010BE 3C47 cmp al, 'G' 2979 000010C0 7404 je short B_70 2980 000010C2 3C43 cmp al, 'C' 2981 000010C4 75A8 jne short B_67 2982 B_70: 2983 000010C6 C606[0766]73 mov byte [msg_sectors_crlf_s], 's' ; " sectors" 2984 2985 000010CB E8C20F call partition_size_input 2986 ;jc B_47 ; exit if partition size input is 0 2987 000010CE 72BA jc short B_68 2988 2989 000010D0 21DB and bx, bx ; bx_dx_ax = partition size 2990 ;jnz short B_77 2991 ; 23/02/2019 2992 000010D2 7540 jnz short B_72 ; invalid! (use maximum available sectors) 2993 2994 ; 08/02/2019 2995 000010D4 09D2 or dx, dx 2996 000010D6 750A jnz short B_71 ; proper size (for now) 2997 2998 000010D8 8B1E[DA6E] mov bx, [min_sectors] ; minimum sectors 2999 000010DC 39C3 cmp bx, ax 3000 000010DE 7602 jna short B_71 ; proper size (for now) 3001 3002 ; invalid! (use minimum sectors or sectors per cylinder) 3003 000010E0 89D8 mov ax, bx 3004 B_71: 3005 ; 09/02/2019 3006 ; save dx,ax 3007 000010E2 8916[E26E] mov [ppn_Sectors+2], dx 3008 000010E6 A3[E06E] mov [ppn_Sectors], ax 3009 3010 ; write partition size 3011 ;push dx 3012 ;push ax 3013 000010E9 BE[CF6E] mov si, msg_partition_sectors + 7 ; max. 7 digits 3014 000010EC E8E20D call bin_to_decimal 3015 ; ds:si = beginning of decimal number text 3016 000010EF E8570D call print_msg 3017 000010F2 BE[0066] mov si, msg_sectors_crlf 3018 000010F5 E8510D call print_msg 3019 ;pop ax 3020 ;pop dx 3021 3022 000010F8 803E[B46E]00 cmp byte [wholedisk], 0 3023 000010FD 775E ja short B_77 ; 09/02/2019 3024 3025 ; restore ax,dx 3026 000010FF A1[E06E] mov ax, [ppn_Sectors] 3027 00001102 8B16[E26E] mov dx, [ppn_Sectors+2] 3028 3029 ; select whole disk 3030 ; if partition size > disk size 3031 00001106 3B16[B26E] cmp dx, [pp_Sectors+2] 3032 0000110A 7708 ja short B_72 3033 0000110C 724F jb short B_77 3034 0000110E 3B06[B06E] cmp ax, [pp_Sectors] 3035 00001112 7649 jna short B_77 3036 B_72: 3037 00001114 803E[B140]00 cmp byte [newdisk], 0 3038 00001119 7667 jna short B_78 3039 3040 ; "use whole disk or go to back" question 3041 0000111B BE[1E50] mov si, msg_partition_size_overs 3042 B_73: 3043 0000111E E8280D call print_msg 3044 B_74: 3045 00001121 30E4 xor ah, ah 3046 00001123 CD16 int 16h 3047 3048 00001125 3C1B cmp al, 27 ; ESCAPE key 3049 ;je B_49 3050 00001127 0F8432FF je B_66 ; 09/02/2019 3051 0000112B 3C0D cmp al, 13 ; ENTER (Carriage Return) key 3052 0000112D 75F2 jne short B_74 3053 3054 0000112F FE06[B46E] inc byte [wholedisk] 3055 3056 ; 24/02/2019 3057 00001133 803E[B140]00 cmp byte [newdisk], 0 3058 00001138 7715 ja short B_75 3059 3060 0000113A 8B1E[4472] mov bx, [c_fspc_offset] 3061 0000113E 8B87[FA71] mov ax, [free_space.sectors_unused+bx] 3062 00001142 8B97[FC71] mov dx, [free_space.sectors_unused+bx+2] 3063 00001146 A3[B06E] mov [pp_Sectors], ax 3064 00001149 8916[B26E] mov [pp_Sectors+2], dx 3065 0000114D EB07 jmp short B_76 3066 B_75: 3067 ; 09/02/2019 3068 0000114F 8B16[B26E] mov dx, [pp_Sectors+2] 3069 00001153 A1[B06E] mov ax, [pp_Sectors] 3070 B_76: 3071 00001156 8916[E26E] mov [ppn_Sectors+2], dx 3072 0000115A A3[E06E] mov [ppn_Sectors], ax 3073 B_77: 3074 0000115D 803E[B56E]05 cmp byte [pp_type], 5 3075 00001162 0F853601 jne B_99 3076 3077 00001166 803E[A771]00 cmp byte [ppcount], 0 ; primary partition count 3078 0000116B 0F87C500 ja B_93 3079 3080 0000116F BE[8850] mov si, msg_ext_partition_error 3081 00001172 E8D40C call print_msg 3082 00001175 BE[0150] mov si, msg_any_key_to_retry 3083 00001178 E8CE0C call print_msg 3084 3085 ; 09/02/2019 3086 0000117B 30E4 xor ah, ah 3087 0000117D CD16 int 16h 3088 3089 ;jmp B_49 3090 0000117F E945F6 jmp cpi_2 3091 3092 B_78: 3093 ; clear screen 3094 00001182 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 3095 00001185 CD10 int 10h 3096 3097 00001187 BE[0C49] mov si, msg_create_dos_partition_h ; header 3098 0000118A E8BC0C call print_msg 3099 3100 0000118D BE[CF5F] mov si, msg_partition_size_limit 3101 00001190 E8B60C call print_msg 3102 3103 00001193 8B1E[4472] mov bx, [c_fspc_offset] 3104 3105 00001197 803E[C26E]53 cmp byte [pSize_unit], 'S' 3106 0000119C 7415 je short B_79 3107 0000119E 803E[C26E]4B cmp byte [pSize_unit], 'K' 3108 000011A3 740E je short B_79 3109 3110 000011A5 803E[C26E]25 cmp byte [pSize_unit], '%' 3111 000011AA 7469 je short B_89 3112 3113 000011AC 803E[C26E]43 cmp byte [pSize_unit], 'C' 3114 000011B1 7479 je B_92 3115 B_79: 3116 ; 'S', 'K' 3117 000011B3 81C3[FA71] add bx, free_space.sectors_unused 3118 000011B7 8B07 mov ax, [bx] 3119 000011B9 8B5702 mov dx, [bx+2] 3120 3121 000011BC B90A00 mov cx, 10 3122 000011BF 89E5 mov bp, sp 3123 B_80: 3124 000011C1 E872FC call div32 3125 000011C4 53 push bx 3126 000011C5 09D2 or dx, dx 3127 000011C7 75F8 jnz short B_80 3128 000011C9 83F809 cmp ax, 9 3129 000011CC 77F3 ja short B_80 3130 B_81: 3131 000011CE BB0700 mov bx, 07h 3132 000011D1 09C0 or ax, ax 3133 000011D3 7501 jnz short B_83 3134 B_82: 3135 000011D5 58 pop ax 3136 B_83: 3137 000011D6 0430 add al, '0' 3138 B_84: 3139 000011D8 B40E mov ah, 0Eh 3140 ;mov bx, 07h 3141 000011DA CD10 int 10h ; write character (as tty) 3142 3143 000011DC 39EC cmp sp, bp 3144 000011DE 72F5 jb short B_82 3145 3146 000011E0 803E[C26E]53 cmp byte [pSize_unit], 'S' 3147 000011E5 7422 je short B_86 3148 000011E7 803E[C26E]4B cmp byte [pSize_unit], 'K' 3149 000011EC 741B je short B_86 3150 3151 000011EE 803E[C26E]25 cmp byte [pSize_unit], '%' 3152 000011F3 7508 jne short B_85 3153 3154 ; 24/02/2019 3155 000011F5 3C25 cmp al, '%' 3156 000011F7 7416 je short B_88 3157 000011F9 B025 mov al, '%' 3158 000011FB EBDB jmp short B_84 3159 B_85: 3160 000011FD 803E[C26E]43 cmp byte [pSize_unit], 'C' 3161 00001202 7505 jne short B_86 3162 3163 00001204 BE[6B60] mov si, msg_cylinders 3164 00001207 EB03 jmp short B_87 3165 B_86: 3166 00001209 BE[7660] mov si, msg_sectors 3167 B_87: 3168 0000120C E83A0C call print_msg 3169 B_88: 3170 0000120F BE[1C60] mov si, msg_partition_size_limit_r 3171 ;call print_msg 3172 3173 00001212 E909FF jmp B_73 3174 3175 B_89: 3176 ; '%' 3177 00001215 81C3[F871] add bx, free_space.percent_unused 3178 00001219 8B07 mov ax, [bx] 3179 B_90: 3180 0000121B 89E5 mov bp, sp 3181 B_91: 3182 0000121D 31D2 xor dx, dx 3183 0000121F B90A00 mov cx, 10 3184 00001222 F7F1 div cx 3185 00001224 52 push dx 3186 00001225 83F809 cmp ax, 9 3187 00001228 77F3 ja short B_91 3188 0000122A EBA2 jmp short B_81 3189 B_92: 3190 ; 'C' 3191 0000122C 81C3[F271] add bx, free_space.space 3192 00001230 8B07 mov ax, [bx] 3193 00001232 EBE7 jmp short B_90 3194 3195 B_93: 3196 ; 23/02/2019 3197 00001234 8B1E[4472] mov bx, [c_fspc_offset] 3198 00001238 8B87[F471] mov ax, [bx+free_space.start] 3199 3200 ; set free space start cylinder to 1 if it is 0 3201 0000123C 09C0 or ax, ax 3202 0000123E 750F jnz short B_94 3203 3204 00001240 B005 mov al, 5 ; Get free space for extended partition 3205 00001242 E89614 call find_part_free_space 3206 3207 00001245 891E[4472] mov [c_fspc_offset], bx 3208 3209 00001249 21C9 and cx, cx 3210 0000124B 0F843AF2 jz cp_4 ; there is not free space on disk 3211 B_94: 3212 ; 24/02/2019 3213 0000124F E81100 call partition_size_fixup_x 3214 00001252 0F822CFF jc B_78 3215 3216 ; 16/02/2019 3217 00001256 E8F8F7 call create_extended_partition 3218 ; must be called after 'find_part_free_space'. 3219 ; 24/02/2019 3220 00001259 E8EE10 call show_selected_partition 3221 0000125C E9BE00 jmp C_02 3222 3223 partition_size_fixup: 3224 ; 24/02/2019 3225 0000125F 8B1E[4472] mov bx, [c_fspc_offset] 3226 partition_size_fixup_x: 3227 ; 25/02/2019 3228 00001263 803E[B140]00 cmp byte [newdisk], 0 3229 00001268 7731 ja short B_98 3230 3231 0000126A 81C3[FA71] add bx, free_space.sectors_unused 3232 0000126E 8B07 mov ax, [bx] 3233 00001270 8B5702 mov dx, [bx+2] 3234 3235 00001273 3B16[E26E] cmp dx, [ppn_Sectors+2] 3236 00001277 7222 jb short B_98 ; 24/02/2019 3237 00001279 7708 ja short B_95 3238 0000127B 3B06[E06E] cmp ax, [ppn_Sectors] 3239 0000127F 721A jb short B_98 ; 24/02/2019 3240 00001281 7411 je short B_97 3241 3242 B_95: 3243 ; 19/02/2019 3244 00001283 A1[E06E] mov ax, [ppn_Sectors] 3245 B_96: 3246 00001286 8B16[E26E] mov dx, [ppn_Sectors+2] 3247 3248 ; 18/02/2019 3249 3250 ; check for best fit 3251 ; (leave max. available space to next time if 3252 ; another space/gap fits to partition size request.) 3253 3254 0000128A E86816 call find_enough_free_sectors 3255 ; CX = Free space index (0 to 4) 3256 ; DX:AX = First available space which fits to request 3257 ;mov bx, cx 3258 ;shl bl, 4 ; * 16 ; * Free space structure size 3259 ;mov [c_fspc_offset], bx 3260 3261 ; 22/02/2019 3262 0000128D C0E104 shl cl, 4 3263 00001290 890E[4472] mov [c_fspc_offset], cx 3264 3265 ;add bx, free_space.sectors_unused 3266 ;mov ax, [bx] 3267 ;mov dx, [bx+2] 3268 B_97: 3269 ; Save max. available space 3270 00001294 A3[B06E] mov [pp_Sectors], ax 3271 00001297 8916[B26E] mov [pp_Sectors+2], dx 3272 B_98: 3273 0000129B C3 retn 3274 3275 B_99: 3276 ; 24/02/2019 3277 0000129C E8C0FF call partition_size_fixup 3278 0000129F 0F82DFFE jc B_78 3279 3280 ; 16/02/2019 3281 ; Force cylinder boundary alignment except 3282 ; sectors ('S') and kilobytes ('K') as sizing unit. 3283 3284 000012A3 C606[4672]59 mov byte [cylinder_boundary], 'Y' ; Default 3285 ; sizing unit is one of 3286 ; 'cylinders','megabytes','gigabytes' 3287 ; and boundary alignment is yes for them. 3288 000012A8 A0[C26E] mov al, [pSize_unit] 3289 3290 ;cmp byte [pSize_unit], 'S' ; Sectors 3291 000012AB 3C53 cmp al, 'S' 3292 000012AD 7404 je short B_100 3293 3294 ;cmp byte [pSize_unit], 'K' ; Kilobytes 3295 000012AF 3C4B cmp al, 'K' 3296 000012B1 752F jne short B_104 3297 B_100: 3298 ; Sizing unit is one of 'sectors' and/or 'kilobytes' 3299 ; and bound aligment will be applied if the answer will be yes. 3300 3301 000012B3 BE[1051] mov si, msg_cylinder_boundary_set 3302 000012B6 E8900B call print_msg 3303 B_101: 3304 000012B9 30E4 xor ah, ah 3305 000012BB CD16 int 16h 3306 ; Cylinder boundary adjusting 3307 000012BD 3C0D cmp al, 13 ; ENTER key 3308 000012BF 74F2 je short B_100 3309 000012C1 3C1B cmp al, 27 ; ESCAPE key 3310 000012C3 741A je short B_103 ; Align end of the partition only 3311 ; if start of the partition is aligned 3312 ; or it starts at cyl 0, head 1, sect 17 or 63. 3313 ; (End of the partition will be extended to 3314 ; end sector of it's last cylinder if the size 3315 ; will not over [pp_Sectors] value.) 3316 000012C5 24DF and al, 0DFh 3317 3318 ; 22/02/2019 3319 000012C7 3C59 cmp al, 'Y' 3320 000012C9 7508 jne short B_102 3321 3322 000012CB BE[0A5E] mov si, _msg_YES 3323 000012CE E8780B call print_msg 3324 3325 ;mov al, 'Y' 3326 ;jmp short B_103 3327 000012D1 EB0F jmp short B_104 3328 B_102: 3329 000012D3 3C4E cmp al, 'N' 3330 000012D5 75E2 jne short B_101 3331 3332 000012D7 BE[105E] mov si, _msg_NO 3333 000012DA E86C0B call print_msg 3334 3335 000012DD B04E mov al, 'N' 3336 ; do not align partition to cylinder boundary 3337 B_103: 3338 000012DF A2[4672] mov [cylinder_boundary], al 3339 B_104: 3340 000012E2 E832F5 call create_primary_partition 3341 3342 ; 18/02/2019 3343 000012E5 803E[B140]00 cmp byte [newdisk], 0 3344 000012EA 760E jna short B_105 3345 3346 000012EC 31C0 xor ax, ax ; 0 3347 000012EE 31D2 xor dx, dx ; 0 3348 ; DX_AX = Masterboot Sector = 0 3349 000012F0 BB[4057] mov bx, MasterBootBuff 3350 ; ES:BX = Sector Buffer 3351 000012F3 E8620B call write_hd_sector 3352 000012F6 0F822F0B jc D_01 3353 3354 B_105: 3355 ; DS:SI = Partition Table Entry address 3356 ; 25/02/2019 3357 000012FA 8936[6872] mov [pte_address], si ; save PTE address 3358 000012FE E84910 call show_selected_partition 3359 3360 ;jmp C_01 3361 3362 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3363 ; Format question 3364 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3365 3366 C_01: 3367 ;mov si, CRLF 3368 ;call print_msg 3369 3370 00001301 C606[D16E]01 mov byte [format_q], 1 3371 3372 00001306 A0[B56E] mov al, [pp_type] 3373 00001309 3C01 cmp al, 1 ; FAT12 (CHS) 3374 0000130B 741D je short C_03 3375 0000130D 3C04 cmp al, 4 ; FAT16 CHS 3376 0000130F 7419 je short C_03 3377 00001311 3C06 cmp al, 6 ; FAT16 BIG CHS 3378 00001313 7415 je short C_03 3379 00001315 3C0B cmp al, 0Bh ; FAT32 CHS 3380 00001317 7411 je short C_03 3381 00001319 3CA1 cmp al, 0A1h ; SINGLIX FS1 3382 0000131B 740D je short C_03 3383 3384 ;cmp al, 71h 3385 ;je short C_03 ; RETRO UNIX 386 3386 3387 ;dec byte [format_q] ; 0 3388 C_02: 3389 0000131D C606[D16E]00 mov byte [format_q], 0 ; 24/02/2019 3390 3391 ; NON-DOS partition! 3392 ; Ask for editing PT or exit (continue without formatting) 3393 00001322 BE[9654] mov si, msg_edit_or_exit 3394 00001325 E8210B call print_msg 3395 00001328 EB06 jmp short C_04 3396 C_03: 3397 ; Ask for formatting, editing PT or exit 3398 0000132A BE[2754] mov si, msg_format_stage 3399 0000132D E8190B call print_msg 3400 C_04: 3401 00001330 BE[6754] mov si, msg_partition_edit 3402 00001333 E8130B call print_msg 3403 C_05: 3404 00001336 28E4 sub ah, ah 3405 00001338 CD16 int 16h 3406 3407 0000133A 3C0D cmp al, 13 3408 0000133C 7452 je short C_08 3409 3410 ;; 07/03/2019 3411 0000133E 3C20 cmp al, 20h ; SPACE 3412 ;je A_27 ; edit partition table option is selected 3413 00001340 7406 je short C_06 ; 08/03/2019 3414 3415 00001342 3C1B cmp al, 27 ; ESCAPE 3416 00001344 75F0 jne short C_05 3417 3418 00001346 30C0 xor al, al ; 08/03/2019 3419 Exit: 3420 C_06: 3421 00001348 50 push ax ; 08/03/2019 3422 00001349 B43E mov ah, 3Eh ; close file 3423 0000134B 8B1E[A840] mov bx, [img_file_handle] 3424 0000134F CD21 int 21h 3425 ; 08/03/2019 3426 00001351 58 pop ax 3427 ;cmp al, 27 3428 ;je short C_06_exit 3429 00001352 08C0 or al, al 3430 00001354 7409 jz short C_06_exit 3431 00001356 C706[A840]0000 mov word [img_file_handle], 0 3432 0000135C E9DBEE jmp A_27 3433 3434 C_06_exit: 3435 0000135F BE[6756] mov si, CRLF 3436 00001362 E8E40A call print_msg 3437 3438 ; 11/02/2019 3439 3440 ; Exit 3441 00001365 CD20 int 20h 3442 3443 save_mbr_exit: 3444 ; 24/02/2019 3445 00001367 E8C511 call init_partition_tables 3446 3447 0000136A E83416 call display_partition_table 3448 3449 0000136D BE[6756] mov si, CRLF 3450 00001370 E8D60A call print_msg 3451 3452 00001373 BE[1B55] mov si, msg_writing_mbr 3453 00001376 E8D00A call print_msg 3454 3455 00001379 31C0 xor ax, ax ; 0 3456 0000137B 31D2 xor dx, dx ; 0 3457 ; DX_AX = Masterboot Sector = 0 3458 0000137D BB[4057] mov bx, MasterBootBuff 3459 ; ES:BX = Sector Buffer 3460 00001380 E8D50A call write_hd_sector 3461 00001383 7303 jnc short C_07 3462 00001385 E9A10A jmp D_01 3463 C_07: 3464 00001388 BE[6356] mov si, Msg_OK 3465 0000138B E8BB0A call print_msg 3466 0000138E EBB8 jmp short Exit 3467 3468 C_08: 3469 00001390 803E[D16E]01 cmp byte [format_q], 1 3470 00001395 72D0 jb short save_mbr_exit 3471 3472 ; 25/02/2019 3473 ; Write MBR without writing message 3474 3475 ; NOTE: This may be second time of MBR writing... 3476 ; but, if partition table is modified, 3477 ; we need to write MBR to disk, here. 3478 ; 3479 ; (Otherwise.. the last created partition would not be recorded.) 3480 3481 00001397 31C0 xor ax, ax ; 0 3482 00001399 31D2 xor dx, dx ; 0 3483 ; DX_AX = Masterboot Sector = 0 3484 0000139B BB[4057] mov bx, MasterBootBuff 3485 ; ES:BX = Sector Buffer 3486 0000139E E8B70A call write_hd_sector 3487 000013A1 0F82840A jc D_01 3488 3489 ;; clear screen 3490 ;mov ax, 3 ; set video mode to 03h (80x25 text) 3491 ;int 10h 3492 3493 ; 25/02/2019 3494 000013A5 8B36[6872] mov si, [pte_address] 3495 3496 ; 18/02/2019 3497 000013A9 E89E0F call show_selected_partition 3498 3499 000013AC A0[4E54] mov al, [partition_num_chr] 3500 000013AF A2[0E55] mov [partition_num_txt], al 3501 3502 000013B2 BE[EC54] mov si, msg_format_question 3503 000013B5 E8910A call print_msg 3504 C_09: 3505 000013B8 30E4 xor ah, ah 3506 000013BA CD16 int 16h 3507 3508 000013BC 3C1B cmp al, 1Bh ; ESCAPE 3509 000013BE 7488 je short C_06 3510 3511 000013C0 24DF and al, 0DFh ; capitalization 3512 000013C2 3C59 cmp al, 'Y' 3513 000013C4 740C je short C_10 3514 000013C6 3C4E cmp al, 'N' 3515 000013C8 75EE jne short C_09 3516 000013CA BE[105E] mov si, _msg_NO 3517 000013CD E8790A call print_msg 3518 ;jmp short C_06 3519 ; 24/02/2019 3520 000013D0 EB95 jmp short save_mbr_exit 3521 C_10: 3522 000013D2 BE[0A5E] mov si, _msg_YES 3523 000013D5 E8710A call print_msg 3524 3525 ; [pp_StartSector] = partition's start sector 3526 ; [pp_Sectors] = partition size including start & end sector 3527 ; [partition_num_chr] = partition number + '0' 3528 ; [pp_type] = partition type (for TRDOS 386 boot sector) 3529 3530 000013D8 8926[226A] mov [old_sp], sp 3531 3532 000013DC 8A16[B56E] mov dl, [pp_type] 3533 ; DL = partition type (file system ID) 3534 ;dec dl 3535 ;jz FAT12_hdi_format 3536 000013E0 80FA01 cmp dl, 1 ; 14/09/2020 (BugFix) 3537 000013E3 0F86E305 jna FAT12_hdi_format 3538 ;cmp dl, 4 3539 ;je FAT16_hdi_format 3540 ;cmp dl, 6 3541 ;je FAT16_hdi_format 3542 000013E7 80FA0B cmp dl, 0Bh 3543 000013EA 0F82D503 jb FAT16_hdi_format 3544 ;je short FAT32_hdi_format 3545 ;cmp dl, 0Ch ; 14/09/2020 3546 000013EE 0F877907 ja SINGLIX_hdi_format 3547 3548 ;cmp dl, 0A1h 3549 ;je SINGLIX_hdi_format 3550 ;jb RUNIX386_hdi_format ; dl = 071h 3551 3552 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3553 ; FAT32 FORMATTING 3554 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3555 3556 ; 08/02/2019 (Modified for -only- FAT32 CHS partitions) 3557 FAT32_hdi_format: 3558 ;mov ax, 000Ch ; db 0Ch, 00h ; 'or al, 0' 3559 ;cmp dl, al ; 0Ch 3560 ;je short FAT32_lba_format 3561 ;mov ax, 0C00Bh ; db 0Bh, 0C0h ; 'or ax, ax' 3562 ;FAT32_lba_format: 3563 ; Put TRDOS 386 FAT32 partition magic word 3564 ; at offset 5Ah, in TRDOS386 FAT32 boot sector 0. 3565 ;mov bp, TRDOS_FAT32_hd_bs 3566 000013F2 BD[9634] mov bp, RD5_FAT32_hd_bs ; 04/05/2024 3567 000013F5 8D7E03 lea di, [bp+3] 3568 000013F8 BE[0C66] mov si, bs_oem_name 3569 000013FB B90400 mov cx, 4 3570 000013FE F3A5 rep movsw 3571 ;mov [bp+5Ah], ax ; [loc_5A] 3572 00001400 C7465A0BC0 mov word [bp+5Ah], 0C00Bh ; 08/02/2019 3573 00001405 A1[AA40] mov ax, [sectors] 3574 00001408 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 3575 0000140B A1[AC40] mov ax, [heads] 3576 0000140E 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 3577 00001411 A1[AC6E] mov ax, [pp_StartSector] 3578 00001414 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 3579 00001417 A1[AE6E] mov ax, [pp_StartSector+2] 3580 0000141A 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 3581 ;mov ax, [pp_Sectors] 3582 0000141D A1[E06E] mov ax, [ppn_Sectors] ; 16/02/2019 3583 00001420 894620 mov [bp+20h], ax ; [BPB_TotSec32] 3584 ;mov dx, [pp_Sectors+2] 3585 00001423 8B16[E26E] mov dx, [ppn_Sectors+2] ; 16/02/2019 3586 00001427 895622 mov [bp+22h], dx ; [BPB_TotSec32+2] 3587 3588 ; Sectors per cluster calculation 3589 ; (According to MS FAT32 FS specification.) 3590 0000142A B108 mov cl, 8 ; 8 sectors per cluster 3591 0000142C 83FA08 cmp dx, 8 ; >= 532480 sectors 3592 0000142F 7709 ja short FAT32_f_2 ; 8 sectors per cluster 3593 00001431 7205 jb short FAT32_f_1 ; 1 sector per cluster 3594 00001433 3D0020 cmp ax, 2000h ; dx_ax = (8*65536)+8192 3595 00001436 7302 jnb short FAT32_f_2 ; 12/09/2020 (BugFix) 3596 FAT32_f_1: 3597 00001438 B101 mov cl, 1 ; 1 sector per cluster 3598 FAT32_f_2: 3599 0000143A 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 3600 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 3601 ;mov word [bp+0Eh], 32 ; [BPB_RsvdSecCnt] 3602 3603 ; Calculating FAT size in sectors 3604 ; (According to MS FAT32 FS Specification, 2000) 3605 3606 ; DX_AX = partition (volume) size in sectors 3607 0000143D 2B460E sub ax, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 3608 00001440 83DA00 sbb dx, 0 3609 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 3610 ; RootDirsectors) 3611 ; RootDirSectors = 0 (for FAT32 FS) 3612 00001443 89CB mov bx, cx ; ch = 0 3613 00001445 C1E308 shl bx, 8 ; * 256 3614 00001448 8A4E10 mov cl, [bp+10h] ; [BPB_NumFATs] 3615 0000144B 01CB add bx, cx 3616 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 3617 0000144D D1EB shr bx, 1 3618 ; TmpVal2 = TmpVal2/2 3619 0000144F 89D9 mov cx, bx 3620 00001451 4B dec bx ; TmpVal2-1 3621 00001452 01D8 add ax, bx 3622 00001454 83D200 adc dx, 0 3623 00001457 E8DCF9 call div32 3624 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 3625 ; DX_AX = FAT size in sectors 3626 0000145A 894624 mov [bp+24h], ax ; [BPB_FATSz32] 3627 0000145D 895626 mov [bp+26h], dx ; [BPB_FATSz32+2] 3628 ; * 2 3629 00001460 89D3 mov bx, dx 3630 00001462 01C0 add ax, ax 3631 00001464 11D3 adc bx, dx 3632 ; BX_AX = [BPB_NumFATs] * [BPB_FATSz32] 3633 00001466 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 32 3634 00001469 01C1 add cx, ax 3635 0000146B 83D300 adc bx, 0 3636 ; BX_CX = [BPB_RsvdSecCnt]+[BPB_NumFATs]*[BPB_FATSz32] 3637 0000146E 8B4620 mov ax, [bp+20h] ; [BPB_TotSec32] 3638 00001471 8B5622 mov dx, [bp+22h] ; [BPB_TotSec32+2] 3639 00001474 29C8 sub ax, cx 3640 00001476 19DA sbb dx, bx 3641 00001478 890E[246C] mov [data_start], cx 3642 0000147C 891E[266C] mov [data_start+2], bx 3643 ; DX_AX = Data sectors 3644 00001480 A3[286C] mov [data_sectors], ax 3645 00001483 8916[2A6C] mov [data_sectors+2], dx 3646 00001487 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 3647 0000148A 30ED xor ch, ch 3648 0000148C E8A7F9 call div32 ; DX_AX/CX 3649 ; DX_AX = Count of clusters (rounded down) 3650 0000148F A3[2C6C] mov [cluster_count], ax 3651 00001492 8916[2E6C] mov [cluster_count+2], dx 3652 3653 00001496 8D7E47 lea di, [bp+71] ; [BS_VolLab] 3654 00001499 E89E01 call write_volume_name 3655 0000149C 8D7643 lea si, [bp+67] ; [BS_VolID] 3656 0000149F E8F701 call write_volume_serial 3657 000014A2 E80703 call write_cluster_count 3658 3659 000014A5 E87802 call write_formatting_msg 3660 000014A8 B000 mov al, 0 3661 000014AA E8D002 call write_format_percent_x 3662 3663 000014AD 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 3664 000014B0 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 3665 000014B3 0106[246C] add [data_start], ax 3666 000014B7 1116[266C] adc [data_start+2], dx 3667 FAT32_f_3: 3668 ; DX_AX = FAT32 Boot Sector address 3669 ;mov bx, TRDOS_FAT32_hd_bs 3670 000014BB BB[9634] mov bx, RD5_FAT32_hd_bs ; 04/05/2024 3671 ; ES:BX = Boot Sector 1 Buffer 3672 000014BE E89709 call write_hd_sector 3673 000014C1 0F82CC02 jc formatting_error 3674 000014C5 E87C02 call write_format_percent 3675 000014C8 83C001 add ax, 1 3676 000014CB 83D200 adc dx, 0 3677 000014CE BB[2268] mov bx, HDFORMAT_FSINFO_BUFF 3678 ; ES:BX = FS INFO Sector Buffer (= BS+1) 3679 000014D1 E88409 call write_hd_sector 3680 000014D4 0F82B902 jc formatting_error 3681 000014D8 E86902 call write_format_percent 3682 000014DB 83C001 add ax, 1 3683 000014DE 83D200 adc dx, 0 3684 ;mov bx, TRDOS_FAT32_hd_bs + 512 3685 000014E1 BB[9636] mov bx, RD5_FAT32_hd_bs + 512 ; 04/05/2024 3686 ; ES:BX = Boot Sector 2 Buffer 3687 000014E4 E87109 call write_hd_sector 3688 000014E7 0F82A602 jc formatting_error 3689 000014EB E85602 call write_format_percent 3690 000014EE B90300 mov cx, 3 3691 FAT32_f_4: 3692 000014F1 51 push cx 3693 000014F2 83C001 add ax, 1 3694 000014F5 83D200 adc dx, 0 3695 000014F8 BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 3696 000014FB E85A09 call write_hd_sector 3697 000014FE 0F828F02 jc formatting_error 3698 00001502 E83F02 call write_format_percent 3699 00001505 59 pop cx 3700 00001506 FEC9 dec cl 3701 00001508 75E7 jnz short FAT32_f_4 3702 0000150A 83C001 add ax, 1 3703 0000150D 83D200 adc dx, 0 3704 00001510 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 3705 00001513 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 3706 00001516 83C10C add cx, 12 3707 00001519 83D300 adc bx, 0 3708 ; write BACKUP sectors 3709 ; (6,7,8 boot+fsi and 9,10,11 empty sectors) 3710 0000151C 39DA cmp dx, bx 3711 0000151E 729B jb short FAT32_f_3 3712 00001520 39C8 cmp ax, cx 3713 00001522 7297 jb short FAT32_f_3 3714 ; write remain part of reserved sectors 3715 00001524 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 3716 00001527 83E90C sub cx, 12 3717 0000152A 7618 jna short FAT32_f_6 3718 FAT32_f_5: 3719 0000152C 51 push cx 3720 0000152D BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 3721 00001530 E82509 call write_hd_sector 3722 00001533 0F825A02 jc formatting_error 3723 00001537 E80A02 call write_format_percent 3724 0000153A 83C001 add ax, 1 3725 0000153D 83D200 adc dx, 0 3726 00001540 59 pop cx 3727 00001541 49 dec cx 3728 00001542 75E8 jnz short FAT32_f_5 3729 FAT32_f_6: 3730 ; write FAT sectors 3731 00001544 8B0E[246C] mov cx, [data_start] ; lba/abs addr 3732 00001548 8B1E[266C] mov bx, [data_start+2] ; lba/abs addr 3733 0000154C 53 push bx 3734 0000154D 51 push cx 3735 0000154E BB[246A] mov bx, HDFORMAT_FATBUFFER 3736 ; ES:BX = FAT Sector Buffer 3737 00001551 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 3738 00001554 B5FF mov ch, 0FFh 3739 00001556 890F mov [bx], cx 3740 00001558 88E9 mov cl, ch ; cx = 0FFFFh 3741 0000155A 894F02 mov [bx+2], cx 3742 0000155D 894F04 mov [bx+4], cx 3743 00001560 894F06 mov [bx+6], cx 3744 ; Root dir cluster number = 2 3745 ; 0FFFFFFFh = end of cluster chain 3746 00001563 894F08 mov [bx+8], cx ; 0FFFFh 3747 00001566 80E50F and ch, 0Fh 3748 00001569 894F0A mov [bx+10], cx ; 0FFFh 3749 ;inc cx 3750 0000156C E8E908 call write_hd_sector 3751 0000156F 0F821E02 jc formatting_error 3752 00001573 E8CE01 call write_format_percent 3753 ;mov bx, HDFORMAT_FATBUFFER 3754 00001576 B90000 mov cx, 0 3755 00001579 890F mov [bx], cx 3756 0000157B 894F02 mov [bx+2], cx 3757 0000157E 894F04 mov [bx+4], cx 3758 00001581 894F06 mov [bx+6], cx 3759 00001584 894F08 mov [bx+8], cx 3760 00001587 894F0A mov [bx+10], cx 3761 0000158A EB0F jmp short FAT32_f_8 3762 FAT32_f_7: 3763 0000158C 53 push bx 3764 0000158D 51 push cx 3765 0000158E BB[246A] mov bx, HDFORMAT_FATBUFFER 3766 00001591 E8C408 call write_hd_sector 3767 00001594 0F82F901 jc formatting_error 3768 00001598 E8A901 call write_format_percent 3769 FAT32_f_8: 3770 0000159B 59 pop cx 3771 0000159C 5B pop bx 3772 0000159D 83C001 add ax, 1 3773 000015A0 83D200 adc dx, 0 3774 000015A3 39DA cmp dx, bx 3775 000015A5 72E5 jb short FAT32_f_7 3776 000015A7 39C8 cmp ax, cx 3777 000015A9 72E1 jb short FAT32_f_7 3778 3779 ; write root directory (1st cluster) 3780 ; as empty sectors 3781 000015AB 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 3782 000015AE 30ED xor ch, ch 3783 000015B0 290E[286C] sub [data_sectors], cx 3784 000015B4 831E[2A6C]00 sbb word [data_sectors+2], 0 3785 FAT32_f_9: 3786 000015B9 51 push cx 3787 000015BA BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 3788 000015BD E89808 call write_hd_sector 3789 000015C0 0F82CD01 jc formatting_error 3790 000015C4 E87D01 call write_format_percent 3791 000015C7 83C001 add ax, 1 3792 000015CA 83D200 adc dx, 0 3793 000015CD 59 pop cx 3794 000015CE FEC9 dec cl 3795 000015D0 75E7 jnz short FAT32_f_9 3796 3797 ; write DATA sectors 3798 ; (after root directory 1st cluster) 3799 000015D2 8B0E[286C] mov cx, [data_sectors] 3800 000015D6 8B1E[2A6C] mov bx, [data_sectors+2] 3801 ; NOTE: Partition size must be >= 512 MB 3802 ; for FAT32 FS ((BX >= 15)) 3803 FAT32_f_10: 3804 000015DA 53 push bx 3805 000015DB 51 push cx 3806 000015DC BB[2266] mov bx, HDFORMAT_SECBUFFER 3807 000015DF E87608 call write_hd_sector 3808 000015E2 0F82AB01 jc formatting_error 3809 000015E6 E85B01 call write_format_percent 3810 000015E9 59 pop cx 3811 000015EA 5B pop bx 3812 000015EB 83C001 add ax, 1 3813 000015EE 83D200 adc dx, 0 3814 000015F1 49 dec cx 3815 000015F2 75E6 jnz short FAT32_f_10 3816 000015F4 4B dec bx 3817 000015F5 75E3 jnz short FAT32_f_10 3818 3819 ; If there are, format remain sectors which are 3820 ; at beyond of data clusters, with zero bytes. 3821 3822 000015F7 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 3823 000015FA 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 3824 FAT16_f_18: 3825 000015FD 034E20 add cx, [bp+20h] ; [BPB_TotSec32] 3826 00001600 135E22 adc bx, [bp+22h] ; [BPB_TotSec32+2] 3827 FAT16_f_19: 3828 FAT12_f_8: 3829 ; are there remain sectors (in partition) ? 3830 00001603 29C1 sub cx, ax 3831 00001605 19D3 sbb bx, dx 3832 ; 11/02/2019 3833 ; BX must be 0 (Because, 1 cluster <= 32KB. So, 3834 ; remain sectors must not be more than 32K) 3835 00001607 751C jnz short FAT32_f_12 ; There is a wrong thing !!! 3836 ; If BX is not zero, 3837 ; it is better to skip this stage...) 3838 00001609 09C9 or cx, cx 3839 0000160B 7418 jz short FAT32_f_12 ; no.. 3840 ; (good! FAT contains all data sectors) 3841 FAT32_f_11: 3842 0000160D 51 push cx 3843 0000160E BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 3844 00001611 E84408 call write_hd_sector 3845 00001614 0F827901 jc formatting_error 3846 00001618 E82901 call write_format_percent 3847 0000161B 59 pop cx 3848 0000161C 83C001 add ax, 1 3849 0000161F 83D200 adc dx, 0 3850 00001622 49 dec cx 3851 00001623 75E8 jnz short FAT32_f_11 3852 3853 FAT32_f_12: 3854 SINGLIX_fs1_f_12: 3855 ; End of FAT format routine... 3856 end_of_formatting: 3857 00001625 B064 mov al, 100 3858 00001627 E85301 call write_format_percent_x 3859 ;mov si, CRLF 3860 ;call print_msg 3861 0000162A BE[6356] mov si, Msg_OK 3862 0000162D E81908 call print_msg 3863 00001630 E915FD jmp Exit 3864 3865 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3866 ; set & write volume name 3867 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3868 3869 write_fs_volume_name: 3870 00001633 C606[0B66]40 mov byte [vname_length], 64 3871 00001638 EB05 jmp short svn_fs 3872 3873 write_volume_name: 3874 0000163A C606[0B66]0B mov byte [vname_length], 11 3875 svn_fs: 3876 ; DI = (BS) Volume Label address 3877 0000163F BE[0556] mov si, Msg_Volume_Name 3878 00001642 E80408 call print_msg 3879 3880 ; get cursor position 3881 ; bh = 0 ; video page 3882 00001645 B403 mov ah, 3 ; get cursor pos 3883 00001647 CD10 int 10h 3884 00001649 8916[AB55] mov [Cursor_Pos], dx 3885 3886 0000164D E8AF08 call rw_char 3887 00001650 7207 jc short svn_1 3888 svn_0: 3889 00001652 AC lodsb 3890 00001653 3C20 cmp al, 20h 3891 00001655 7706 ja short svn_2 3892 00001657 74F9 je short svn_0 3893 svn_1: 3894 00001659 BE[1666] mov si, no_name 3895 0000165C AC lodsb 3896 svn_2: 3897 ;mov di, [bp+47h) ; [BS_VolLab] ; FAT32 3898 ;mov di, [bp+2Bh) ; [BS_VolLab] ; FAT16 (&FAT12) 3899 0000165D 89FB mov bx, di ; * 3900 0000165F 30ED xor ch, ch 3901 00001661 8A0E[0B66] mov cl, [vname_length] ; 11 3902 00001665 EB05 jmp short svn_4 3903 svn_3: 3904 00001667 AC lodsb 3905 00001668 3C20 cmp al, 20h 3906 0000166A 7226 jb short svn_6 3907 svn_4: 3908 0000166C AA stosb 3909 0000166D E2F8 loop svn_3 3910 svn_5: 3911 0000166F 8A0E[0B66] mov cl, [vname_length] ; 11 3912 00001673 89DE mov si, bx ; * 3913 00001675 BF[C455] mov di, StrVolumeName 3914 00001678 F3A4 rep movsb 3915 ;mov byte [di], 0 3916 3917 0000167A 8B16[AB55] mov dx, [Cursor_Pos] 3918 0000167E BB0700 mov bx, 7 3919 00001681 B402 mov ah, 2 3920 00001683 CD10 int 10h ; Set Cursor Position 3921 3922 00001685 BE[C455] mov si, StrVolumeName 3923 00001688 E8BE07 call print_msg 3924 0000168B BE[6756] mov si, CRLF 3925 0000168E E8B807 call print_msg 3926 00001691 C3 retn 3927 svn_6: 3928 00001692 B020 mov al, 20h 3929 svn_7: 3930 00001694 AA stosb 3931 00001695 E2FD loop svn_7 3932 00001697 EBD6 jmp short svn_5 3933 3934 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3935 ; set & write volume serial number (volume ID) 3936 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3937 3938 write_volume_serial: 3939 ; SI = (BS) Volume Serial Number (binary) address 3940 3941 ;xor ax, ax 3942 ;int 1Ah ; get time of day 3943 3944 ;mov [si], dx 3945 ;mov [si+2], cx ; set unique volume ID 3946 3947 ;mov ah, 02h ; Return Current Time 3948 ;int 1Ah 3949 ;xchg ch, cl 3950 ;xchg dh, dl 3951 3952 ;add cx, dx 3953 ;add [si+2], cx 3954 3955 ;mov ah, 04h ; Return Current Date 3956 ;int 1Ah 3957 3958 ;xchg ch,cl 3959 ;xchg dh,dl 3960 3961 ;add cx, dx 3962 ;add [si+2], cx 3963 3964 ; According to Microsoft DOS 6.0 serial number 3965 ; production method... 3966 ; < Create unique 32 bit serial number > 3967 3968 ; Create_Serial_ID (MSDOS 6.0 Source code, MSFOR.ASM) 3969 ; (20/04/1987) 3970 ; 3971 ; Get date (INT 21h, AH=2Bh) 3972 ; Get time (INT 21h, AH=2Ch) 3973 ; Serial_ID+0 = DX reg date + DX reg time 3974 ; Serial_ID+2 = CX reg date + CX reg time 3975 ; Serial_Num_Low = Serial_ID+2 3976 ; Serial_Num_High = Serial_ID+0 3977 3978 00001699 B404 mov ah, 04h ; Return Current Date 3979 0000169B CD1A int 1Ah 3980 3981 ; DL = Day (BCD) (20h) 3982 ; DH = Month (BCD) (12h) 3983 ; CH = Century (BCD) (20h) 3984 ; CL = Year (BCD) (17h) 3985 3986 0000169D 88D0 mov al, dl 3987 0000169F E87100 call bcd_to_bin 3988 000016A2 88C2 mov dl, al 3989 000016A4 88F0 mov al, dh 3990 000016A6 E86A00 call bcd_to_bin 3991 000016A9 88C6 mov dh, al 3992 000016AB 88C8 mov al, cl 3993 000016AD E86300 call bcd_to_bin 3994 000016B0 88C1 mov cl, al 3995 000016B2 88E8 mov al, ch 3996 000016B4 E85C00 call bcd_to_bin 3997 000016B7 88C5 mov ch, al 3998 3999 ; DH = Month (1-10) 4000 ; DL = Day (1-31) 4001 ; CX = Year (1900-2099) 4002 4003 000016B9 52 push dx 4004 000016BA 51 push cx 4005 4006 000016BB B402 mov ah, 02h ; Return Current Time 4007 000016BD CD1A int 1Ah 4008 4009 ; DH = Seconds (BCD) (59h) 4010 ; CL = Minutes (BCD) (59h) 4011 ; CH = Hours (BCD) (23h) 4012 ; DL = Daylight savings time option (1=yes) 4013 4014 000016BF 88F0 mov al, dh 4015 000016C1 E84F00 call bcd_to_bin 4016 000016C4 88C6 mov dh, al 4017 000016C6 88C8 mov al, cl 4018 000016C8 E84800 call bcd_to_bin 4019 000016CB 88C1 mov cl, al 4020 000016CD 88E8 mov al, ch 4021 000016CF E84100 call bcd_to_bin 4022 000016D2 88C5 mov ch, al 4023 4024 ; CH = Hour (0-23) 4025 ; CL = Minutes (0-59) 4026 ; DH = Seconds (0-59) 4027 ; ((DL = Hundredths (0-99) - MSDOS!)) 4028 ; DL = 0 or 1 (here!) 4029 4030 000016D4 89C8 mov ax, cx 4031 000016D6 59 pop cx 4032 000016D7 01C8 add ax, cx 4033 4034 000016D9 894402 mov [si+2], ax 4035 4036 000016DC 89D0 mov ax, dx 4037 000016DE 5A pop dx 4038 000016DF 01D0 add ax, dx 4039 4040 000016E1 8904 mov [si], ax 4041 4042 000016E3 30E4 xor ah, ah ; Read time counter 4043 000016E5 CD1A int 1Ah 4044 4045 ; CX = High word of clock count 4046 ; DX = Low word of clock count 4047 ; AL = 0 if 24 hours has not passed, else 1 4048 4049 ; NOTES: 4050 ; (Ref: vitaly_filatov.tripod.com/ng/asm/asm_029.1.html) 4051 ; 4052 ; Following formulas convert the clock count to 4053 ; the time of day: 4054 ; Hour = Clock / 65543 (1007h) 4055 ; Remainder = Clock MOD 65543 4056 ; 4057 ; Minutes = Remainder / 1092 (444h) 4058 ; Remainder = Remainder MOD 1092 4059 ; 4060 ; Second = Remainder / 18.21 4061 ; Remainder = Remainder MOD 18.21 4062 ; 4063 ; Hundredths = CINT(Remainder * 100) 4064 4065 000016E7 0014 add [si], dl 4066 4067 ; SI = Volume serial number address (4 bytes) 4068 000016E9 8A04 mov al, [si] 4069 000016EB E8FA07 call bin_to_hex 4070 000016EE A3[3056] mov [Vol_Serial2+2], ax 4071 000016F1 8A4401 mov al, [si+1] 4072 000016F4 E8F107 call bin_to_hex 4073 000016F7 A3[2E56] mov [Vol_Serial2], ax 4074 000016FA 8A4402 mov al, [si+2] 4075 000016FD E8E807 call bin_to_hex 4076 00001700 A3[2B56] mov [Vol_Serial1+2], ax 4077 00001703 8A4403 mov al, [si+3] 4078 00001706 E8DF07 call bin_to_hex 4079 00001709 A3[2956] mov [Vol_Serial1], ax 4080 4081 0000170C BE[1756] mov si, Msg_Volume_Serial 4082 0000170F E83707 call print_msg 4083 4084 00001712 C3 retn 4085 4086 bcd_to_bin: 4087 00001713 53 push bx 4088 00001714 D410 db 0D4h,10h ; Undocumented inst. AAM 4089 ; AH = AL / 10h 4090 ; AL = AL MOD 10h 4091 00001716 88C3 mov bl, al 4092 00001718 B00A mov al, 10 4093 0000171A F6E4 mul ah 4094 0000171C 00D8 add al, bl 4095 0000171E 5B pop bx 4096 0000171F C3 retn 4097 4098 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4099 ; write formatting percentage 4100 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4101 4102 write_formatting_msg: 4103 ;mov ax, [pp_Sectors] 4104 ;mov dx, [pp_Sectors+2] 4105 ; 16/02/2019 4106 00001720 A1[E06E] mov ax, [ppn_Sectors] 4107 00001723 8B16[E26E] mov dx, [ppn_Sectors+2] 4108 4109 ; DX_AX = Total sectors for percentage 4110 00001727 B96400 mov cx, 100 4111 0000172A E809F7 call div32 4112 0000172D A3[326C] mov [format_percent], ax 4113 4114 00001730 BE[4F56] mov si, msg_formatting 4115 00001733 E81307 call print_msg 4116 4117 ; get cursor position 4118 ; bh = 0 ; video page 4119 00001736 B403 mov ah, 3 ; get cursor pos 4120 00001738 CD10 int 10h 4121 0000173A 8916[AB55] mov [Cursor_Pos], dx 4122 4123 0000173E C606[346C]FF mov byte [prev_percent], 255 4124 4125 00001743 C3 retn 4126 4127 write_format_percent: 4128 ; DX_AX = Current sector (which has been written) 4129 4130 00001744 50 push ax 4131 00001745 52 push dx 4132 00001746 53 push bx 4133 00001747 51 push cx 4134 00001748 56 push si 4135 4136 00001749 2B461C sub ax, [bp+1Ch] ; [BPB_HiddSec] 4137 0000174C 1B561E sbb dx, [bp+1Eh] ; [BPB_HiddSec+2] 4138 wpc_t: 4139 0000174F 8B0E[326C] mov cx, [format_percent] 4140 00001753 E8E0F6 call div32 4141 ; AL = percentage value between 1 to 100 4142 wpc_x: 4143 00001756 3A06[346C] cmp al, [prev_percent] 4144 0000175A 741B je short wpc_y 4145 0000175C A2[346C] mov [prev_percent], al 4146 0000175F 8B16[AB55] mov dx, [Cursor_Pos] 4147 00001763 BB0700 mov bx, 7 4148 00001766 B402 mov ah, 2 4149 00001768 CD10 int 10h ; Set Cursor Position 4150 0000176A 31D2 xor dx, dx 4151 0000176C 30E4 xor ah, ah 4152 ;mov al, [prev_percent] 4153 0000176E BE[5D56] mov si, format_percent_str + 2 4154 00001771 E85D07 call bin_to_decimal 4155 00001774 E8D206 call print_msg 4156 wpc_y: 4157 00001777 5E pop si 4158 00001778 59 pop cx 4159 00001779 5B pop bx 4160 0000177A 5A pop dx 4161 0000177B 58 pop ax 4162 0000177C C3 retn 4163 4164 write_format_percent_x: 4165 ; AL = % number 4166 4167 0000177D 50 push ax 4168 0000177E 52 push dx 4169 0000177F 53 push bx 4170 00001780 51 push cx 4171 00001781 56 push si 4172 4173 00001782 EBD2 jmp short wpc_x 4174 4175 write_fs_format_percent: 4176 ; DX_AX = Current sector (which has been written) 4177 4178 00001784 50 push ax 4179 00001785 52 push dx 4180 00001786 53 push bx 4181 00001787 51 push cx 4182 00001788 56 push si 4183 4184 00001789 2B460C sub ax, [bp+0Ch] ; [bsBeginSector] 4185 0000178C 1B560E sbb dx, [bp+0Eh] ; [bsBeginSector+2] 4186 0000178F EBBE jmp short wpc_t 4187 4188 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4189 ; format error 4190 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4191 4192 formatting_error: 4193 00001791 8B26[226A] mov sp, [old_sp] 4194 4195 00001795 88E0 mov al, ah ; error code 4196 00001797 E84E07 call bin_to_hex 4197 0000179A A3[7556] mov [error_code], ax 4198 4199 0000179D BE[6756] mov si, CRLF 4200 000017A0 E8A606 call print_msg 4201 4202 000017A3 BE[6A56] mov si, Msg_Error 4203 000017A6 E8A006 call print_msg 4204 000017A9 E99CFB jmp Exit 4205 4206 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4207 ; write cluster count 4208 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4209 4210 write_cluster_count: 4211 000017AC BE[3556] mov si, msg_cluster_count 4212 000017AF E89706 call print_msg 4213 000017B2 A1[2C6C] mov ax, [cluster_count] 4214 000017B5 8B16[2E6C] mov dx, [cluster_count+2] 4215 000017B9 BE[4B56] mov si, cluster_count_str+6 4216 000017BC E81207 call bin_to_decimal 4217 000017BF E88706 call print_msg 4218 000017C2 C3 retn 4219 4220 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4221 ; FAT16 FORMATTING 4222 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4223 ; 08/02/2019 (Modified for -only- FAT16 CHS partitions) 4224 FAT16_hdi_format: 4225 000017C3 B80607 mov ax, 0706h ; db 06h, 07h ; 'push es, pop es' 4226 000017C6 38C2 cmp dl, al ; 06h ; Big CHS partition (>= 32MB) 4227 000017C8 7403 je short FAT16_big_chs_format 4228 ;mov ax, 070Eh ; db 0Eh, 07h ; 'push cs, pop es' 4229 ;cmp dl, al ; 0Eh ; LBA partition 4230 ;je short FAT16_lba_format 4231 FAT16_chs_format: 4232 ; Partition Type: 04h, CHS (<32 MB) partition 4233 000017CA B80400 mov ax, 0004h ; db 04h, 00h ; 'add al, 0' 4234 FAT16_big_chs_format: 4235 ;FAT16_lba_format: 4236 ; Put TRDOS 386 FAT16 partition magic word 4237 ; at offset 3Eh, in TRDOS386 FAT16 boot sector. 4238 ;mov bp, TRDOS_FAT16_hd_bs 4239 000017CD BD[9638] mov bp, RD5_FAT16_hd_bs ; 04/05/2024 4240 000017D0 8D7E03 lea di, [bp+3] 4241 000017D3 BE[0C66] mov si, bs_oem_name 4242 000017D6 B90400 mov cx, 4 4243 000017D9 F3A5 rep movsw 4244 000017DB 89463E mov [bp+3Eh], ax ; [loc_3E] 4245 4246 000017DE A1[AA40] mov ax, [sectors] 4247 000017E1 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4248 000017E4 A1[AC40] mov ax, [heads] 4249 000017E7 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4250 000017EA A1[AC6E] mov ax, [pp_StartSector] 4251 000017ED 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 4252 000017F0 A1[AE6E] mov ax, [pp_StartSector+2] 4253 000017F3 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4254 ;mov ax, [pp_Sectors] 4255 000017F6 A1[E06E] mov ax, [ppn_Sectors] ; 16/02/2019 4256 ;mov dx, [pp_Sectors+2] 4257 000017F9 8B16[E26E] mov dx, [ppn_Sectors+2] ; 16/02/2019 4258 000017FD 21D2 and dx, dx 4259 000017FF 7505 jnz short FAT16_f_0 4260 00001801 894613 mov [bp+13h], ax ; [BPB_TotSec16] 4261 ; CX = 0 4262 ;mov [bp+20h], cx ; [BPB_TotSec32] = 0 4263 ;mov [bp+22h], cx ; [BPB_TotSec32+2] = 0 4264 00001804 EB06 jmp short FAT16_f_1 4265 FAT16_f_0: 4266 00001806 894620 mov [bp+20h], ax ; [BPB_TotSec32] 4267 ;;mov dx, [pp_Sectors+2] 4268 ;mov dx, [ppn_Sectors+2] ; 16/02/2019 4269 00001809 895622 mov [bp+22h], dx ; [BPB_TotSec32+2] 4270 ; CX = 0 4271 ;mov [bp+13h], cx ; [BPB_TotSec16] = 0 4272 FAT16_f_1: 4273 ; Sectors per cluster calculation 4274 ; (According to MS FAT32 FS specification.) 4275 0000180C B102 mov cl, 2 ; 2 sectors per cluster 4276 0000180E 09D2 or dx, dx 4277 00001810 7507 jnz short FAT16_f_2 ; >2 sectors (>16MB) 4278 00001812 3DA87F cmp ax, 32680 4279 00001815 763C jna short FAT16_f_10 ; 2 sectors, <=16MB 4280 ; > 16MB 4281 00001817 EB38 jmp short FAT16_f_9 ; 4 sectors per cluster 4282 FAT16_f_2: 4283 00001819 83FA04 cmp dx, 4 ; >= 262144 sectors ; >=128MB 4284 0000181C 7708 ja short FAT16_f_3 ; >4 sectors per cluster 4285 0000181E 7231 jb short FAT16_f_9 ; 4 sectors per cluster 4286 00001820 09C0 or ax, ax ; dx_ax = (4*65536)+0 4287 00001822 742D jz short FAT16_f_9 ; 4 sectors per cluster 4288 00001824 EB29 jmp short FAT16_f_8 ; 8 sectors per cluster 4289 FAT16_f_3: 4290 00001826 83FA08 cmp dx, 8 ; >= 524288 sectors ; >=256MB 4291 00001829 7708 ja short FAT16_f_4 ; >8 sectors per cluster 4292 0000182B 7222 jb short FAT16_f_8 ; 8 sectors per cluster 4293 0000182D 21C0 and ax, ax ; dx_ax = (8*65536)+0 4294 0000182F 741E jz short FAT16_f_8 ; 8 sectors per cluster 4295 00001831 EB1A jmp short FAT16_f_7 ; 16 sectors per cluster 4296 FAT16_f_4: 4297 00001833 83FA10 cmp dx, 16 ; >= 1048576 sectors ; >=512MB 4298 00001836 7708 ja short FAT16_f_5 ; >16 sectors per cluster 4299 00001838 7213 jb short FAT16_f_7 ; 16 sectors per cluster 4300 0000183A 21C0 and ax, ax ; dx_ax = (16*65536)+0 4301 0000183C 740F jz short FAT16_f_7 ; 16 sectors per cluster 4302 0000183E EB0B jmp short FAT16_f_6 ; 32 sectors per cluster 4303 FAT16_f_5: 4304 00001840 83FA20 cmp dx, 32 ; >= 2097152 sectors ; >=1GB 4305 00001843 7206 jb short FAT16_f_6 ; 32 sectors per cluster 4306 00001845 09C0 or ax, ax ; dx_ax = (32*65536)+0 4307 00001847 7402 jz short FAT16_f_6 ; 32 sectors per cluster 4308 ; >1GB (<=2GB) 4309 ; 64 sectors per cluster 4310 00001849 D0E1 shl cl, 1 4311 FAT16_f_6: 4312 ; 32 sectors per cluster (for <= 2GB volumes) 4313 0000184B D0E1 shl cl, 1 4314 FAT16_f_7: 4315 ; 16 sectors per cluster (for <= 1GB volumes) 4316 0000184D D0E1 shl cl, 1 4317 FAT16_f_8: 4318 ; 8 sectors per cluster (for <= 512MB volumes) 4319 0000184F D0E1 shl cl, 1 4320 FAT16_f_9: 4321 ; 4 sectors per cluster (for <= 256MB volumes) 4322 00001851 D0E1 shl cl, 1 4323 FAT16_f_10: 4324 ; 2 sectors per cluster (for <= 128MB volumes) 4325 00001853 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 4326 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 4327 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 4328 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 4329 4330 ; Calculating FAT size in sectors 4331 ; (According to MS FAT32 FS Specification, 2000) 4332 4333 ; DX_AX = partition (volume) size in sectors 4334 00001856 8B5E11 mov bx, [bp+11h] ; [BPB_RootEntCnt] = 512 4335 00001859 83C30F add bx, 15 ; bx = 527 4336 0000185C C1EB04 shr bx, 4 ; /16 = 527/16 = 32 4337 ; ((32*BX)+511)/512 4338 0000185F 891E[306C] mov [root_dir_secs], bx 4339 00001863 035E0E add bx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4340 00001866 29D8 sub ax, bx 4341 00001868 83DA00 sbb dx, 0 4342 ; TmpVal1 = DiskSize - (BPB_ResvdSecCnt + 4343 ; RootDirsectors) 4344 ;mov bx, cx ; ch = 0 4345 ;shl bx, 8 ; * 256 4346 ; 11/02/2019 4347 0000186B 88CF mov bh, cl 4348 0000186D 30DB xor bl, bl 4349 0000186F B102 mov cl, 2 ; [BPB_NumFATs] 4350 00001871 01CB add bx, cx 4351 ; TmpVal2 = (256*BPB_SecPerClus)+BPB_NumFATs 4352 00001873 89D9 mov cx, bx 4353 00001875 4B dec bx ; TmpVal2-1 4354 00001876 01D8 add ax, bx 4355 00001878 83D200 adc dx, 0 4356 0000187B E8B8F5 call div32 4357 ; FATSz = (TmpVal1+(TmpVal2-1))/TmpVal2 4358 ; AX = FAT size in sectors 4359 ; DX = 0 4360 0000187E 894616 mov [bp+16h], ax ; [BPB_FATSz16] 4361 ; * 2 4362 00001881 D1E0 shl ax, 1 4363 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 4364 00001883 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4365 00001886 01C1 add cx, ax 4366 4367 ; 15/07/2024 (bugfix) 4368 00001888 894E42 mov [bp+42h], cx ; bsRootDirStart 4369 0000188B 8B1E[306C] mov bx, [root_dir_secs] 4370 0000188F 895E44 mov [bp+44h], bx ; bsRootDirSects 4371 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 4372 4373 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4374 ;add cx, [root_dir_secs] ; + RootDirsectors 4375 ; 15/07/2024 4376 00001892 01D9 add cx, bx 4377 00001894 29DB sub bx, bx ; BX = 0 4378 ; BX_CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4379 ; + RootDirSectors 4380 00001896 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 4381 ;sub dx, dx 4382 ; DX = 0 4383 00001899 21C0 and ax, ax 4384 0000189B 7506 jnz short FAT16_f_11 4385 0000189D 8B4620 mov ax, [bp+20h] ; [BPB_TotSec32] 4386 000018A0 8B5622 mov dx, [bp+22h] ; [BPB_TotSec32+2] 4387 FAT16_f_11: 4388 000018A3 29C8 sub ax, cx 4389 000018A5 19DA sbb dx, bx 4390 000018A7 890E[246C] mov [data_start], cx 4391 000018AB 891E[266C] mov [data_start+2], bx 4392 4393 ; 15/07/2024 (bugfix) 4394 000018AF 894E40 mov [bp+40h], cx ; bsDataStart 4395 4396 ; DX_AX = Data sectors 4397 000018B2 A3[286C] mov [data_sectors], ax 4398 000018B5 8916[2A6C] mov [data_sectors+2], dx 4399 000018B9 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4400 000018BC 30ED xor ch, ch 4401 000018BE E875F5 call div32 ; DX_AX/CX 4402 ; AX = Count of clusters (rounded down) 4403 ; DX = 0 4404 000018C1 A3[2C6C] mov [cluster_count], ax 4405 000018C4 8916[2E6C] mov [cluster_count+2], dx 4406 4407 000018C8 8D7E2B lea di, [bp+43] ; [BS_VolLab] 4408 000018CB E86CFD call write_volume_name 4409 000018CE 8D7627 lea si, [bp+39] ; [BS_VolID] 4410 000018D1 E8C5FD call write_volume_serial 4411 000018D4 E8D5FE call write_cluster_count 4412 4413 000018D7 E846FE call write_formatting_msg 4414 000018DA B000 mov al, 0 4415 000018DC E89EFE call write_format_percent_x 4416 4417 000018DF 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 4418 000018E2 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 4419 4420 000018E5 0106[246C] add [data_start], ax 4421 000018E9 1116[266C] adc [data_start+2], dx 4422 4423 ; DX_AX = FAT16 Boot Sector address 4424 ;mov bx, TRDOS_FAT16_hd_bs 4425 000018ED BB[9638] mov bx, RD5_FAT16_hd_bs ; 04/05/2024 4426 ; ES:BX = Boot Sector Buffer 4427 000018F0 E86505 call write_hd_sector 4428 000018F3 0F829AFE jc formatting_error 4429 000018F7 E84AFE call write_format_percent 4430 000018FA 83C001 add ax, 1 4431 000018FD 83D200 adc dx, 0 4432 ; write remain part of reserved sectors 4433 00001900 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 4434 ;sub cx, 1 4435 ;jna short FAT16_f_13 4436 ; 11/02/2019 4437 00001903 49 dec cx 4438 00001904 7418 jz short FAT16_f_13 4439 FAT16_f_12: 4440 00001906 51 push cx 4441 00001907 BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 4442 0000190A E84B05 call write_hd_sector 4443 0000190D 0F8280FE jc formatting_error 4444 00001911 E830FE call write_format_percent 4445 00001914 83C001 add ax, 1 4446 00001917 83D200 adc dx, 0 4447 0000191A 59 pop cx 4448 0000191B 49 dec cx ; dec cl 4449 0000191C 75E8 jnz short FAT16_f_12 4450 FAT16_f_13: 4451 ; write FAT sectors 4452 0000191E 8B0E[246C] mov cx, [data_start] ; lba/abs addr 4453 00001922 8B1E[266C] mov bx, [data_start+2] ; lba/abs addr 4454 4455 ; 11/02/2019 4456 00001926 2B0E[306C] sub cx, [root_dir_secs] 4457 0000192A 83DB00 sbb bx, 0 4458 4459 0000192D 53 push bx 4460 0000192E 51 push cx 4461 0000192F BB[246A] mov bx, HDFORMAT_FATBUFFER 4462 ; ES:BX = FAT Sector Buffer 4463 00001932 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 4464 00001935 B5FF mov ch, 0FFh 4465 00001937 890F mov [bx], cx ; 0FFF8h 4466 00001939 88E9 mov cl, ch ; cx = 0FFFFh 4467 0000193B 894F02 mov [bx+2], cx 4468 ;inc cx 4469 0000193E E81705 call write_hd_sector 4470 00001941 0F824CFE jc formatting_error 4471 00001945 E8FCFD call write_format_percent 4472 ;mov bx, HDFORMAT_FATBUFFER 4473 00001948 B90000 mov cx, 0 4474 0000194B 890F mov [bx], cx 4475 0000194D 894F02 mov [bx+2], cx 4476 00001950 EB0F jmp short FAT16_f_15 4477 FAT16_f_14: 4478 00001952 53 push bx 4479 00001953 51 push cx 4480 00001954 BB[246A] mov bx, HDFORMAT_FATBUFFER 4481 00001957 E8FE04 call write_hd_sector 4482 0000195A 0F8233FE jc formatting_error 4483 0000195E E8E3FD call write_format_percent 4484 FAT16_f_15: 4485 00001961 59 pop cx 4486 00001962 5B pop bx 4487 00001963 83C001 add ax, 1 4488 00001966 83D200 adc dx, 0 4489 00001969 39DA cmp dx, bx 4490 0000196B 72E5 jb short FAT16_f_14 4491 0000196D 39C8 cmp ax, cx 4492 0000196F 72E1 jb short FAT16_f_14 4493 4494 ; write root directory sectors 4495 ; as empty sectors 4496 00001971 8B0E[306C] mov cx, [root_dir_secs] 4497 FAT16_f_16: 4498 00001975 51 push cx 4499 00001976 BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 4500 00001979 E8DC04 call write_hd_sector 4501 0000197C 0F8211FE jc formatting_error 4502 00001980 E8C1FD call write_format_percent 4503 00001983 83C001 add ax, 1 4504 00001986 83D200 adc dx, 0 4505 00001989 59 pop cx 4506 0000198A 49 dec cx 4507 0000198B 75E8 jnz short FAT16_f_16 4508 4509 ; write DATA sectors 4510 ; (after root directory sectors) 4511 0000198D 8B0E[286C] mov cx, [data_sectors] 4512 00001991 8B1E[2A6C] mov bx, [data_sectors+2] 4513 ; 11/02/2019 4514 00001995 43 inc bx ; 0 -> 1, 1-> 2 4515 FAT16_f_17: 4516 00001996 53 push bx 4517 00001997 51 push cx 4518 00001998 BB[2266] mov bx, HDFORMAT_SECBUFFER 4519 0000199B E8BA04 call write_hd_sector 4520 0000199E 0F82EFFD jc formatting_error 4521 000019A2 E89FFD call write_format_percent 4522 000019A5 59 pop cx 4523 000019A6 5B pop bx 4524 000019A7 83C001 add ax, 1 4525 000019AA 83D200 adc dx, 0 4526 000019AD 49 dec cx 4527 000019AE 75E6 jnz short FAT16_f_17 4528 000019B0 4B dec bx 4529 000019B1 75E3 jnz short FAT16_f_17 4530 4531 ; If there are, format remain sectors which are 4532 ; at beyond of data clusters, with zero bytes. 4533 4534 000019B3 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 4535 000019B6 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4536 4537 000019B9 837E1300 cmp word [bp+13h], 0 ; [BPB_TotSec16] 4538 000019BD 0F843CFC jz FAT16_f_18 4539 000019C1 034E13 add cx, [bp+13h] ; [BPB_TotSec16] 4540 000019C4 83D300 adc bx, 0 4541 000019C7 E939FC jmp FAT16_f_19 4542 4543 FAT12_hdi_format: 4544 ;mov bp, TRDOS_FAT12_hd_bs 4545 000019CA BD[963A] mov bp, RD5_FAT12_hd_bs ; 04/05/2024 4546 000019CD 8D7E03 lea di, [bp+3] 4547 000019D0 BE[0C66] mov si, bs_oem_name 4548 000019D3 B90400 mov cx, 4 4549 000019D6 F3A5 rep movsw 4550 000019D8 A1[AA40] mov ax, [sectors] 4551 000019DB 894618 mov [bp+18h], ax ; [BPB_SecPerTrk] 4552 000019DE A1[AC40] mov ax, [heads] 4553 000019E1 89461A mov [bp+1Ah], ax ; [BPB_NumHeads] 4554 000019E4 A1[AC6E] mov ax, [pp_StartSector] 4555 000019E7 89461C mov [bp+1Ch], ax ; [BPB_HiddSec] 4556 000019EA A1[AE6E] mov ax, [pp_StartSector+2] 4557 000019ED 89461E mov [bp+1Eh], ax ; [BPB_HiddSec+2] 4558 ;mov ax, [pp_Sectors] 4559 000019F0 A1[E06E] mov ax, [ppn_Sectors] ; 16/02/2019 4560 000019F3 894613 mov [bp+13h], ax ; [BPB_TotSec16] 4561 4562 ; 11/02/2019 4563 000019F6 31F6 xor si, si ; reset (FAT size fix) flag 4564 000019F8 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4565 000019FB 8B5611 mov dx, [bp+11h] ; [BPB_RootEntCnt] = 512 4566 000019FE 83C20F add dx, 15 ; (16-1) (512-1) 4567 00001A01 C1EA04 shr dx, 4 ; /16 (*32/512) 4568 ; AX = Root dir sectors 4569 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4570 00001A04 01D1 add cx, dx ; + RootDirsectors ; + 32 4571 00001A06 890E[306C] mov [root_dir_secs], cx ; = 33 4572 4573 ; 11/02/2019 4574 ;sub ax, 33 ; 1 reserved sector, 32 root dir sectors 4575 ; .. now AX has number of data sectors 4576 ; + 2* (FAT sectors) 4577 00001A0A 29C8 sub ax, cx 4578 FAT12_f_10: ; 11/02/2019 4579 ; Sectors per cluster calculation 4580 ; (According to MS FAT32 FS specification.) 4581 ;mov cx, 1 ; 1 sector per cluster 4582 00001A0C B101 mov cl, 1 ; CH = 0 4583 FAT12_f_0: 4584 00001A0E 3DF50F cmp ax, 4085 ; Max. cluster count for FAT12 4585 00001A11 7206 jb short FAT12_f_1 4586 00001A13 D0E1 shl cl, 1 ; *2 4587 00001A15 D1E8 shr ax, 1 ; /2 4588 00001A17 EBF5 jmp short FAT12_f_0 4589 FAT12_f_1: 4590 00001A19 884E0D mov [bp+0Dh], cl ; [BPB_SecPerClus] 4591 ;mov byte [bp+10h], 2 ; [BPB_NumFATs] 4592 ;mov word [bp+0Eh], 1 ; [BPB_RsvdSecCnt] 4593 ;mov word [bp+11h], 512 ; [BPB_RootEntCnt] 4594 4595 ; Calculating FAT size in sectors 4596 ; AX = partition (volume) size in sectors 4597 ; CX = sectors per clusters 4598 00001A1C 31D2 xor dx, dx 4599 00001A1E F7F1 div cx 4600 ; AX = cluster count (only for FAT size calc) 4601 ; DX = 0 4602 00001A20 83C002 add ax, 2 ; cluster 2 to ... 4603 00001A23 89C2 mov dx, ax 4604 00001A25 D1E2 shl dx, 1 4605 00001A27 01D0 add ax, dx ; *3 4606 00001A29 D1E8 shr ax, 1 ; /2 4607 00001A2B 83D000 adc ax, 0 ; +0.5 -> +1 4608 4609 ; AX = FAT bytes for 12 bit cluster numbers 4610 4611 00001A2E B90002 mov cx, 512 ; [BPB_BytesPerSec] 4612 00001A31 01C8 add ax, cx 4613 00001A33 48 dec ax ; [BPB_BytesPerSec] - 1 4614 00001A34 29D2 sub dx, dx 4615 00001A36 F7F1 div cx 4616 00001A38 894616 mov [bp+16h], ax ; [BPB_FATSz16] 4617 ; * 2 4618 00001A3B D1E0 shl ax, 1 4619 ; AX = [BPB_NumFATs] * [BPB_FATSz16] 4620 4621 ;mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4622 ;add cx, ax 4623 ;mov ax, [bp+11h] ; [BPB_RootEntCnt] = 512 4624 ;add ax, 15 ; (16-1) (512-1) 4625 ;shr ax, 4 ; /16 (*32/512) 4626 ;; AX = Root dir sectors 4627 ;; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4628 ;add cx, ax ; + RootDirsectors 4629 ;mov [root_dir_secs], ax 4630 4631 ; 11/02/2019 4632 ;mov cx, 33 4633 00001A3D 8B0E[306C] mov cx, [root_dir_secs] 4634 4635 ; 15/07/2024 (bugfix) 4636 ; ax = 2 * FAT size (in sectors) 4637 00001A41 03460E add ax, [bp+0Eh] ; total FAT sectors + reserved sectors 4638 00001A44 894642 mov [bp+42h], ax ; bsRootDirStart 4639 00001A47 894E44 mov [bp+44h], cx ; bsRootDirSects 4640 ;mov word [bp+46h], 16 ; bsDirEntsPerSec 4641 4642 ; 15/07/2024 4643 ;add cx, [bp+0Eh] ; [BPB_RsvdSecCnt] ; 1 4644 ; cx = root directory sectors + reserved sectors 4645 00001A4A 01C1 add cx, ax 4646 ; cx = root dir sects + rsvd sects + total FAT sects 4647 4648 ; CX = [BPB_RsvdSecCnt]+([BPB_NumFATs]*[BPB_FATSz16]) 4649 ; + RootDirSectors 4650 00001A4C 8B4613 mov ax, [bp+13h] ; [BPB_TotSec16] 4651 00001A4F 29C8 sub ax, cx 4652 ; AX = data sectors 4653 ; cH = 0 4654 4655 ; 11/02/2019 - fix FAT size (better method) 4656 00001A51 09F6 or si, si 4657 00001A53 7504 jnz short FAT12_f_9 4658 4659 00001A55 89C6 mov si, ax ; ax = data sectors 4660 00001A57 EBB3 jmp short FAT12_f_10 4661 4662 FAT12_f_9: 4663 00001A59 31D2 xor dx, dx 4664 00001A5B 890E[246C] mov [data_start], cx 4665 00001A5F 8916[266C] mov [data_start+2], dx ; 0 4666 4667 ; 15/07/2024 (bugfix) 4668 00001A63 894E40 mov [bp+40h], cx ; bsDataStart 4669 4670 ; DX_AX = Data sectors 4671 00001A66 A3[286C] mov [data_sectors], ax 4672 00001A69 8916[2A6C] mov [data_sectors+2], dx ; 0 4673 00001A6D 8A4E0D mov cl, [bp+0Dh] ; [BPB_SecPerClus] 4674 00001A70 28ED sub ch, ch 4675 00001A72 F7F1 div cx 4676 ; AX = Count of clusters (rounded down) 4677 00001A74 29D2 sub dx, dx ; 0 4678 00001A76 A3[2C6C] mov [cluster_count], ax 4679 00001A79 8916[2E6C] mov [cluster_count+2], dx ; 0 4680 4681 00001A7D 8D7E2B lea di, [bp+43] ; [BS_VolLab] 4682 00001A80 E8B7FB call write_volume_name 4683 00001A83 8D7627 lea si, [bp+39] ; [BS_VolID] 4684 00001A86 E810FC call write_volume_serial 4685 00001A89 E820FD call write_cluster_count 4686 4687 00001A8C E891FC call write_formatting_msg 4688 00001A8F B000 mov al, 0 4689 00001A91 E8E9FC call write_format_percent_x 4690 4691 00001A94 8B461C mov ax, [bp+1Ch] ; [BPB_HiddSec] 4692 00001A97 8B561E mov dx, [bp+1Eh] ; [BPB_HiddSec+2] 4693 4694 00001A9A 0106[246C] add [data_start], ax 4695 00001A9E 1116[266C] adc [data_start+2], dx 4696 4697 ; DX_AX = FAT12 Boot Sector address 4698 ;mov bx, TRDOS_FAT12_hd_bs 4699 00001AA2 BB[963A] mov bx, RD5_FAT12_hd_bs ; 04/05/2024 4700 ; ES:BX = Boot Sector Buffer 4701 00001AA5 E8B003 call write_hd_sector 4702 00001AA8 0F82E5FC jc formatting_error 4703 00001AAC E895FC call write_format_percent 4704 00001AAF 83C001 add ax, 1 4705 00001AB2 83D200 adc dx, 0 4706 ; write remain part of reserved sectors 4707 00001AB5 8B4E0E mov cx, [bp+0Eh] ; [BPB_RsvdSecCnt] 4708 ;sub cx, 1 4709 ;jna short FAT12_f_3 4710 ; 11/02/2019 4711 00001AB8 49 dec cx 4712 00001AB9 7418 jz short FAT12_f_3 4713 FAT12_f_2: 4714 00001ABB 51 push cx 4715 00001ABC BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 4716 00001ABF E89603 call write_hd_sector 4717 00001AC2 0F82CBFC jc formatting_error 4718 00001AC6 E87BFC call write_format_percent 4719 00001AC9 83C001 add ax, 1 4720 00001ACC 83D200 adc dx, 0 4721 00001ACF 59 pop cx 4722 00001AD0 49 dec cx ; dec cl 4723 00001AD1 75E8 jnz short FAT12_f_2 4724 FAT12_f_3: 4725 ; write FAT sectors 4726 00001AD3 8B0E[246C] mov cx, [data_start] ; lba/abs addr 4727 00001AD7 8B1E[266C] mov bx, [data_start+2] ; lba/abs addr 4728 4729 ; 11/02/2019 4730 00001ADB 2B0E[306C] sub cx, [root_dir_secs] 4731 00001ADF 83DB00 sbb bx, 0 4732 4733 00001AE2 53 push bx 4734 00001AE3 51 push cx 4735 00001AE4 BB[246A] mov bx, HDFORMAT_FATBUFFER 4736 ; ES:BX = FAT Sector Buffer 4737 00001AE7 8A4E15 mov cl, [bp+15h] ; [BPB_Media] 4738 00001AEA B5FF mov ch, 0FFh 4739 00001AEC 890F mov [bx], cx ; 0FFF8h 4740 00001AEE 886F02 mov [bx+2], ch ; 0FFFFF8h 4741 ;xor cx, cx 4742 00001AF1 E86403 call write_hd_sector 4743 00001AF4 0F8299FC jc formatting_error 4744 00001AF8 E849FC call write_format_percent 4745 ;mov bx, HDFORMAT_FATBUFFER 4746 00001AFB B90000 mov cx, 0 4747 00001AFE 890F mov [bx], cx 4748 00001B00 884F02 mov [bx+2], cl 4749 00001B03 EB0F jmp short FAT12_f_5 4750 FAT12_f_4: 4751 00001B05 53 push bx 4752 00001B06 51 push cx 4753 00001B07 BB[246A] mov bx, HDFORMAT_FATBUFFER 4754 00001B0A E84B03 call write_hd_sector 4755 00001B0D 0F8280FC jc formatting_error 4756 00001B11 E830FC call write_format_percent 4757 FAT12_f_5: 4758 00001B14 59 pop cx 4759 00001B15 5B pop bx 4760 00001B16 83C001 add ax, 1 4761 00001B19 83D200 adc dx, 0 4762 00001B1C 39DA cmp dx, bx 4763 00001B1E 72E5 jb short FAT12_f_4 4764 00001B20 39C8 cmp ax, cx 4765 00001B22 72E1 jb short FAT12_f_4 4766 4767 ; write root directory sectors 4768 ; as empty sectors 4769 00001B24 8B0E[306C] mov cx, [root_dir_secs] 4770 FAT12_f_6: 4771 00001B28 51 push cx 4772 00001B29 BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 4773 00001B2C E82903 call write_hd_sector 4774 00001B2F 0F825EFC jc formatting_error 4775 00001B33 E80EFC call write_format_percent 4776 00001B36 83C001 add ax, 1 4777 00001B39 83D200 adc dx, 0 4778 00001B3C 59 pop cx 4779 00001B3D 49 dec cx ; dec cl 4780 00001B3E 75E8 jnz short FAT12_f_6 4781 4782 ; write DATA sectors 4783 ; (after root directory sectors) 4784 00001B40 8B0E[286C] mov cx, [data_sectors] 4785 ;mov bx, [data_sectors+2] 4786 ;inc bx ; 11/02/2019 4787 FAT12_f_7: 4788 ;push bx 4789 00001B44 51 push cx 4790 00001B45 BB[2266] mov bx, HDFORMAT_SECBUFFER 4791 00001B48 E80D03 call write_hd_sector 4792 00001B4B 0F8242FC jc formatting_error 4793 00001B4F E8F2FB call write_format_percent 4794 00001B52 59 pop cx 4795 ;pop bx 4796 00001B53 83C001 add ax, 1 4797 00001B56 83D200 adc dx, 0 4798 00001B59 49 dec cx 4799 00001B5A 75E8 jnz short FAT12_f_7 4800 ;dec bx 4801 ;jnz short FAT12_f_7 4802 4803 ; If there are, format remain sectors which are 4804 ; at beyond of data clusters, with zero bytes. 4805 4806 00001B5C 8B4E1C mov cx, [bp+1Ch] ; [BPB_HiddSec] 4807 00001B5F 8B5E1E mov bx, [bp+1Eh] ; [BPB_HiddSec+2] 4808 4809 00001B62 034E13 add cx, [bp+13h] ; [BPB_TotSec16] 4810 00001B65 83D300 adc bx, 0 4811 00001B68 E998FA jmp FAT12_f_8 4812 4813 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4814 ; SINGLIX FS FORMATTING 4815 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4816 4817 SINGLIX_hdi_format: 4818 ; 06/01/2018 4819 ; 05/01/2018 4820 ; If Sectors/Track = 17, use CHS+LBA type boot sector 4821 00001B6B 8B1E[AA40] mov bx, [sectors] 4822 00001B6F 83FB11 cmp bx, 17 4823 00001B72 7711 ja short SINGLIX_fs1_f_1 4824 SINGLIX_fs1_f_0: 4825 00001B74 BD[963C] mov bp, TRDOS_TRFS1_chs_bs 4826 00001B77 887E2D mov [bp+45], bh ; 0 ; [bs_LBA_Ready] = 0 4827 00001B7A 885E2E mov [bp+46], bl ; [bs_Disk_SecPerTrack] 4828 00001B7D A0[AC40] mov al, [heads] 4829 00001B80 88462F mov [bp+47], al ; [bs_Disk_Heads] 4830 00001B83 EB15 jmp short SINGLIX_fs1_f_3 4831 SINGLIX_fs1_f_1: 4832 ; Sectors per Track = 63 4833 ; If disk capacity >= 63*16*1024 use LBA type boot sector 4834 00001B85 8B0E[AC40] mov cx, [heads] 4835 00001B89 A1[AE40] mov ax, [cylinders] 4836 00001B8C F7E1 mul cx 4837 00001B8E 21D2 and dx, dx 4838 00001B90 7505 jnz short SINGLIX_fs1_f_2 4839 00001B92 3D0040 cmp ax, 16384 4840 00001B95 72DD jb short SINGLIX_fs1_f_0 4841 SINGLIX_fs1_f_2: 4842 00001B97 BD[963E] mov bp, TRDOS_TRFS1_lba_bs 4843 ;mov byte [bp+45], 1 ; [bs_LBA_Ready] = 1 4844 SINGLIX_fs1_f_3: 4845 ;mov ax, [pp_Sectors] 4846 ;mov dx, [pp_Sectors+2] 4847 ; 16/02/2019 4848 00001B9A A1[E06E] mov ax, [ppn_Sectors] 4849 00001B9D 8B16[E26E] mov dx, [ppn_Sectors+2] 4850 00001BA1 894610 mov [bp+16], ax ; [bsVolumeSize] 4851 00001BA4 895612 mov [bp+18], dx ; [bsVolumeSize+2] 4852 00001BA7 8B0E[AC6E] mov cx, [pp_StartSector] 4853 00001BAB 8B1E[AE6E] mov bx, [pp_StartSector+2] 4854 00001BAF 894E0C mov [bp+12], cx ; [bsBeginSector] 4855 00001BB2 895E0E mov [bp+14], bx ; [bsBeginSector+2] 4856 00001BB5 C6462C80 mov byte [bp+44], 80h ; [bsDriveNumber] ; hd0 4857 4858 ; Prepare MAT 4859 00001BB9 A3[886C] mov [MAT_VolumeSize], ax ; Total Sectors of the FS 4860 00001BBC 8916[8A6C] mov [MAT_VolumeSize+2], dx 4861 00001BC0 890E[8C6C] mov [MAT_BeginSector], cx ; Beginning Sector of the FS 4862 00001BC4 891E[8E6C] mov [MAT_BeginSector+2], bx 4863 ;mov cx, [bp+24] ; [bsMATLocation] 4864 ;mov bx, [bp+26] ; [bsMATLocation+2] 4865 ;add cx, 1 4866 ;adc bx, 0 4867 ; Note: (as Default) MAT Address = 1, DAT Address = 2 4868 00001BC8 B90200 mov cx, 2 4869 ;xor bx, bx ; 0 4870 ;mov [bp+24], cx ; [bsMATLocation] 4871 ;mov [bp+26], bx ; [bsMATLocation+2] 4872 00001BCB 890E[906C] mov [DAT_Address], cx 4873 ;mov [DAT_Address+2], bx 4874 ; DX_AX = FS1 Volume Size 4875 00001BCF 83C007 add ax, 7 ; 7 bits more (for round up) 4876 00001BD2 83D200 adc dx, 0 4877 00001BD5 B90800 mov cx, 8 ; 1 DAT byte == 8 sectors 4878 00001BD8 E85BF2 call div32 4879 ; DX_AX = DAT bytes 4880 00001BDB B9FF01 mov cx, 511 4881 00001BDE 01C8 add ax, cx 4882 00001BE0 83D200 adc dx, 0 4883 00001BE3 41 inc cx ; 512 4884 00001BE4 E84FF2 call div32 4885 ; DX_AX = DAT sectors (DX must be 0 for volume sizes < 128GB) 4886 00001BE7 A3[946C] mov [DAT_SectorCount], ax 4887 ;mov [DAT_SectorCount+2], dx ; 0 4888 4889 00001BEA 83C002 add ax, 2 ; BS + MAT 4890 ;adc dx, 0 4891 00001BED 89461C mov [bp+28], ax ; [bsRootDirDT] ; RDT address (offset) 4892 ;mov [bp+30], dx 4893 4894 ; Free Sectors = Total Sectors - (BS+MAT+DATsects+RDT+4) 4895 00001BF0 83C005 add ax, 5 ; DATsects + (BS+MAT+RDT+4) 4896 00001BF3 89C2 mov dx, ax 4897 00001BF5 8B0E[886C] mov cx, [MAT_VolumeSize] 4898 00001BF9 8B1E[8A6C] mov bx, [MAT_VolumeSize+2] 4899 00001BFD 29C1 sub cx, ax 4900 00001BFF 83DB00 sbb bx, 0 4901 00001C02 890E[986C] mov [MAT_FreeSectors], cx 4902 00001C06 891E[9A6C] mov [MAT_FreeSectors+2], bx 4903 00001C0A A3[9C6C] mov [MAT_FirstFreeSector], ax 4904 ;mov word [MAT_FirstFreesector+2] , 0 4905 4906 00001C0D BF[386C] mov di, fs_volume_name 4907 00001C10 E820FA call write_fs_volume_name 4908 00001C13 BE[786C] mov si, fs_volume_serial 4909 00001C16 E880FA call write_volume_serial 4910 4911 ; Modify FS volume name 4912 ; (Convert 20h tail bytes to 0) 4913 00001C19 B94000 mov cx, 64 4914 00001C1C BE[386C] mov si, fs_volume_name 4915 00001C1F 31DB xor bx, bx 4916 00001C21 B0FF mov al, 0FFh 4917 modify_fs_vname_1: 4918 00001C23 88C4 mov ah, al 4919 00001C25 AC lodsb 4920 00001C26 3C20 cmp al, 20h 4921 00001C28 7708 ja short modify_fs_vname_2 4922 00001C2A 80FC20 cmp ah, 20h 4923 00001C2D 7603 jna short modify_fs_vname_2 4924 00001C2F 89F3 mov bx, si 4925 00001C31 4B dec bx 4926 modify_fs_vname_2: 4927 00001C32 E2EF loop modify_fs_vname_1 4928 00001C34 09DB or bx, bx 4929 00001C36 740B jz short modify_fs_vname_3 4930 00001C38 89DF mov di, bx 4931 00001C3A B9[786C] mov cx, fs_volume_name+64 4932 00001C3D 29D9 sub cx, bx 4933 00001C3F 30C0 xor al, al 4934 00001C41 F3AA rep stosb 4935 4936 modify_fs_vname_3: 4937 00001C43 E8DAFA call write_formatting_msg 4938 00001C46 B000 mov al, 0 4939 00001C48 E832FB call write_format_percent_x 4940 4941 00001C4B 8B460C mov ax, [bp+12] ; [bsBeginSector] 4942 00001C4E 8B560E mov dx, [bp+14] ; [bsBeginSector+2] 4943 4944 ; DX_AX = TRFS1 Boot Sector address 4945 00001C51 89EB mov bx, bp 4946 ; ES:BX = Boot Sector Buffer 4947 00001C53 E80202 call write_hd_sector 4948 00001C56 0F8237FB jc formatting_error 4949 4950 00001C5A 83C001 add ax, 1 4951 00001C5D 83D200 adc dx, 0 4952 4953 ; DX_AX = MAT (DAT header) sector address 4954 00001C60 BB[846C] mov bx, FS_MAT_Buffer 4955 ; 16/02/2019 4956 00001C63 C7074D41 mov word [bx],'MA' 4957 00001C67 C6470254 mov byte [bx+2],'T' 4958 00001C6B E8EA01 call write_hd_sector 4959 00001C6E 0F821FFB jc formatting_error 4960 00001C72 E80FFB call write_fs_format_percent 4961 4962 ; Calculate DAT bits 4963 ; NOTE: 4096 bits per DAT sector 4964 00001C75 A1[9C6C] mov ax, [MAT_FirstFreeSector] 4965 ;mov dx, [MAT_FirstFreeSector+2] 4966 00001C78 31D2 xor dx, dx 4967 00001C7A 52 push dx 4968 00001C7B 50 push ax 4969 00001C7C B90010 mov cx, 4096 4970 00001C7F E8B4F1 call div32 4971 00001C82 891E[7C6C] mov [DAT_FFBit], bx 4972 00001C86 A3[7E6C] mov [DAT_FFSector], ax 4973 00001C89 58 pop ax 4974 00001C8A 5A pop dx 4975 00001C8B 83E801 sub ax, 1 4976 00001C8E 83DA00 sbb dx, 0 4977 00001C91 0306[986C] add ax, [MAT_FreeSectors] 4978 00001C95 1316[9A6C] adc dx, [MAT_FreeSectors+2] 4979 00001C99 E89AF1 call div32 4980 00001C9C 891E[806C] mov [DAT_LFBit], bx 4981 00001CA0 A3[826C] mov [DAT_LFSector], ax 4982 4983 00001CA3 31F6 xor si, si ; 0 4984 SINGLIX_fs1_f_4: 4985 ; calculate free bits for current DAT sector 4986 ; (to be written) 4987 00001CA5 BF[A06C] mov di, FS_DAT_Buffer 4988 00001CA8 3B36[7E6C] cmp si, [DAT_FFSector] 4989 00001CAC 7431 je short SINGLIX_fs1_f_7 4990 00001CAE 724D jb short SINGLIX_fs1_f_9 4991 00001CB0 3B36[826C] cmp si, [DAT_LFSector] 4992 00001CB4 7224 jb short SINGLIX_fs1_f_6 4993 00001CB6 7745 ja short SINGLIX_fs1_f_9 4994 00001CB8 8B1E[806C] mov bx, [DAT_LFBit] 4995 00001CBC B0FF mov al, 0FFh 4996 00001CBE 88DC mov ah, bl 4997 00001CC0 C1EB03 shr bx, 3 ; bit count to byte count 4998 00001CC3 7409 jz short SINGLIX_fs1_f_5 4999 00001CC5 89D9 mov cx, bx 5000 00001CC7 F3AA rep stosb 5001 00001CC9 BF[A06C] mov di, FS_DAT_Buffer 5002 00001CCC 01DF add di, bx 5003 SINGLIX_fs1_f_5: 5004 00001CCE 80E407 and ah, 7 5005 00001CD1 88E1 mov cl, ah 5006 00001CD3 D2E0 shl al, cl 5007 00001CD5 F6D0 not al 5008 00001CD7 AA stosb 5009 ;mov cx, 511 5010 ;sub cx, bx 5011 ;jna short SINGLIX_fs1_f_9 5012 ;mov al, 0 ; out of volume bits (=0) 5013 ;rep stosb 5014 00001CD8 EB23 jmp short SINGLIX_fs1_f_9 5015 SINGLIX_fs1_f_6: 5016 00001CDA B90002 mov cx, 512 5017 00001CDD EB1A jmp short SINGLIX_fs1_f_8 5018 SINGLIX_fs1_f_7: 5019 00001CDF 8B1E[7C6C] mov bx, [DAT_FFBit] 5020 00001CE3 88D9 mov cl, bl 5021 00001CE5 80E107 and cl, 7 5022 00001CE8 C1EB03 shr bx, 3 ; from bits to bytes 5023 00001CEB 01DF add di, bx 5024 00001CED B0FF mov al, 0FFh 5025 00001CEF D2E0 shl al, cl 5026 00001CF1 AA stosb 5027 00001CF2 B9FF01 mov cx, 511 5028 00001CF5 29D9 sub cx, bx 5029 00001CF7 7604 jna short SINGLIX_fs1_f_9 5030 SINGLIX_fs1_f_8: 5031 00001CF9 B0FF mov al, 0FFh ; Free sector bits (=1) 5032 00001CFB F3AA rep stosb 5033 SINGLIX_fs1_f_9: 5034 00001CFD A1[8C6C] mov ax, [MAT_BeginSector] 5035 00001D00 8B16[8E6C] mov dx, [MAT_BeginSector+2] 5036 ;add ax, [DAT_Address] ; = 2 5037 ;adc dx, [DAT_Address+2] 5038 00001D04 83C002 add ax, 2 5039 00001D07 83D200 adc dx, 0 5040 00001D0A 01F0 add ax, si 5041 00001D0C 83D200 adc dx, 0 5042 ; Write DAT sector(s) 5043 ; DX_AX = Disk Allocation Table sector address 5044 00001D0F BB[A06C] mov bx, FS_DAT_Buffer 5045 00001D12 E84301 call write_hd_sector 5046 00001D15 0F8278FA jc formatting_error 5047 00001D19 E868FA call write_fs_format_percent 5048 ; Clear DAT buffer again (for next stage) 5049 00001D1C B90001 mov cx, 256 5050 00001D1F BF[A06C] mov di, FS_DAT_Buffer 5051 00001D22 29C0 sub ax, ax 5052 00001D24 F3AB rep stosw 5053 5054 00001D26 46 inc si 5055 5056 00001D27 3B36[946C] cmp si, [DAT_SectorCount] 5057 00001D2B 0F8676FF jna SINGLIX_fs1_f_4 5058 5059 ; ;;; 5060 5061 ; DAT sectors has been written.. 5062 ; Now, Root Directory Description Table is in order 5063 5064 00001D2F BF[A06C] mov di, FS_RDT_Buffer 5065 00001D32 B84444 mov ax, 'DD' 5066 00001D35 AB stosw 5067 00001D36 30E4 xor ah, ah 5068 00001D38 B054 mov al, 'T' 5069 00001D3A AB stosw 5070 00001D3B B80002 mov ax, 512 ; Sector size (Bytes per sector) 5071 00001D3E AB stosw 5072 00001D3F 31C0 xor ax, ax ; RDT sequence number (= 0, section 1) 5073 00001D41 AB stosw 5074 ; RDT address 5075 00001D42 A1[946C] mov ax, [DAT_SectorCount] 5076 00001D45 8B16[966C] mov dx, [DAT_SectorCount+2] 5077 00001D49 83C002 add ax, 2 ; BS + MAT 5078 00001D4C 83D200 adc dx, 0 5079 00001D4F AB stosw 5080 00001D50 89D0 mov ax, dx 5081 00001D52 AB stosw 5082 00001D53 29C0 sub ax, ax ; Next RDT number 5083 00001D55 AB stosw 5084 00001D56 AB stosw 5085 00001D57 B80400 mov ax, 4 ; Sector count of this section 5086 ; (4*512)/4 = 512 root dir entries 5087 00001D5A AB stosw 5088 00001D5B 30C0 xor al, al 5089 00001D5D AB stosw 5090 ; Volume beginning sector 5091 00001D5E 8B460C mov ax, [bp+12] ; [bsBeginSector] 5092 00001D61 8B560E mov dx, [bp+14] ; [bsBeginSector+2] 5093 00001D64 AB stosw 5094 00001D65 89D0 mov ax, dx 5095 00001D67 AB stosw 5096 00001D68 31C0 xor ax, ax 5097 00001D6A 48 dec ax ; 0FFFFh 5098 ; Parent Dir Serial (= FFFFFFFFh for root dir) 5099 00001D6B AB stosw 5100 00001D6C AB stosw 5101 5102 set_fs_volume_serial_number: 5103 00001D6D BE[786C] mov si, fs_volume_serial 5104 00001D70 A5 movsw 5105 00001D71 A5 movsw 5106 5107 00001D72 29C0 sub ax, ax 5108 00001D74 AA stosb ; sub directory level = 0 5109 00001D75 AA stosb ; 0, reverved 5110 00001D76 B004 mov al, 00000100b ; (DOS) System attribute 5111 00001D78 AA stosb ; (DOS) Basic attributes 5112 00001D79 28C0 sub al, al ; Extended attributes (0 for TRDOS 386) 5113 00001D7B AA stosb 5114 00001D7C 29C0 sub ax, ax ; reserved (8) bytes for TR-MULTIX 5115 00001D7E AB stosw 5116 00001D7F AB stosw 5117 00001D80 AB stosw 5118 00001D81 AB stosw 5119 00001D82 B85254 mov ax, 'RT' ; TRFS Root directory signature 5120 00001D85 AB stosw 5121 00001D86 31C0 xor ax, ax ; Country (language, date, text format) 5122 ; (0 = Default, 1 = USA, 90 = Turkiye) 5123 00001D88 AA stosb 5124 00001D89 AA stosb ; Time Zone (0 = GMT = default ; -11 to +12) 5125 5126 00001D8A 89FE mov si, di 5127 ; get the date (from RTC) 5128 00001D8C B404 mov ah, 4 5129 00001D8E CD1A int 1Ah 5130 ; Creating Date (of root directory) 5131 00001D90 86E9 xchg ch, cl ; 07/01/2018 5132 00001D92 89C8 mov ax, cx ; cl = century (BCD), ch = year (BCD) 5133 00001D94 AB stosw 5134 00001D95 88F0 mov al, dh ; month (BCD) 5135 00001D97 AA stosb 5136 00001D98 88D0 mov al, dl ; day (BCD) 5137 00001D9A AA stosb 5138 ; get the time (from RTC) 5139 00001D9B B402 mov ah, 2 5140 00001D9D CD1A int 1Ah 5141 ; Creating Time (of root directory) 5142 00001D9F 86CD xchg cl, ch ; ch = hour (BCD), cl = minute (BSD) 5143 00001DA1 89C8 mov ax, cx ; al = hour, ah = minute 5144 00001DA3 AB stosw 5145 00001DA4 88F0 mov al, dh ; seconds (BCD) 5146 00001DA6 AA stosb 5147 00001DA7 88D0 mov al, dl ; daylight savings time option 5148 00001DA9 AA stosb 5149 ; Set Last Modification Date&Time 5150 00001DAA B90400 mov cx, 4 5151 00001DAD F3A5 rep movsw ; copy creating date&time values to 5152 ; last modification date time values 5153 ; (last modif date&time = creating date&time) 5154 5155 set_fs_volume_name: 5156 00001DAF BE[386C] mov si, fs_volume_name 5157 00001DB2 B120 mov cl, 32 5158 00001DB4 F3A5 rep movsw 5159 5160 ; Fill remain bytes (of this RDT) with zero 5161 00001DB6 B9C000 mov cx, (128+256)/2 5162 00001DB9 31C0 xor ax, ax 5163 00001DBB F3AB rep stosw 5164 5165 ; RDT is ready here... 5166 5167 00001DBD 8B461C mov ax, [bp+28] ; [bsRootDirDT] 5168 ;mov dx, [bp+30] ; [bsRootDirDT+2] 5169 00001DC0 31D2 xor dx, dx 5170 00001DC2 03460C add ax, [bp+12] ; [bsBeginSector] 5171 00001DC5 13560E adc dx, [bp+14] ; [bsBeginSector+2] 5172 5173 ; Write RDT sector 5174 ; DX_AX = Root Directory Description Table address 5175 00001DC8 BB[A06C] mov bx, FS_RDT_Buffer 5176 00001DCB E88A00 call write_hd_sector 5177 00001DCE 0F82BFF9 jc formatting_error 5178 00001DD2 E8AFF9 call write_fs_format_percent 5179 5180 00001DD5 83C001 add ax, 1 5181 00001DD8 83D200 adc dx, 0 5182 5183 ; write root directory data sectors 5184 00001DDB B90400 mov cx, 4 5185 5186 SINGLIX_fs1_f_10: 5187 00001DDE 51 push cx 5188 ; Write root directory sector(s) 5189 ; DX_AX = Root Directory Sector address 5190 00001DDF BB[246A] mov bx, HDFORMAT_EMPTY_BUFF 5191 00001DE2 E87300 call write_hd_sector 5192 00001DE5 0F82A8F9 jc formatting_error 5193 00001DE9 E898F9 call write_fs_format_percent 5194 00001DEC 83C001 add ax, 1 5195 00001DEF 83D200 adc dx, 0 5196 00001DF2 59 pop cx 5197 00001DF3 FEC9 dec cl 5198 00001DF5 75E7 jnz short SINGLIX_fs1_f_10 5199 5200 ; Fill remain sectors with 'F6h' bytes 5201 00001DF7 8B4E10 mov cx, [bp+16] ; [bsVolumeSize] 5202 00001DFA 8B5E12 mov bx, [bp+18] ; [bsVolumeSize+2] 5203 00001DFD 034E0C add cx, [bp+12] ; [bsBeginSector] 5204 00001E00 135E0E adc bx, [bp+14] ; [bsBeginSector+2] 5205 5206 ; write DATA sectors 5207 ; (after root directory sectors) 5208 SINGLIX_fs1_f_11: 5209 00001E03 53 push bx 5210 00001E04 51 push cx 5211 00001E05 BB[2266] mov bx, HDFORMAT_SECBUFFER 5212 00001E08 E84D00 call write_hd_sector 5213 00001E0B 0F8282F9 jc formatting_error 5214 00001E0F E832F9 call write_format_percent 5215 00001E12 59 pop cx 5216 00001E13 5B pop bx 5217 00001E14 83C001 add ax, 1 5218 00001E17 83D200 adc dx, 0 5219 00001E1A 39DA cmp dx, bx 5220 00001E1C 72E5 jb short SINGLIX_fs1_f_11 5221 00001E1E 0F8703F8 ja SINGLIX_fs1_f_12 5222 00001E22 39C8 cmp ax, cx 5223 00001E24 72DD jb short SINGLIX_fs1_f_11 5224 00001E26 E9FCF7 jmp SINGLIX_fs1_f_12 5225 5226 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5227 ; Print error message and exit 5228 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5229 ; 25/02/2019 5230 5231 D_01: 5232 00001E29 50 push ax 5233 00001E2A 8B1E[A840] mov bx, [img_file_handle] 5234 00001E2E B43E mov ah, 3Eh ; close file 5235 00001E30 CD21 int 21h 5236 00001E32 58 pop ax 5237 5238 ; 11/02/2019 5239 ;mov word [img_file_handle], 0 5240 D_02: 5241 00001E33 88E0 mov al, ah ; error code 5242 00001E35 E8B000 call bin_to_hex 5243 00001E38 A3[7556] mov [error_code], ax 5244 5245 00001E3B BE[6756] mov si, CRLF 5246 00001E3E E80800 call print_msg 5247 5248 00001E41 BE[6A56] mov si, Msg_Error 5249 5250 00001E44 E80200 call print_msg 5251 5252 00001E47 CD20 int 20h ; Exit 5253 5254 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5255 ; Print messages 5256 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5257 5258 print_msg: 5259 5260 print_msg_LOOP: 5261 00001E49 AC lodsb ; Load byte at DS:SI to AL 5262 00001E4A 20C0 and al, al 5263 00001E4C 7409 jz short print_msg_OK 5264 00001E4E B40E mov ah, 0Eh 5265 00001E50 BB0700 mov bx, 07h 5266 00001E53 CD10 int 10h ; BIOS Service func ( ah ) = 0Eh 5267 ; Write char as TTY 5268 ; AL-char BH-page BL-color 5269 00001E55 EBF2 jmp short print_msg_LOOP 5270 5271 print_msg_OK: 5272 00001E57 C3 retn 5273 5274 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5275 ; Writing a block (sector) to hard disk disk image file 5276 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5277 5278 write_hd_sector: 5279 ; INPUT -> DX_AX = Logical Block Address 5280 ; ES:BX = Sector Buffer 5281 ; OUTPUT -> 5282 ; cf = 0 -> DX_AX = Logical Block Adress 5283 ; ES:BX = Sector Buffer 5284 ; cf = 1 -> AH = Error Number 5285 ; 5286 00001E58 52 push dx ; sector (hw) 5287 00001E59 50 push ax ; sector (lw) 5288 00001E5A 53 push bx ; buffer 5289 00001E5B B90002 mov cx, 512 5290 ; DX_AX: Multiplicand 5291 ; CX = Multiplier 5292 00001E5E E8E3EF call mul32 5293 ; BX_DX_AX = result of multiplication (product) 5294 00001E61 21DB and bx, bx 5295 00001E63 7529 jnz short image_file_size_err 5296 00001E65 F6C680 test dh, 80h 5297 00001E68 7524 jnz short image_file_size_err 5298 00001E6A 8B1E[A840] mov bx, [img_file_handle] 5299 00001E6E 803E[B040]00 cmp byte [random], 0 5300 00001E73 760A jna short whds 5301 00001E75 89D1 mov cx, dx 5302 00001E77 89C2 mov dx, ax 5303 00001E79 28C0 sub al, al ; specified offset is from the beginning of the file 5304 00001E7B B442 mov ah, 42h ; seek (move file pointer) 5305 00001E7D CD21 int 21h 5306 whds: 5307 ;mov bx, [img_file_handle] 5308 00001E7F B90002 mov cx, 512 5309 00001E82 5A pop dx ; buffer address 5310 00001E83 B440 mov ah, 40h ; write to file 5311 00001E85 CD21 int 21h 5312 00001E87 89D3 mov bx, dx 5313 00001E89 7209 jc short image_file_rw_err 5314 00001E8B 58 pop ax ; sector (lw) 5315 00001E8C 5A pop dx ; sector (hw) 5316 00001E8D C3 retn 5317 5318 image_file_size_err: 5319 00001E8E 5B pop bx 5320 00001E8F 30C0 xor al, al 5321 ;mov ah, 1Bh ; sector not found error 5322 00001E91 B419 mov ah, 19h ; Seek error 5323 00001E93 F9 stc 5324 5325 image_file_rw_err: 5326 00001E94 5A pop dx ; sector (lw) 5327 00001E95 5A pop dx ; sector (hw) 5328 00001E96 C3 retn 5329 5330 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5331 ; Reading a block (sector) from hard disk disk image file 5332 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5333 5334 read_hd_sector: 5335 ; INPUT -> DX_AX = Logical Block Address 5336 ; ES:BX = Sector Buffer 5337 ; OUTPUT -> 5338 ; cf = 0 -> DX_AX = Logical Block Adress 5339 ; ES:BX = Sector Buffer 5340 ; cf = 1 -> AH = Error Number 5341 ; 5342 00001E97 52 push dx ; sector (hw) 5343 00001E98 50 push ax ; sector (lw) 5344 00001E99 53 push bx ; buffer 5345 00001E9A B90002 mov cx, 512 5346 ; DX_AX: Multiplicand 5347 ; CX = Multiplier 5348 00001E9D E8A4EF call mul32 5349 ; BX_DX_AX = result of multiplication (product) 5350 00001EA0 21DB and bx, bx 5351 00001EA2 75EA jnz short image_file_size_err 5352 00001EA4 F6C680 test dh, 80h 5353 00001EA7 75E5 jnz short image_file_size_err 5354 00001EA9 8B1E[A840] mov bx, [img_file_handle] 5355 00001EAD 803E[B040]00 cmp byte [random], 0 5356 00001EB2 760A jna short rhds 5357 00001EB4 89D1 mov cx, dx 5358 00001EB6 89C2 mov dx, ax 5359 00001EB8 28C0 sub al, al ; specified offset is from the beginning of the file 5360 00001EBA B442 mov ah, 42h ; seek (move file pointer) 5361 00001EBC CD21 int 21h 5362 rhds: 5363 ;mov bx, [img_file_handle] 5364 00001EBE B90002 mov cx, 512 5365 00001EC1 5A pop dx ; buffer address 5366 00001EC2 B43F mov ah, 3Fh ; read from file 5367 00001EC4 CD21 int 21h 5368 00001EC6 89D3 mov bx, dx 5369 00001EC8 72CA jc short image_file_rw_err 5370 00001ECA 39C8 cmp ax, cx 5371 00001ECC 75C0 jne short image_file_size_err 5372 00001ECE 58 pop ax ; sector (lw) 5373 00001ECF 5A pop dx ; sector (hw) 5374 00001ED0 C3 retn 5375 5376 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5377 ; Convert byte to decimal number 5378 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5379 5380 bin_to_decimal: 5381 ; INPUT: DS:SI = Target location 5382 ; DX_AX = Binary Number (Integer) 5383 ; OUTPUT: Decimal char at DS:SI 5384 ; SI decremented after every division 5385 ; till AX<10. 5386 ; CX, DX, BX will be changed. 5387 ; 5388 00001ED1 B90A00 mov cx, 10 5389 btd_0: 5390 ; DX_AX = Dividend 5391 ; CX = Divisor 5392 00001ED4 E85FEF call div32 5393 ; DX_AX = Quotient 5394 ; BX = remainder 5395 00001ED7 80C330 add bl, '0' 5396 00001EDA 881C mov [si], bl 5397 00001EDC 21D2 and dx, dx 5398 00001EDE 7403 jz short btd_2 5399 btd_1: 5400 00001EE0 4E dec si 5401 00001EE1 EBF1 jmp short btd_0 5402 btd_2: 5403 00001EE3 09C0 or ax, ax 5404 00001EE5 75F9 jnz short btd_1 5405 5406 00001EE7 C3 retn 5407 5408 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5409 ; Convert byte to hexadecimal number 5410 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5411 5412 byte_to_hex: ; 04/02/2019 5413 bin_to_hex: 5414 ; INPUT -> 5415 ; AL = byte (binary number) 5416 ; OUTPUT -> 5417 ; AX = hexadecimal string 5418 ; 5419 00001EE8 53 push bx 5420 00001EE9 31DB xor bx, bx 5421 00001EEB 88C3 mov bl, al 5422 00001EED C0EB04 shr bl, 4 5423 00001EF0 8A9F[9740] mov bl, [bx+hexchrs] 5424 00001EF4 86D8 xchg bl, al 5425 00001EF6 80E30F and bl, 0Fh 5426 00001EF9 8AA7[9740] mov ah, [bx+hexchrs] 5427 00001EFD 5B pop bx 5428 00001EFE C3 retn 5429 5430 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5431 ; Read & Write characters 5432 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5433 5434 rw_char: 5435 ; OUTPUT -> DS:SI = Entered String (ASCIIZ) 5436 00001EFF BE[C455] mov si, StrVolumeName 5437 00001F02 BB0700 mov bx, 7 5438 00001F05 B403 mov ah, 3 5439 00001F07 CD10 int 10h 5440 00001F09 8916[AB55] mov [Cursor_Pos], dx 5441 read_next_char: 5442 00001F0D 30E4 xor ah, ah 5443 00001F0F CD16 int 16h 5444 00001F11 20C0 and al, al 5445 00001F13 7439 jz short loc_arrow 5446 00001F15 3CE0 cmp al, 0E0h 5447 00001F17 7435 je short loc_arrow 5448 00001F19 3C08 cmp al, 8 5449 00001F1B 753D jne short char_return 5450 loc_back: 5451 00001F1D B403 mov ah, 3 5452 00001F1F CD10 int 10h 5453 00001F21 3A16[AB55] cmp dl, byte [Cursor_Pos] 5454 00001F25 761F jna short loc_beep 5455 prev_column: 5456 00001F27 FECA dec dl 5457 set_cursor_pos: 5458 00001F29 B402 mov ah, 2 5459 00001F2B CD10 int 10h 5460 00001F2D 88D3 mov bl, dl 5461 00001F2F 2A1E[AB55] sub bl, byte [Cursor_Pos] 5462 00001F33 B90100 mov cx, 1 5463 00001F36 B409 mov ah, 9 5464 00001F38 B020 mov al, 20h 5465 00001F3A 8800 mov [si+bx], al 5466 loc_write_it: 5467 00001F3C B307 mov bl, 7 5468 00001F3E CD10 int 10h 5469 00001F40 8B16[AB55] mov dx, [Cursor_Pos] 5470 00001F44 EBC7 jmp short read_next_char 5471 loc_beep: 5472 00001F46 B40E mov ah, 0Eh 5473 00001F48 B007 mov al, 7 5474 00001F4A CD10 int 10h 5475 00001F4C EBBF jmp short read_next_char 5476 loc_arrow: 5477 00001F4E 80FC4B cmp ah, 4Bh 5478 00001F51 74CA je short loc_back 5479 00001F53 80FC53 cmp ah, 53h 5480 00001F56 74C5 je short loc_back 5481 00001F58 EBB3 jmp short read_next_char 5482 char_return: 5483 00001F5A B403 mov ah, 3 5484 00001F5C CD10 int 10h 5485 check_char_type: 5486 00001F5E 3C20 cmp al, 20h 5487 00001F60 7229 jb short loc_escape 5488 00001F62 88D4 mov ah, dl 5489 00001F64 2A26[AB55] sub ah, byte [Cursor_Pos] 5490 ;cmp ah, 10 5491 ;ja short loc_beep 5492 00001F68 3A26[0B66] cmp ah, [vname_length] ; 05/01/2018 5493 00001F6C 73D8 jnb short loc_beep 5494 00001F6E 3C7A cmp al, 'z' 5495 00001F70 779B ja short read_next_char 5496 00001F72 3C61 cmp al, 'a' 5497 00001F74 7202 jb short pass_capitalize 5498 00001F76 24DF and al, 0DFh 5499 pass_capitalize: 5500 00001F78 88E3 mov bl, ah 5501 00001F7A 30E4 xor ah, ah 5502 00001F7C 8900 mov [si+bx], ax 5503 00001F7E B307 mov bl, 7 5504 00001F80 B40E mov ah, 0Eh 5505 00001F82 CD10 int 10h 5506 00001F84 EB87 jmp short read_next_char 5507 pass_escape: 5508 00001F86 3C0D cmp al, 0Dh ; 13 ; ENTER 5509 00001F88 7583 jne short read_next_char 5510 ;mov ah, 0Eh 5511 ;int 10h 5512 ;mov al, 0Ah 5513 ;int 10h 5514 00001F8A C3 retn 5515 loc_escape: 5516 00001F8B 3C1B cmp al, 1Bh ; 27 ; ESC 5517 00001F8D 75F7 jne short pass_escape 5518 00001F8F F9 stc 5519 00001F90 C3 retn 5520 5521 ;----------------------------------------------------------------------------- 5522 5523 display_chs_table: 5524 00001F91 06 push es 5525 00001F92 BF00B8 mov di, 0B800h 5526 00001F95 8EC7 mov es, di 5527 00001F97 31FF xor di, di 5528 ; 12/02/2019 5529 ; new file ? 5530 00001F99 803E[D96E]00 cmp byte [existingfile], 0 5531 00001F9E 7604 jna short dchstbl_1 5532 00001FA0 81C74001 add di, 320 ; skip 2 rows (for the header) 5533 dchstbl_1: 5534 00001FA4 B95000 mov cx, 80 5535 00001FA7 B82007 mov ax, 0720h 5536 00001FAA F3AB rep stosw 5537 00001FAC B150 mov cl, 80 5538 00001FAE B02D mov al, "-" 5539 00001FB0 F3AB rep stosw 5540 00001FB2 B113 mov cl, 19 5541 00001FB4 B020 mov al, 20h 5542 00001FB6 F3AB rep stosw 5543 00001FB8 B043 mov al, 'C' 5544 00001FBA AB stosw 5545 00001FBB B079 mov al, 'y' 5546 00001FBD AB stosw 5547 00001FBE B06C mov al, 'l' 5548 00001FC0 AB stosw 5549 00001FC1 B069 mov al, 'i' 5550 00001FC3 AB stosw 5551 00001FC4 B06E mov al, 'n' 5552 00001FC6 AB stosw 5553 00001FC7 B064 mov al, 'd' 5554 00001FC9 AB stosw 5555 00001FCA B065 mov al, 'e' 5556 00001FCC AB stosw 5557 00001FCD B072 mov al, 'r' 5558 00001FCF AB stosw 5559 00001FD0 B073 mov al, 's' 5560 00001FD2 AB stosw 5561 00001FD3 B03A mov al, ':' 5562 00001FD5 AB stosw 5563 00001FD6 B020 mov al, 20h 5564 00001FD8 AB stosw 5565 ;mov [cylnumpos], di 5566 00001FD9 A1[AE40] mov ax, [cylinders] 5567 00001FDC B104 mov cl, 4 5568 00001FDE B543 mov ch, 'C' 5569 00001FE0 E88400 call write_number 5570 5571 00001FE3 B82007 mov ax, 0720h 5572 00001FE6 AB stosw 5573 00001FE7 AB stosw 5574 00001FE8 B048 mov al, 'H' 5575 00001FEA AB stosw 5576 00001FEB B065 mov al, 'e' 5577 00001FED AB stosw 5578 00001FEE B061 mov al, 'a' 5579 00001FF0 AB stosw 5580 00001FF1 B064 mov al, 'd' 5581 00001FF3 AB stosw 5582 00001FF4 B073 mov al, 's' 5583 00001FF6 AB stosw 5584 00001FF7 B03A mov al, ':' 5585 00001FF9 AB stosw 5586 00001FFA B020 mov al, 20h 5587 00001FFC AB stosw 5588 ;mov [hednumpos], di 5589 00001FFD A1[AC40] mov ax, [heads] 5590 00002000 B102 mov cl, 2 5591 00002002 B548 mov ch, 'H' 5592 00002004 E86000 call write_number 5593 5594 00002007 B82007 mov ax, 0720h 5595 0000200A AB stosw 5596 0000200B AB stosw 5597 0000200C B053 mov al, 'S' 5598 0000200E AB stosw 5599 0000200F B065 mov al, 'e' 5600 00002011 AB stosw 5601 00002012 B063 mov al, 'c' 5602 00002014 AB stosw 5603 00002015 B074 mov al, 't' 5604 00002017 AB stosw 5605 00002018 B06F mov al, 'o' 5606 0000201A AB stosw 5607 0000201B B072 mov al, 'r' 5608 0000201D AB stosw 5609 0000201E B073 mov al, 's' 5610 00002020 AB stosw 5611 00002021 B03A mov al, ':' 5612 00002023 AB stosw 5613 00002024 B020 mov al, 20h 5614 00002026 AB stosw 5615 ;mov [secnumpos], di 5616 00002027 A1[AA40] mov ax, [sectors] 5617 0000202A B102 mov cl, 2 5618 0000202C B553 mov ch, 'S' 5619 0000202E E83600 call write_number 5620 5621 00002031 B116 mov cl, 22 5622 00002033 B82007 mov ax, 0720h 5623 00002036 F3AB rep stosw 5624 5625 00002038 B150 mov cl, 80 5626 0000203A B02D mov al, "-" 5627 0000203C F3AB rep stosw 5628 5629 ;mov cl, 80 5630 0000203E B1A0 mov cl, 160 ; 11/02/2019 5631 00002040 B020 mov al, 20h 5632 00002042 F3AB rep stosw 5633 5634 00002044 BA0006 mov dx, 0600h ; DH = row, DL = 0 column 5635 00002047 31DB xor bx, bx ; BH = video page (0) 5636 00002049 B402 mov ah, 02h ; set cursor position 5637 0000204B CD10 int 10h 5638 5639 ; 12/02/2019 5640 ; new file ? 5641 0000204D 380E[D96E] cmp byte [existingfile], cl ; 0 5642 00002051 7712 ja short dchstbl_2 5643 5644 00002053 81C7A005 add di, 9*160 ; 9 rows (CHS_msg) 5645 5646 00002057 BE[DD41] mov si, CHS_msg 5647 0000205A E8ECFD call print_msg 5648 5649 0000205D B92003 mov cx, 10*80 5650 00002060 B82007 mov ax, 0720h 5651 00002063 F3AB rep stosw 5652 dchstbl_2: 5653 00002065 07 pop es 5654 00002066 C3 retn 5655 5656 ;----------------------------------------------------------------------------- 5657 5658 write_number: 5659 00002067 89CE mov si, cx 5660 00002069 31D2 xor dx, dx 5661 0000206B BB0A00 mov bx, 10 5662 wnum_1: 5663 0000206E F7F3 div bx 5664 00002070 52 push dx 5665 00002071 31D2 xor dx, dx 5666 00002073 FEC9 dec cl 5667 00002075 75F7 jnz short wnum_1 5668 00002077 89F1 mov cx, si 5669 00002079 B407 mov ah, 07h 5670 0000207B 88E8 mov al, ch 5671 0000207D 30ED xor ch, ch 5672 0000207F 3806[B76E] cmp byte [chs_focus], al 5673 00002083 7502 jne short wnum_2 5674 00002085 B40F mov ah, 0Fh 5675 wnum_2: 5676 00002087 5A pop dx 5677 00002088 88D0 mov al, dl 5678 0000208A 0430 add al, '0' 5679 0000208C AB stosw 5680 0000208D E2F8 loop wnum_2 5681 0000208F C3 retn 5682 5683 ;----------------------------------------------------------------------------- 5684 5685 partition_size_input: 5686 00002090 C706[BE6E]0000 mov word [pSize_multiplier+2], 0 5687 00002096 C606[C36E]42 mov byte [msg_psize_unit+1], 'B' 5688 0000209B A0[C26E] mov al, [pSize_unit] 5689 0000209E 3C25 cmp al, '%' 5690 000020A0 751F jne short psu_0 5691 ; 08/02/2019 5692 ; calculate sector count for max. available sectors percentage 5693 000020A2 8B16[B26E] mov dx, [pp_Sectors+2] ; max. available sectors 5694 000020A6 A1[B06E] mov ax, [pp_Sectors] ; for a new partition 5695 ;mov dx, [total_sectors+2] 5696 ;mov ax, [total_sectors] 5697 000020A9 B96400 mov cx, 100 5698 000020AC E887ED call div32 5699 000020AF A3[BC6E] mov [pSize_multiplier], ax 5700 000020B2 B400 mov ah, 0 5701 000020B4 8826[C36E] mov [msg_psize_unit+1], ah 5702 000020B8 C606[C06E]02 mov byte [pSize_maxdigits], 2 5703 000020BD B025 mov al, '%' 5704 000020BF EB60 jmp short psu_6 5705 psu_0: 5706 000020C1 3C43 cmp al, 'C' 5707 000020C3 7517 jne short psu_1 5708 000020C5 A1[AA40] mov ax, [sectors] 5709 000020C8 F726[AC40] mul word [heads] 5710 000020CC A3[BC6E] mov [pSize_multiplier], ax 5711 000020CF C606[C06E]04 mov byte [pSize_maxdigits], 4 5712 ;sub dh, dh 5713 000020D4 8836[C36E] mov [msg_psize_unit+1], dh 5714 000020D8 B043 mov al, 'C' 5715 000020DA EB45 jmp short psu_6 5716 psu_1: 5717 000020DC 3C47 cmp al, 'G' 5718 000020DE 7513 jne short psu_2 5719 000020E0 C706[BC6E]0008 mov word [pSize_multiplier], 2*1024 5720 000020E6 C706[BE6E]0004 mov word [pSize_multiplier+2], 1024 5721 000020EC C606[C06E]01 mov byte [pSize_maxdigits], 1 5722 000020F1 EB2E jmp short psu_6 5723 psu_2: 5724 000020F3 3C4D cmp al, 'M' 5725 000020F5 750D jne short psu_3 5726 000020F7 C706[BC6E]0008 mov word [pSize_multiplier], 2*1024 5727 000020FD C606[C06E]04 mov byte [pSize_maxdigits], 4 5728 00002102 EB1D jmp short psu_6 5729 psu_3: 5730 00002104 3C4B cmp al, 'K' 5731 00002106 7508 jne short psu_4 5732 00002108 C706[BC6E]0200 mov word [pSize_multiplier], 2 5733 0000210E EB0C jmp short psu_5 5734 psu_4: 5735 ; al = 'S' 5736 00002110 30E4 xor ah, ah 5737 00002112 8826[C36E] mov [msg_psize_unit+1], ah 5738 00002116 C706[BC6E]0100 mov word [pSize_multiplier], 1 5739 psu_5: 5740 0000211C C606[C06E]07 mov byte [pSize_maxdigits], 7 5741 psu_6: 5742 00002121 A2[A34F] mov [msg_partition_size_x], al 5743 00002124 BE[8F4F] mov si, msg_partition_size 5744 00002127 E81FFD call print_msg 5745 5746 0000212A 89E5 mov bp, sp 5747 0000212C 31DB xor bx, bx 5748 0000212E 891E[B86E] mov [pSize_temp], bx ; 0 5749 ;mov [pSize_temp+2], bx ; 0 5750 00002132 881E[C16E] mov [pSize_digitpos], bl ; 0 5751 ; bh = 0 ; video page 5752 00002136 B403 mov ah, 3 ; get cursor pos 5753 00002138 CD10 int 10h 5754 0000213A 8916[AB55] mov [Cursor_Pos], dx 5755 ; 09/02/2019 5756 0000213E B307 mov bl, 7 ; page 0, color 7 (light gray) 5757 psu_7: 5758 00002140 30E4 xor ah, ah 5759 00002142 CD16 int 16h 5760 5761 00002144 3C30 cmp al, '0' 5762 00002146 721F jb short psu_8 5763 00002148 3C39 cmp al, '9' 5764 0000214A 77F4 ja short psu_7 5765 0000214C 8A1E[C16E] mov bl, [pSize_digitpos] 5766 00002150 3A1E[C06E] cmp bl, [pSize_maxdigits] 5767 00002154 73EA jnb short psu_7 5768 00002156 FE06[C16E] inc byte [pSize_digitpos] 5769 0000215A 2C30 sub al, '0' 5770 0000215C 30E4 xor ah, ah 5771 0000215E 50 push ax 5772 0000215F 0430 add al, '0' 5773 00002161 B40E mov ah, 0Eh ; write char as tty 5774 ;mov bx, 7 ; page 0, color 7 (light gray) 5775 00002163 CD10 int 10h 5776 00002165 EBD9 jmp short psu_7 5777 psu_8: 5778 00002167 20C0 and al, al 5779 00002169 0F849500 jz psu_15 ; check for left arrow key 5780 0000216D 3C1B cmp al, 27 5781 0000216F 0F849C00 je psu_16esc ; ESCAPE key 5782 00002173 0F878500 ja psu_14 ; check for left arrow key 5783 00002177 3C0D cmp al, 13 5784 ;je short psu_9 ; ENTER key 5785 00002179 7249 jb short psu_11 ; check for backspace key 5786 ;jmp short psu_7 5787 0000217B 77C3 ja short psu_7 5788 psu_9: 5789 0000217D 31C0 xor ax, ax 5790 0000217F A3[BA6E] mov [pSize_temp+2], ax ; 0 ; 08/02/2019 5791 00002182 3806[C16E] cmp byte [pSize_digitpos], al ; 0 5792 00002186 0F868F00 jna psu_16 5793 ;xor bh, bh 5794 0000218A 8A1E[C16E] mov bl, [pSize_digitpos] 5795 0000218E FECB dec bl 5796 00002190 D0E3 shl bl, 1 5797 00002192 01E3 add bx, sp 5798 00002194 8B07 mov ax, [bx] 5799 00002196 A3[B86E] mov [pSize_temp], ax 5800 ;mov word [pSize_temp+2], 0 5801 00002199 B90A00 mov cx, 10 5802 psu_10: 5803 0000219C FE0E[C16E] dec byte [pSize_digitpos] 5804 000021A0 7477 jz short psu_16 5805 5806 000021A2 A1[B86E] mov ax, [pSize_temp] 5807 000021A5 8B16[BA6E] mov dx, [pSize_temp+2] 5808 ;mov cx, 10 5809 000021A9 E898EC call mul32 5810 ;mov [pSize_temp], ax 5811 ;mov [pSize_temp+2], dx 5812 ;xor bh, bh 5813 000021AC 8A1E[C16E] mov bl, [pSize_digitpos] 5814 000021B0 FECB dec bl 5815 000021B2 D0E3 shl bl, 1 5816 000021B4 01E3 add bx, sp ; (*) 5817 ;mov ax, [bx] 5818 ;add [pSize_temp], ax 5819 ;adc word [pSize_temp+2], 0 5820 000021B6 0307 add ax, [bx] 5821 000021B8 83D200 adc dx, 0 5822 000021BB A3[B86E] mov [pSize_temp], ax 5823 000021BE 8916[BA6E] mov [pSize_temp+2], dx 5824 000021C2 EBD8 jmp short psu_10 5825 5826 ; Left arrow, backspace, DEL key checking 5827 psu_11: 5828 000021C4 3C08 cmp al, 8 ; backspace key 5829 000021C6 0F8576FF jne psu_7 5830 psu_12: 5831 ;; bh = 0 ; video page 5832 ;mov ah, 3 ; get cursor pos 5833 ;int 10h 5834 ;cmp dl, [Cursor_Pos] 5835 ;jna short psu_13 5836 ;dec dl 5837 ;dec byte [pSize_digitpos] 5838 5839 ; 08/02/2019 5840 000021CA 8B16[AB55] mov dx, [Cursor_Pos] 5841 000021CE 8A1E[C16E] mov bl, [pSize_digitpos] 5842 000021D2 20DB and bl, bl 5843 000021D4 741D jz short psu_13 5844 5845 000021D6 FECB dec bl 5846 000021D8 881E[C16E] mov [pSize_digitpos], bl 5847 5848 000021DC 00DA add dl, bl 5849 5850 ; bh = 0 ; video page 5851 000021DE B402 mov ah, 2 ; set cursor pos 5852 000021E0 CD10 int 10h 5853 ;mov bl, dl 5854 ;sub bl, [Cursor_Pos] 5855 000021E2 B90100 mov cx, 1 5856 000021E5 B409 mov ah, 9 ; write char at current curs pos 5857 000021E7 B020 mov al, 20h ; space (blank) 5858 000021E9 8800 mov [si+bx], al 5859 ; bh = 0 ; video page 5860 000021EB B307 mov bl, 7 ; attribute/color (light gray) 5861 000021ED CD10 int 10h 5862 5863 ; 09/02/2019 5864 000021EF 58 pop ax ; remove last digit on top of stack 5865 ; set sp to correct position for BX (*) 5866 000021F0 E94DFF jmp psu_7 5867 psu_13: 5868 000021F3 B40E mov ah, 0Eh 5869 000021F5 B007 mov al, 7 5870 ;mov bx, 7 5871 000021F7 CD10 int 10h 5872 000021F9 E944FF jmp psu_7 5873 psu_14: 5874 000021FC 3CE0 cmp al, 0E0h 5875 000021FE 0F853EFF jne psu_7 5876 psu_15: 5877 00002202 80FC4B cmp ah, 4Bh ; left arrow 5878 00002205 74C3 je short psu_12 5879 00002207 80FC53 cmp ah, 53h ; DEL key (backspace) 5880 0000220A 74BE je short psu_12 5881 0000220C E931FF jmp psu_7 5882 5883 psu_16esc: 5884 0000220F 31C9 xor cx, cx ; 0 5885 00002211 890E[B86E] mov [pSize_temp], cx 5886 00002215 890E[BA6E] mov [pSize_temp+2], cx 5887 psu_16: 5888 00002219 89EC mov sp, bp 5889 5890 0000221B 803E[C26E]53 cmp byte [pSize_unit], 'S' 5891 00002220 7508 jne short psu_17 5892 5893 00002222 BE[0066] mov si, msg_sectors_crlf 5894 00002225 E821FC call print_msg 5895 ;xor bx, bx 5896 00002228 EB0C jmp short psu_18 5897 psu_17: 5898 0000222A BE[C26E] mov si, msg_psize_unit 5899 0000222D E819FC call print_msg 5900 5901 00002230 BE[6756] mov si, CRLF 5902 00002233 E813FC call print_msg 5903 psu_18: 5904 00002236 A1[B86E] mov ax, [pSize_temp] 5905 00002239 8B16[BA6E] mov dx, [pSize_temp+2] 5906 0000223D 89C1 mov cx, ax 5907 0000223F 09D1 or cx, dx 5908 ;jz short psu_20 5909 00002241 7422 jz short psu_21 ; 08/02/2019 5910 00002243 8B0E[BC6E] mov cx, [pSize_multiplier] 5911 00002247 803E[C26E]43 cmp byte [pSize_unit], 'C' 5912 0000224C 7413 je short psu_20 ; 09/02/2019 5913 ;jne short psu_19 5914 ;call mul32 5915 ; 08/02/2019 5916 ; dx:ax = requested partition size in sectors 5917 ;retn 5918 ;psu_19: 5919 ;mov cx, [pSize_multiplier] 5920 0000224E 83F901 cmp cx, 1 5921 ;jna short psu_20 5922 00002251 7703 ja short psu_19 5923 ; 09/02/2019 5924 00002253 31DB xor bx, bx 5925 00002255 C3 retn 5926 psu_19: 5927 00002256 E8EBEB call mul32 5928 ;and bx, bx 5929 ;jnz short psu_22 ; 09/02/2019 5930 00002259 8B0E[BE6E] mov cx, [pSize_multiplier+2] 5931 0000225D 09C9 or cx, cx 5932 ;jz short psu_20 5933 0000225F 7405 jz short psu_22 ; 09/02/2019 5934 psu_20: 5935 00002261 E8E0EB call mul32 5936 00002264 C3 retn 5937 psu_21: 5938 00002265 F9 stc 5939 psu_22: 5940 00002266 C3 retn 5941 5942 ;----------------------------------------------------------------------------- 5943 5944 partition_type_input: 5945 00002267 BE[A94F] mov si, msg_partition_type 5946 0000226A E8DCFB call print_msg 5947 5948 0000226D 31DB xor bx, bx 5949 5950 0000226F 881E[D26E] mov [pType_pos], bl ; 0 5951 00002273 891E[D36E] mov [pType_num], bx ; 0 5952 5953 ; bh = 0 ; video page 5954 00002277 B403 mov ah, 3 ; get cursor pos 5955 00002279 CD10 int 10h 5956 0000227B 8916[AB55] mov [Cursor_Pos], dx 5957 ptu_0: 5958 0000227F 30E4 xor ah, ah 5959 00002281 CD16 int 16h 5960 5961 00002283 803E[D26E]01 cmp byte [pType_pos], 1 5962 00002288 773F ja short ptu_5 5963 5964 0000228A 3C30 cmp al, '0' 5965 0000228C 723B jb short ptu_5 5966 0000228E 3C39 cmp al, '9' 5967 00002290 7707 ja short ptu_1 5968 00002292 88C4 mov ah, al 5969 00002294 80EC30 sub ah, '0' 5970 00002297 EB13 jmp short ptu_2 5971 ptu_1: 5972 00002299 3CE0 cmp al, 0E0h 5973 0000229B 7473 je short ptu_9 5974 5975 0000229D 24DF and al, 0DFh 5976 0000229F 3C41 cmp al, 'A' 5977 000022A1 72DC jb short ptu_0 5978 000022A3 3C46 cmp al, 'F' 5979 000022A5 77D8 ja short ptu_0 5980 000022A7 88C4 mov ah, al 5981 000022A9 80EC37 sub ah, 'A'-10 5982 ptu_2: 5983 000022AC 803E[D26E]00 cmp byte [pType_pos], 0 5984 000022B1 7606 jna short ptu_3 5985 000022B3 8826[D46E] mov [pType_num+1], ah 5986 000022B7 EB04 jmp short ptu_4 5987 ptu_3: 5988 000022B9 8826[D36E] mov [pType_num], ah 5989 ptu_4: 5990 000022BD B40E mov ah, 0Eh 5991 000022BF B307 mov bl, 7 5992 000022C1 CD10 int 10h 5993 5994 000022C3 FE06[D26E] inc byte [pType_pos] 5995 5996 000022C7 EBB6 jmp short ptu_0 5997 ptu_5: 5998 000022C9 20C0 and al, al 5999 000022CB 7443 jz short ptu_9 ; check for left arrow key 6000 000022CD 3C1B cmp al, 27 6001 000022CF 744C je short ptu_10 ; ESCAPE key 6002 000022D1 77AC ja short ptu_0 6003 000022D3 3C0D cmp al, 13 6004 000022D5 744A je short ptu_11 ; ENTER key 6005 000022D7 77A6 ja short ptu_0 6006 ptu_6: 6007 ; Left arrow, backspace, DEL key checking 6008 6009 000022D9 3C08 cmp al, 8 ; backspace key 6010 000022DB 75A2 jne short ptu_0 6011 ptu_7: 6012 ; bh = 0 ; video page 6013 000022DD B403 mov ah, 3 ; get cursor pos 6014 000022DF CD10 int 10h 6015 000022E1 3A16[AB55] cmp dl, [Cursor_Pos] 6016 000022E5 7620 jna short ptu_8 6017 000022E7 FECA dec dl 6018 000022E9 FE0E[D26E] dec byte [pType_pos] 6019 ; bh = 0 ; video page 6020 000022ED B402 mov ah, 2 ; set cursor pos 6021 000022EF CD10 int 10h 6022 000022F1 88D3 mov bl, dl 6023 000022F3 2A1E[AB55] sub bl, [Cursor_Pos] 6024 000022F7 B90100 mov cx, 1 6025 000022FA B409 mov ah, 9 ; write char at current curs pos 6026 000022FC B020 mov al, 20h ; space (blank) 6027 000022FE 8800 mov [si+bx], al 6028 ; bh = 0 ; video page 6029 00002300 B307 mov bl, 7 ; attribute/color (light gray) 6030 00002302 CD10 int 10h 6031 00002304 E978FF jmp ptu_0 6032 ptu_8: 6033 00002307 B40E mov ah, 0Eh 6034 00002309 B007 mov al, 7 6035 0000230B CD10 int 10h 6036 0000230D E96FFF jmp ptu_0 6037 ptu_9: 6038 00002310 80FC4B cmp ah, 4Bh ; left arrow 6039 00002313 74C8 je short ptu_7 6040 00002315 80FC53 cmp ah, 53h ; DEL key (backspace) 6041 00002318 74C3 je short ptu_7 6042 0000231A E962FF jmp ptu_0 6043 6044 ptu_10: ; ESCAPE 6045 0000231D B000 mov al, 0 6046 ; partition type is 0 (none) 6047 0000231F EB12 jmp short ptu_12 6048 ptu_11: ; ENTER 6049 00002321 A0[D36E] mov al, [pType_num] 6050 00002324 803E[D26E]01 cmp byte [pType_pos], 1 6051 00002329 7608 jna short ptu_12 6052 0000232B B410 mov ah, 16 6053 0000232D F6E4 mul ah 6054 0000232F 0206[D46E] add al, [pType_num+1] 6055 ptu_12: 6056 00002333 50 push ax 6057 00002334 E8B1FB call bin_to_hex 6058 00002337 A3[BF4F] mov [msg_ptype_num], ax 6059 ; bh = 0 ; video page 6060 0000233A B402 mov ah, 2 ; set cursor pos 6061 0000233C 8B16[AB55] mov dx, [Cursor_Pos] 6062 00002340 CD10 int 10h 6063 00002342 BE[BF4F] mov si, msg_ptype_num 6064 00002345 E801FB call print_msg 6065 00002348 58 pop ax 6066 00002349 C3 retn 6067 6068 ;----------------------------------------------------------------------------- 6069 6070 show_selected_partition: 6071 ; INPUT -> 6072 ; DS:SI = Partition table row address 6073 6074 pt_s_offset equ 7 6075 pt_bh_offset equ 11 6076 pt_bs_offset equ 15 6077 pt_bc_offset equ 19 6078 pt_fs_offset equ 23 6079 pt_eh_offset equ 27 6080 pt_es_offset equ 31 6081 pt_ec_offset equ 35 6082 pt_rs_offset equ 41 6083 pt_ts_offset equ 52 6084 pt_fsn_offset equ 63 6085 6086 ; clear screen 6087 0000234A B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 6088 0000234D CD10 int 10h 6089 6090 0000234F 89F0 mov ax, si 6091 00002351 2D[FE58] sub ax, MasterBootBuff + pTableOffset ; + 446 6092 00002354 C0E804 shr al, 4 ; from offset to partition number 6093 00002357 0431 add al, '1' ; 1 based partition number (chr) 6094 ; Write partition number to the header location 6095 00002359 A2[7F51] mov [msg_selected_partition+43], al ; '1' to '4' 6096 6097 ; Partition number will be used at formatting stage 6098 0000235C A2[4E54] mov [partition_num_chr], al ; number + '0' 6099 6100 0000235F B268 mov dl, 'h' 6101 00002361 8A04 mov al, [si+ptBootable] 6102 00002363 E882FB call bin_to_hex 6103 00002366 A3[9B52] mov [pt_row+pt_s_offset], ax 6104 00002369 8816[9D52] mov [pt_row+pt_s_offset+2], dl ; 'h' 6105 0000236D 8A4401 mov al, [si+ptBeginHead] 6106 00002370 E875FB call bin_to_hex 6107 00002373 A3[9F52] mov [pt_row+pt_bh_offset], ax 6108 00002376 8816[A152] mov [pt_row+pt_bh_offset+2], dl ; 'h' 6109 0000237A 8A4402 mov al, [si+ptBeginSector] 6110 0000237D E868FB call bin_to_hex 6111 00002380 A3[A352] mov [pt_row+pt_bs_offset], ax 6112 00002383 8816[A552] mov [pt_row+pt_bs_offset+2], dl ; 'h' 6113 00002387 8A4403 mov al, [si+ptBeginCylinder] 6114 0000238A E85BFB call bin_to_hex 6115 0000238D A3[A752] mov [pt_row+pt_bc_offset], ax 6116 00002390 8816[A952] mov [pt_row+pt_bc_offset+2], dl ; 'h' 6117 00002394 8A4404 mov al, [si+ptFileSystemID] 6118 ; Partition type will be used at formatting stage 6119 00002397 A2[B66E] mov [pp_type_user], al 6120 0000239A E84BFB call bin_to_hex 6121 0000239D A3[AB52] mov [pt_row+pt_fs_offset], ax 6122 000023A0 8816[AD52] mov [pt_row+pt_fs_offset+2], dl ; 'h' 6123 000023A4 8A4405 mov al, [si+ptEndHead] 6124 000023A7 E83EFB call bin_to_hex 6125 000023AA A3[AF52] mov [pt_row+pt_eh_offset], ax 6126 000023AD 8816[B152] mov [pt_row+pt_eh_offset+2], dl ; 'h' 6127 000023B1 8A4406 mov al, [si+ptEndSector] 6128 000023B4 E831FB call bin_to_hex 6129 000023B7 A3[B352] mov [pt_row+pt_es_offset], ax 6130 000023BA 8816[B552] mov [pt_row+pt_es_offset+2], dl ; 'h' 6131 000023BE 8A4407 mov al, [si+ptEndCylinder] 6132 000023C1 E824FB call bin_to_hex 6133 000023C4 A3[B752] mov [pt_row+pt_ec_offset], ax 6134 000023C7 8816[B952] mov [pt_row+pt_ec_offset+2], dl ; 'h' 6135 000023CB 8A4408 mov al, [si+ptStartSector] 6136 000023CE E817FB call bin_to_hex 6137 000023D1 A3[C352] mov [pt_row+pt_rs_offset+6], ax 6138 000023D4 8816[C552] mov [pt_row+pt_rs_offset+8], dl ; 'h' 6139 000023D8 8A4409 mov al, [si+ptStartSector+1] 6140 000023DB E80AFB call bin_to_hex 6141 000023DE A3[C152] mov [pt_row+pt_rs_offset+4], ax 6142 000023E1 8A440A mov al, [si+ptStartSector+2] 6143 000023E4 E801FB call bin_to_hex 6144 000023E7 A3[BF52] mov [pt_row+pt_rs_offset+2], ax 6145 000023EA 8A440B mov al, [si+ptStartSector+3] 6146 000023ED E8F8FA call bin_to_hex 6147 000023F0 A3[BD52] mov [pt_row+pt_rs_offset], ax 6148 000023F3 8A440C mov al, [si+ptSectors] 6149 000023F6 E8EFFA call bin_to_hex 6150 000023F9 A3[CE52] mov [pt_row+pt_ts_offset+6], ax 6151 000023FC 8816[D052] mov [pt_row+pt_ts_offset+8], dl ; 'h' 6152 00002400 8A440D mov al, [si+ptSectors+1] 6153 00002403 E8E2FA call bin_to_hex 6154 00002406 A3[CC52] mov [pt_row+pt_ts_offset+4], ax 6155 00002409 8A440E mov al, [si+ptSectors+2] 6156 0000240C E8D9FA call bin_to_hex 6157 0000240F A3[CA52] mov [pt_row+pt_ts_offset+2], ax 6158 00002412 8A440F mov al, [si+ptSectors+3] 6159 00002415 E8D0FA call bin_to_hex 6160 00002418 A3[C852] mov [pt_row+pt_ts_offset], ax 6161 6162 0000241B 8A4404 mov al, [si+ptFileSystemID] 6163 0000241E BF[CA41] mov di, valid_partitions 6164 00002421 B91300 mov cx, 19 6165 00002424 F2AE repnz scasb 6166 00002426 7405 jz short ssp_1 6167 00002428 B8[BC41] mov ax, FS_OTHERS 6168 0000242B EB0C jmp short ssp_2 6169 ssp_1: 6170 0000242D 81EF[CB41] sub di, valid_partitions + 1 6171 00002431 B80E00 mov ax, 14 6172 00002434 F7E7 mul di 6173 00002436 05[B240] add ax, FileSys_Names 6174 ssp_2: 6175 00002439 96 xchg ax, si 6176 0000243A B107 mov cl, 7 6177 0000243C BF[D352] mov di, pt_row + pt_fsn_offset 6178 0000243F F3A5 rep movsw 6179 00002441 89C7 mov di, ax ; partition table row address 6180 6181 00002443 BE[5451] mov si, msg_selected_partition 6182 00002446 E800FA call print_msg 6183 6184 00002449 BE[3553] mov si, msg_boot_indicator 6185 0000244C E8FAF9 call print_msg 6186 0000244F BE[0B5E] mov si, msg_YES 6187 00002452 F60580 test byte [di+ptBootable], 80h 6188 00002455 7503 jnz short ssp_3 6189 00002457 BE[115E] mov si, msg_NO 6190 ssp_3: 6191 0000245A E8ECF9 call print_msg 6192 6193 0000245D BE[4D53] mov si, msg_starting_head 6194 00002460 E8E6F9 call print_msg 6195 00002463 8A4501 mov al, [di+ptBeginHead] 6196 00002466 E8B200 call write_byte_decimal 6197 00002469 E8DDF9 call print_msg 6198 0000246C BE[6553] mov si, msg_starting_sector 6199 0000246F E8D7F9 call print_msg 6200 00002472 8A4502 mov al, [di+ptBeginSector] 6201 00002475 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 6202 00002477 243F and al, 3Fh ; sector number, 1 to 63 6203 00002479 E89F00 call write_byte_decimal 6204 0000247C E8CAF9 call print_msg 6205 0000247F BE[7D53] mov si, msg_starting_cylinder 6206 00002482 E8C4F9 call print_msg 6207 00002485 8A4503 mov al, [di+ptBeginCylinder] ; bits 0to7 of cyl 6208 00002488 C0EA06 shr dl, 6 ; bits 8&9 of cyl 6209 0000248B 88D4 mov ah, dl 6210 0000248D 31D2 xor dx, dx 6211 0000248F BE[CF6E] mov si, msg_partition_sectors + 7 ; max. 7 digits 6212 ; dx_ax: binary number 6213 00002492 E83CFA call bin_to_decimal 6214 ; ds:si = decimal number text address 6215 00002495 E8B1F9 call print_msg 6216 00002498 BE[9553] mov si, msg_system_id 6217 0000249B E8ABF9 call print_msg 6218 ; Write file system name (again, copy) 6219 0000249E BE[D352] mov si, pt_row + pt_fsn_offset 6220 ;mov cx, 14 6221 000024A1 B10E mov cl, 14 6222 000024A3 B40E mov ah, 0Eh ; write tty 6223 000024A5 BB0700 mov bx, 7 6224 ssp_4: 6225 000024A8 AC lodsb 6226 000024A9 CD10 int 10h 6227 000024AB E2FB loop ssp_4 6228 6229 000024AD BE[AD53] mov si, msg_ending_head 6230 000024B0 E896F9 call print_msg 6231 000024B3 8A4505 mov al, [di+ptEndHead] 6232 000024B6 E86200 call write_byte_decimal 6233 000024B9 E88DF9 call print_msg 6234 000024BC BE[C553] mov si, msg_ending_sector 6235 000024BF E887F9 call print_msg 6236 000024C2 8A4506 mov al, [di+ptEndSector] 6237 000024C5 88C2 mov dl, al ; bits 7&8 are bits 8&9 of cyl 6238 000024C7 243F and al, 3Fh ; sector number, 1 to 63 6239 000024C9 E84F00 call write_byte_decimal 6240 000024CC E87AF9 call print_msg 6241 000024CF BE[DD53] mov si, msg_ending_cylinder 6242 000024D2 E874F9 call print_msg 6243 000024D5 8A4507 mov al, [di+ptEndCylinder] ; bits 0to7 of cyl 6244 000024D8 C0EA06 shr dl, 6 ; bits 8&9 of cyl 6245 000024DB 88D4 mov ah, dl 6246 000024DD 31D2 xor dx, dx 6247 000024DF BE[CF6E] mov si, msg_partition_sectors + 7 ; max. 7 digits 6248 ; dx_ax: binary number 6249 000024E2 E8ECF9 call bin_to_decimal 6250 ; ds:si = decimal number text address 6251 000024E5 E861F9 call print_msg 6252 6253 000024E8 BE[F553] mov si, msg_relative_sectors 6254 000024EB E85BF9 call print_msg 6255 000024EE 8B4508 mov ax, [di+ptStartSector] 6256 000024F1 8B550A mov dx, [di+ptStartSector+2] 6257 ;mov si, msg_partition_sectors + 7 ; max. 11 digits 6258 000024F4 BE[CF6E] mov si, reserved_bytes + 10 ; max. 11 digits 6259 000024F7 E8D7F9 call bin_to_decimal 6260 000024FA E84CF9 call print_msg 6261 6262 000024FD BE[0F54] mov si, msg_total_sectors 6263 00002500 E846F9 call print_msg 6264 00002503 8B450C mov ax, [di+ptSectors] 6265 00002506 8B550E mov dx, [di+ptSectors+2] 6266 ;mov si, msg_partition_sectors + 7 ; max. 11 digits 6267 00002509 BE[CF6E] mov si, reserved_bytes + 10 ; max. 11 digits 6268 0000250C E8C2F9 call bin_to_decimal 6269 0000250F E837F9 call print_msg 6270 6271 ; 24/02/2019 6272 00002512 BE[6756] mov si, CRLF 6273 00002515 E831F9 call print_msg 6274 6275 00002518 89FE mov si, di ; partition table row address 6276 6277 0000251A C3 retn 6278 6279 ;----------------------------------------------------------------------------- 6280 6281 write_byte_decimal: 6282 ; INPUT -> 6283 ; AL = binary number 6284 ; OUTPUT -> 6285 ; DS:SI = decimal number text address 6286 ; (ASCIIZ string) 6287 ; 6288 ; (SI, AX, CX will me modified) 6289 6290 0000251B BE[D06E] mov si, msg_partition_sectors + 8 6291 0000251E B10A mov cl, 10 6292 wbd_loop: 6293 00002520 4E dec si 6294 00002521 30E4 xor ah, ah 6295 00002523 F6F1 div cl 6296 00002525 80C430 add ah, '0' 6297 00002528 8824 mov [si], ah 6298 0000252A 20C0 and al, al 6299 0000252C 75F2 jnz short wbd_loop 6300 0000252E C3 retn 6301 6302 ;----------------------------------------------------------------------------- 6303 ; 03/02/2019 6304 ; 16/10/2020 6305 6306 init_partition_tables: 6307 6308 ; INPUT -> none 6309 ; OUTPUT -> none 6310 6311 ; 12/02/2019 6312 ;cmp word [MBIDCode], 0AA55h 6313 ;jne ipt_stc ; invalid 6314 6315 ; 15/02/2019 6316 ; clear primary partition tables structure/list 6317 6318 0000252F BF[5E71] mov di, part_table_boot_ind 6319 00002532 B92400 mov cx, 36 ; 18*4 = 72 bytes 6320 00002535 31C0 xor ax, ax ; 0 6321 00002537 F3AB rep stosw 6322 6323 00002539 A3[A671] mov [pcount], ax ; reset (pcount & ppcount) 6324 0000253C A3[A871] mov [apcount], ax ; reset (apcount & epnumber) 6325 6326 0000253F BE[FE58] mov si, MasterBootBuff+446 ; Partition table offset 6327 ;mov cx, 4 6328 00002542 B104 mov cl, 4 6329 00002544 31FF xor di, di 6330 ipt_0: 6331 00002546 8A6404 mov ah, [si+ptFileSystemID] 6332 6333 00002549 20E4 and ah, ah 6334 0000254B 0F841801 jz ipt_8 ; empty 6335 6336 0000254F FE06[A671] inc byte [pcount] ; partition count 6337 6338 00002553 80FC01 cmp ah, 1 ; FAT12 6339 00002556 7427 je short ipt_2 6340 00002558 80FC04 cmp ah, 4 ; FAT16 6341 0000255B 7422 je short ipt_2 6342 0000255D 7224 jb short ipt_3 6343 0000255F 80FC06 cmp ah, 6 ; FAT16 big 6344 00002562 741B je short ipt_2 6345 00002564 7712 ja short ipt_1 ; EXTENDED 6346 6347 ;cmp ah, 5 ; EXTENDED 6348 ;jne short ipt_3 6349 6350 00002566 803E[A971]00 cmp byte [epnumber], 0 6351 0000256B 0F87B100 ja ipt_stc ; invalid (more than 1 extended dos partition) 6352 6353 0000256F B005 mov al, 5 6354 00002571 28C8 sub al, cl ; partition number 1 to 4 6355 00002573 A2[A971] mov byte [epnumber], al ; extended partition entry number (1 to 4) 6356 00002576 EB0B jmp short ipt_3 6357 ipt_1: 6358 00002578 80FC0B cmp ah, 0Bh ; FAT32 (CHS) 6359 0000257B 7506 jne short ipt_3 ; 16/10/2020 6360 ; 26/10/2020 6361 0000257D 7400 je short ipt_2 6362 ;cmp ah, 07h ; NTFS (Windows FS) 6363 ;jne short ipt_3 ; accept NTFS as primary dos partition 6364 ; ; (then, extended partition can be created) 6365 ipt_2: 6366 0000257F FE06[A771] inc byte [ppcount] ; primary dos partition count 6367 ipt_3: 6368 00002583 88A5[6371] mov [part_table_sys_id+di], ah ; Partition Type (FS type) 6369 6370 00002587 8A04 mov al, [si+ptBootable] 6371 6372 00002589 20C0 and al, al 6373 0000258B 7413 jz short ipt_4 6374 6375 0000258D 803E[A871]01 cmp byte [apcount], 1 ; check (previous) active partition count 6376 00002592 0F838A00 jnb ipt_stc ; invalid (if it is not zero here) 6377 6378 00002596 3C80 cmp al, 80h ; active partition sign/flag? 6379 00002598 0F858400 jne ipt_stc ; invalid flag 6380 6381 0000259C FE06[A871] inc byte [apcount] ; active partition count = 1 6382 ipt_4: 6383 000025A0 8885[5E71] mov [part_table_boot_ind+di], al 6384 6385 000025A4 A0[AC40] mov al, [heads] 6386 ipt_4_fix: 6387 000025A7 FEC8 dec al 6388 000025A9 8A6401 mov ah, [si+ptBeginHead] 6389 000025AC 38E0 cmp al, ah 6390 ;jb short ipt_retn ; invalid 6391 000025AE 7272 jb ipt_heads_fix ; 10/02/2019 6392 000025B0 88A5[5F71] mov [part_table_start_head+di], ah 6393 000025B4 8A6405 mov ah, [si+ptEndHead] 6394 000025B7 38E0 cmp al, ah 6395 ;jb short ipt_retn ; invalid 6396 000025B9 7267 jb short ipt_heads_fix ; 10/02/2019 6397 000025BB 88A5[6471] mov [part_table_end_head+di], ah 6398 000025BF A0[AA40] mov al, [sectors] 6399 000025C2 8A7C02 mov bh, [si+ptBeginSector] 6400 000025C5 88FC mov ah, bh 6401 000025C7 80E43F and ah, 3Fh ; 63 6402 000025CA 38E0 cmp al, ah 6403 000025CC 7253 jb short ipt_retn ; invalid 6404 000025CE 88A5[6071] mov [part_table_start_sector+di], ah 6405 000025D2 8A7406 mov dh, [si+ptEndSector] 6406 000025D5 88F4 mov ah, dh 6407 000025D7 80E43F and ah, 3Fh ; 63 6408 000025DA 38E0 cmp al, ah 6409 000025DC 7243 jb short ipt_retn ; invalid 6410 000025DE 88A5[6571] mov [part_table_end_sector+di], ah 6411 000025E2 C0EF06 shr bh, 6 6412 000025E5 8A5C03 mov bl, [si+ptBeginCylinder] 6413 000025E8 A1[AE40] mov ax, [cylinders] 6414 000025EB 48 dec ax 6415 000025EC 39D8 cmp ax, bx 6416 000025EE 7231 jb short ipt_retn ; invalid 6417 000025F0 899D[6171] mov [part_table_start_cyl+di], bx 6418 000025F4 C0EE06 shr dh, 6 6419 000025F7 8A5407 mov dl, [si+ptEndCylinder] 6420 000025FA 39D0 cmp ax, dx 6421 000025FC 7223 jb short ipt_retn ; invalid 6422 000025FE 8995[6671] mov [part_table_end_cyl+di], dx 6423 6424 00002602 8B4408 mov ax, [si+ptStartSector] 6425 00002605 8B540A mov dx, [si+ptStartSector+2] 6426 6427 00002608 8985[6871] mov [part_table_rel_sec_lw+di], ax 6428 0000260C 8995[6A71] mov [part_table_rel_sec_hw+di], dx 6429 6430 00002610 09D0 or ax, dx 6431 00002612 740C jz short ipt_stc ; invalid (start sector must not be zero) 6432 6433 00002614 8B440C mov ax, [si+ptSectors] 6434 00002617 8B540E mov dx, [si+ptSectors+2] 6435 6436 0000261A 89D3 mov bx, dx 6437 0000261C 09C3 or bx, ax 6438 ;jz short ipt_stc ; invalid (zero size of partition) 6439 0000261E 7521 jnz short ipt_6 ; 10/02/2019 6440 6441 ;cmp dx, [total_sectors+2] 6442 ;ja short ipt_stc ; invalid (partition size > disk capacity) 6443 ;jb short ipt_6 6444 ;;cmp ax, [total_sectors] ; (ax + 1) <= total sectors 6445 ;jb short ipt_6 6446 6447 ipt_stc: 6448 ; invalid MBR data 6449 00002620 F9 stc 6450 ipt_retn: 6451 00002621 C3 retn 6452 6453 ipt_heads_fix: 6454 ; 10/02/2019 6455 ; AL = [heads] - 1 6456 6457 00002622 F606[AE40]01 test byte [cylinders], 1 6458 00002627 75F7 jnz short ipt_stc ; odd cylinder count (can not be shifted) 6459 6460 00002629 FEC0 inc al ; = [heads] 6461 0000262B 3C08 cmp al, 8 6462 0000262D 77F1 ja short ipt_stc ; this fix is needed for <= 16 heads (& 17 spt) 6463 0000262F D0E0 shl al, 1 6464 00002631 A2[AC40] mov [heads], al ; heads = heads*2 6465 00002634 D12E[AE40] shr word [cylinders], 1 ; cylinders = cylinders/2 6466 00002638 E96CFF jmp ipt_4_fix 6467 6468 ipt_5: 6469 0000263B 83C712 add di, 18 6470 0000263E E905FF jmp ipt_0 6471 6472 ipt_6: 6473 00002641 8985[6C71] mov [part_table_num_sec_lw+di], ax 6474 00002645 8995[6E71] mov [part_table_num_sec_hw+di], dx 6475 6476 00002649 0385[6871] add ax, [part_table_rel_sec_lw+di] 6477 0000264D 1395[6A71] adc dx, [part_table_rel_sec_hw+di] 6478 00002651 72CE jc short ipt_retn ; invalid 6479 6480 00002653 3B16[A26E] cmp dx, [total_sectors+2] 6481 00002657 77C7 ja short ipt_stc ; invalid (partition end > disk capacity) 6482 00002659 7206 jb short ipt_7 6483 0000265B 3B06[A06E] cmp ax, [total_sectors] ; ax <= total sectors 6484 0000265F 77BF ja short ipt_stc ; invalid (partition end > disk capacity) 6485 ipt_7: 6486 00002661 83C610 add si, 16 6487 00002664 E2D5 loop ipt_5 6488 6489 ; OK! 6490 6491 ;clc 6492 00002666 C3 retn 6493 6494 ipt_8: 6495 ; Empty partition table check (all of 16 bytes must be 0) 6496 00002667 51 push cx 6497 00002668 B108 mov cl, 8 6498 ipt_9: 6499 0000266A AD lodsw 6500 0000266B 09C0 or ax, ax 6501 0000266D 7506 jnz short ipt_10 6502 0000266F E2F9 loop ipt_9 6503 00002671 59 pop cx 6504 00002672 E2C7 loop ipt_5 6505 6506 ;clc 6507 00002674 C3 retn 6508 ipt_10: 6509 00002675 59 pop cx 6510 ; invalid 6511 00002676 F9 stc 6512 00002677 C3 retn 6513 6514 ;----------------------------------------------------------------------------- 6515 ; 25/10/2020 6516 6517 ; 02/02/2019 6518 6519 sort_partition_table: 6520 6521 ; INPUT -> none 6522 ; OUTPUT -> none 6523 6524 00002678 31DB xor bx, bx 6525 ;jmp short sortpt_2 ; 25/10/2020 6526 sortpt_1: 6527 0000267A 889F[EA6E] mov [bx+sort], bl ; 0 6528 0000267E FEC3 inc bl 6529 sortpt_2: 6530 00002680 80FB04 cmp bl, 4 ; number of partition table entries to sort 6531 00002683 72F5 jb short sortpt_1 6532 6533 ; Do a bubble sort 6534 6535 00002685 EB04 jmp short sortpt_4 6536 sortpt_3: 6537 ; Sort until we don't do a swap 6538 6539 00002687 08C9 or cl, cl ; sort changed ? 6540 00002689 744A jz short sortpt_8 ; no. 6541 sortpt_4: 6542 0000268B 30C9 xor cl, cl 6543 6544 0000268D B301 mov bl, 1 6545 6546 0000268F B212 mov dl, 18 ; partition table structure size 6547 00002691 EB07 jmp short sortpt_6 6548 sortpt_5: 6549 00002693 FEC3 inc bl 6550 6551 00002695 80FB04 cmp bl, 4 6552 00002698 73ED jnb short sortpt_3 6553 6554 sortpt_6: 6555 0000269A 8A87[EA6E] mov al, [bx+sort] 6556 6557 0000269E F6E2 mul dl 6558 6559 000026A0 89C6 mov si, ax 6560 6561 000026A2 8BBC[6671] mov di, [part_table_end_cyl+si] 6562 6563 000026A6 8A87[E96E] mov al, [bx+sort-1] 6564 6565 000026AA F6E2 mul dl ; * 18 6566 6567 000026AC 97 xchg di, ax 6568 6569 000026AD 3985[6671] cmp [part_table_end_cyl+di], ax ; previous > current 6570 000026B1 7714 ja short sortpt_7 ; swap order indicators 6571 6572 ; If current entry is empty partition entry 6573 ; and previous entry is not empty partition entry 6574 ; swap them. 6575 6576 000026B3 8B84[6E71] mov ax, [part_table_num_sec_hw+si] ; current entry 6577 000026B7 0B84[6C71] or ax, [part_table_num_sec_lw+si] 6578 000026BB 75D6 jnz short sortpt_5 6579 6580 000026BD 8B85[6E71] mov ax, [part_table_num_sec_hw+di] ; previous entry 6581 000026C1 0B85[6C71] or ax, [part_table_num_sec_lw+di] 6582 000026C5 74CC jz short sortpt_5 6583 sortpt_7: 6584 ; Swap the order indicators 6585 6586 000026C7 8B87[E96E] mov ax, [bx+sort-1] 6587 000026CB 86E0 xchg ah, al 6588 000026CD 8987[E96E] mov [bx+sort-1], ax 6589 6590 000026D1 B101 mov cl, 1 ; sort changed 6591 000026D3 EBBE jmp short sortpt_5 6592 sortpt_8: 6593 000026D5 C606[0671]01 mov byte [p_sorted], 1 ; 04/02/2019 6594 6595 000026DA C3 retn 6596 6597 ;----------------------------------------------------------------------------- 6598 ; 03/02/2019 6599 6600 find_part_free_space: ; find/calculate free space for partitions 6601 ; 15/02/2019 6602 6603 ; INPUT -> 6604 ; AL = 0 -> calculate for primary/MBR partitions 6605 ; AL = 5 -> calculate for extended partition 6606 ; OUTPUT -> 6607 ; CX = the largest free space/cylinders (between partitions) 6608 ; AX = Free space index (gap number) - from 0 to 4 - 6609 ; BX = Free space structure offset (for the largest free space) 6610 ; 6611 ; 22/02/2019 6612 ; [freespace_count] = number of free spaces/gaps 6613 6614 000026DB A2[0571] mov [p_type], al 6615 6616 ; Sort the partition table 6617 6618 000026DE E897FF call sort_partition_table ; 16/02/2019 6619 6620 ; Initialize free space to zero 6621 6622 ; 15/02/2019 6623 000026E1 BF[F271] mov di, fspc ; free_space.space 6624 000026E4 B92800 mov cx, 5*8 ; (5*16/2) 6625 000026E7 31C0 xor ax, ax ; 0 6626 000026E9 F3AB rep stosw 6627 6628 000026EB A2[0271] mov [freespace_count], al ; 0 6629 ; 22/02/2019 6630 ;mov [last_found_partition], al ; 0 6631 6632 000026EE A3[0071] mov [_i_], ax ; 0 6633 000026F1 EB11 jmp short fpfs_2 6634 fpfs_1: 6635 000026F3 FE06[0071] inc byte [_i_] 6636 ;;fpfs_2: 6637 000026F7 803E[0071]04 cmp byte [_i_], 4 6638 000026FC 7203 jb short fpfs_3 6639 000026FE E97801 jmp fpfs_13 6640 fpfs_3: 6641 ; Find space between start of disk and first partition 6642 6643 00002701 A1[0071] mov ax, [_i_] 6644 fpfs_2: 6645 00002704 89C3 mov bx, ax 6646 ;mov al, [sort+bx] 6647 00002706 8A8F[EA6E] mov cl, [sort+bx] ; 15/02/2019 6648 6649 ;mov cl, 18 ; partition table structure size = 18 bytes 6650 0000270A B012 mov al, 18 ; 15/02/2019 6651 0000270C F6E1 mul cl 6652 0000270E 89C3 mov bx, ax 6653 6654 00002710 80BF[6371]00 cmp byte [part_table_sys_id+bx], 0 6655 00002715 74DC je short fpfs_1 6656 6657 00002717 880E[0471] mov [last_found_partition], cl ; 15/02/2019 6658 6659 0000271B 30C9 xor cl, cl ; 0 6660 0000271D B001 mov al, 1 ; LBA = 1 (after MBR) ; ah = 0 6661 6662 0000271F 803E[0571]05 cmp byte [p_type], 5 ; EXTENDED 6663 00002724 7509 jne short fpfs_4 6664 6665 ; This is a special case - the extended partition can not start 6666 ; on cylinder 0 due to its architecture. Protect against that here 6667 6668 ; 13/02/2019 6669 ; LBA value of free space start 6670 00002726 A0[AA40] mov al, [sectors] 6671 00002729 F626[AC40] mul byte [heads] 6672 ; ax = start sector (for Extended Partition) 6673 0000272D FEC1 inc cl ; 1 ; cx = start cylinder = 1 6674 fpfs_4: 6675 ; Found a partition, get the space 6676 6677 ; 15/02/2019 6678 0000272F 8B97[6171] mov dx, [part_table_start_cyl+bx] 6679 00002733 39CA cmp dx, cx 6680 00002735 0F86C000 jna fpfs_9 ; It is accepted as free (partition) space 6681 ; if this space between masterboot sector and partition 1 6682 ; has 1 cylinder (heads*spt) size at least. 6683 ; 22/02/2019 6684 00002739 31FF xor di, di ; 0 ; Reset Free Space Table offset 6685 6686 0000273B FE06[0271] inc byte [freespace_count] ; mov byte [freespace_count], 1 6687 6688 0000273F 890E[F471] mov [free_space.start], cx ; 0 (for PP) or 1 (for EP) 6689 6690 ; non-aligned address of start sector (for the 1st partition as sorted) 6691 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 6692 ; if new partition will be selected as a primary dos partition. 6693 ; (But, start sector -LBA- will not be changed 6694 ; if it is a non-dos or user input type partition.. unless 6695 ; cylinder boundary alignment option is used.) 6696 6697 00002743 A3[FE71] mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 6698 ; or 1 (for PP) 6699 ;mov [free_space.startsector+2], 0 6700 6701 ; free space ends before start of next valid partition 6702 00002746 89D0 mov ax, dx ; start cylinder of partition 1 (as sorted) 6703 00002748 29CA sub dx, cx ; cylinder count of free space 1 (gap 1) 6704 0000274A 48 dec ax ; end cylinder of free space 1 (gap 1) 6705 0000274B A3[F671] mov [free_space.end], ax 6706 0000274E 8916[F271] mov [free_space.space], dx 6707 6708 ; save free space (1) as (non-aligned) sector count 6709 00002752 8B87[6871] mov ax, [part_table_rel_sec_lw+bx] 6710 00002756 8B97[6A71] mov dx, [part_table_rel_sec_hw+bx] 6711 0000275A 2B06[FE71] sub ax, [free_space.startsector] 6712 0000275E 83DA00 sbb dx, 0 6713 00002761 A3[FA71] mov [free_space.sectors_unused], ax 6714 00002764 8916[FC71] mov [free_space.sectors_unused+2], dx 6715 6716 ;mov ax, [free_space.space] 6717 6718 ;call cylinders_to_sectors 6719 6720 ;mov [free_space.sectors_unused], ax 6721 ;mov [free_space.sectors_unused+2], dx 6722 6723 00002768 8B0E[AE40] mov cx, [cylinders] ; Total (disk) cylinders -divisor- 6724 0000276C 8B1E[F271] mov bx, [free_space.space] ; Partition cylinders -dividend- 6725 6726 00002770 E81002 call cylinders_to_percent 6727 6728 00002773 A3[F871] mov [free_space.percent_unused], ax 6729 6730 ; 15/02/2019 6731 ;mov bl, [_i_] 6732 ;xor bh, bh 6733 ;mov al, [sort+bx] 6734 6735 ;mov [last_found_partition], al 6736 6737 ; Look for space between the rest of the partitions 6738 6739 fpfs_7: 6740 ; ah = 0 6741 ;mov al, [_i_] 6742 ;;cbw 6743 ;mov bx, ax 6744 ; 22/02/2019 6745 00002776 8B1E[0071] mov bx, [_i_] 6746 6747 ; 15/02/2019 6748 ;mov al, [sort+bx] 6749 0000277A 8A8F[EA6E] mov cl, [sort+bx] 6750 ;mov bl, 18 6751 ;mul bl 6752 0000277E B012 mov al, 18 6753 00002780 F6E1 mul cl 6754 00002782 89C6 mov si, ax 6755 6756 00002784 80BC[6371]00 cmp byte [part_table_sys_id+si], 0 6757 00002789 746E je short fpfs_9 6758 6759 ; 15/02/2019 6760 0000278B 860E[0471] xchg [last_found_partition], cl 6761 6762 ; Check to see if more than one partition on a cylinder 6763 ; If so, leave the space at zero */ 6764 6765 ; NOTE: 6766 ; It is accepted as valid free (partition) space 6767 ; if free space (gap) between partitions 6768 ; has 1 cylinder (heads*spt) size at least. 6769 6770 0000278F B012 mov al, 18 ; Partition tables/data structure size = 18 bytes 6771 00002791 F6E1 mul cl 6772 00002793 89C3 mov bx, ax ; ah = 0 6773 6774 00002795 8B97[6671] mov dx, [part_table_end_cyl+bx] ; end cyl. of previous partition 6775 00002799 8B84[6171] mov ax, [part_table_start_cyl+si] ; start cyl. of current partition 6776 6777 0000279D 42 inc dx ; start cylinder of free space is after the end cylinder of 6778 ; the previous partition (as sorted) 6779 6780 0000279E 39D0 cmp ax, dx ; and it must be before than the next partition (as sorted) 6781 000027A0 7657 jna short fpfs_9 ; je short fpfs_9 6782 6783 ; No, things are normal 6784 ; Get space between the end of the last one and the start of the next one 6785 6786 ; 22/02/2019 6787 ;add di, 16 6788 000027A2 8B3E[0271] mov di, [freespace_count] 6789 000027A6 C1E704 shl di, 4 ; * 16 ; next entry offset (in free space table) 6790 6791 000027A9 FE06[0271] inc byte [freespace_count] 6792 6793 000027AD 89C1 mov cx, ax 6794 000027AF 29D1 sub cx, dx 6795 000027B1 48 dec ax 6796 000027B2 8995[F471] mov [free_space.start+di], dx 6797 000027B6 8985[F671] mov [free_space.end+di], ax 6798 000027BA 898D[F271] mov [free_space.space+di], cx 6799 6800 ;mov ax, [free_space.space+di] 6801 ;call cylinders_to_sectors 6802 ;mov [free_space.sectors_unused+di], ax 6803 ;mov [free_space.sectors_unused+2+di], dx 6804 6805 ; calculate and save (non-aligned) free sector count between partitions 6806 6807 000027BE 8B87[6871] mov ax, [part_table_rel_sec_lw+bx] 6808 000027C2 8B97[6A71] mov dx, [part_table_rel_sec_hw+bx] 6809 000027C6 0387[6C71] add ax, [part_table_num_sec_lw+bx] 6810 000027CA 1397[6E71] adc dx, [part_table_num_sec_hw+bx] 6811 6812 000027CE 8B8C[6871] mov cx, [part_table_rel_sec_lw+si] 6813 000027D2 8B9C[6A71] mov bx, [part_table_rel_sec_hw+si] 6814 6815 000027D6 8985[FE71] mov [free_space.startsector+di], ax 6816 000027DA 8995[0072] mov [free_space.startsector+2+di], dx 6817 6818 000027DE 29C1 sub cx, ax 6819 000027E0 19D3 sbb bx, dx 6820 6821 000027E2 898D[FA71] mov [free_space.sectors_unused+di], cx 6822 000027E6 899D[FC71] mov [free_space.sectors_unused+2+di], bx 6823 6824 fpfs_8: 6825 ; NOTE: Percentage is based on cylinder-boundary aligned partition size. 6826 ; (total disk cylinders and partition's cylinder count are used for that) 6827 6828 000027EA 8B0E[AE40] mov cx, [cylinders] ; -divisor- 6829 000027EE 8B9D[F271] mov bx, [free_space.space+di] ; -dividend- 6830 000027F2 E88E01 call cylinders_to_percent 6831 6832 000027F5 8985[F871] mov [free_space.percent_unused+di], ax 6833 6834 ; ah = 0 6835 6836 ; 15/02/2019 6837 ;mov bl, [_i_] 6838 ;xor bh, bh 6839 ;mov al, [sort+bx] 6840 ; 6841 ;mov [last_found_partition], al 6842 6843 fpfs_9: 6844 000027F9 FE06[0071] inc byte [_i_] 6845 fpfs_10: 6846 000027FD 803E[0071]04 cmp byte [_i_], 4 6847 00002802 7303 jnb short fpfs_11 6848 6849 00002804 E96FFF jmp fpfs_7 6850 6851 fpfs_11: 6852 ; Find the space between the last partition and the end of the disk 6853 ; Make sure that freespace cannot become negative 6854 6855 00002807 A0[0471] mov al, [last_found_partition] 6856 0000280A B112 mov cl, 18 ; Partition table structure size = 18 bytes 6857 0000280C F6E1 mul cl 6858 0000280E 89C3 mov bx, ax 6859 00002810 8B0E[AE40] mov cx, [cylinders] 6860 00002814 49 dec cx ; 15/02/2019 6861 ; (min. cylinder count = 1 for a valid/usable free space) 6862 00002815 8B87[6671] mov ax, [part_table_end_cyl+bx] 6863 ;cmp [part_table_end_cyl+bx], cx 6864 00002819 39C8 cmp ax, cx 6865 0000281B 7203 jb short fpfs_12 6866 0000281D E9A600 jmp fpfs_15 6867 fpfs_12: 6868 ; 22/02/2019 6869 00002820 8B3E[0271] mov di, [freespace_count] 6870 00002824 C1E704 shl di, 4 ; * 16 ; next entry offset (in free space table) 6871 6872 00002827 FE06[0271] inc byte [freespace_count] 6873 6874 0000282B 898D[F671] mov [free_space.end+di], cx ; end cyl. of free space 5 (gap 5) 6875 ;mov ax, [part_table_end_cyl+bx] 6876 0000282F 89CA mov dx, cx 6877 00002831 29C2 sub dx, ax 6878 00002833 8995[F271] mov [free_space.space+di], dx ; di = 4*16 6879 00002837 40 inc ax 6880 00002838 8985[F471] mov [free_space.start+di], ax 6881 6882 ;inc cx ; [cylinders] 6883 ;mov ax, [free_space.space+si] 6884 ;call cylinders_to_sectors 6885 ;mov [free_space.sectors_unused+di], ax 6886 ;mov [free_space.sectors_unused+2+di], dx 6887 6888 ; calculate and save (non-aligned) free sector count 6889 6890 ; 22/02/2019 6891 0000283C 8B87[6871] mov ax, [part_table_rel_sec_lw+bx] 6892 00002840 8B97[6A71] mov dx, [part_table_rel_sec_hw+bx] 6893 00002844 0387[6C71] add ax, [part_table_num_sec_lw+bx] 6894 00002848 1397[6E71] adc dx, [part_table_num_sec_hw+bx] 6895 6896 0000284C 8985[FE71] mov [free_space.startsector+di], ax 6897 00002850 8995[0072] mov [free_space.startsector+2+di], dx 6898 6899 00002854 8B0E[A06E] mov cx, [total_sectors] 6900 00002858 8B1E[A26E] mov bx, [total_sectors+2] 6901 0000285C 29C1 sub cx, ax 6902 0000285E 19D3 sbb bx, dx 6903 00002860 898D[FA71] mov [free_space.sectors_unused+di], cx 6904 00002864 899D[FC71] mov [free_space.sectors_unused+2+di], bx 6905 6906 00002868 8B0E[AE40] mov cx, [cylinders] 6907 0000286C 8B9D[F271] mov bx, [free_space.space+di] 6908 00002870 E81001 call cylinders_to_percent 6909 00002873 8985[F871] mov [free_space.percent_unused+di], ax 6910 00002877 EB4D jmp short fpfs_15 6911 6912 fpfs_13: 6913 ; No partitions found, show entire space as free 6914 6915 ; 22/02/2019 6916 00002879 FE06[0271] inc byte [freespace_count] ; mov byte [freespace_count], 1 6917 6918 ; 15/02/2019 6919 ;sub ax, ax 6920 0000287D 29D2 sub dx, dx 6921 6922 ;inc al ; LBA = 1 (after MBR) ; ah = 0 6923 0000287F B001 mov al, 1 ; 25/02/2019 6924 6925 ;This is a special case - the extended partition can not start 6926 ;on cylinder 0 due to its architecture. Protect against that here 6927 6928 00002881 803E[0571]05 cmp byte [p_type], 5 ; EXTENDED 6929 00002886 7509 jne short fpfs_14 6930 6931 00002888 FEC2 inc dl 6932 6933 ; 15/02/2019 6934 ; LBA value of free space start 6935 0000288A A0[AA40] mov al, [sectors] 6936 0000288D F626[AC40] mul byte [heads] 6937 ; ax = start sector (for Extended Partition) 6938 fpfs_14: 6939 00002891 8916[F471] mov [free_space.start], dx ; 0 or 1 6940 6941 ; non-aligned address of start sector (for the 1st partition as sorted) 6942 ; NOTE: later, start sector will be moved to (chs) head 1 and sector 1 6943 ; if new partition will be selected as a primary dos partition. 6944 6945 00002895 A3[FE71] mov [free_space.startsector], ax ; = [sectors]*[heads] (for EP) 6946 ; or 1 (for PP) 6947 ;mov [free_space.startsector+2], 0 6948 6949 00002898 A1[AE40] mov ax, [cylinders] ; disk capacity 6950 0000289B 89C1 mov cx, ax 6951 0000289D 48 dec ax 6952 0000289E A3[F671] mov [free_space.end], ax 6953 000028A1 29D0 sub ax, dx 6954 000028A3 40 inc ax 6955 000028A4 A3[F271] mov [free_space.space], ax 6956 6957 000028A7 A1[A06E] mov ax, [total_sectors] 6958 000028AA 8B16[A26E] mov dx, [total_sectors+2] 6959 000028AE 2B06[FE71] sub ax, [free_space.startsector] 6960 000028B2 83DA00 sbb dx, 0 6961 000028B5 A3[FA71] mov [free_space.sectors_unused], ax 6962 000028B8 8916[FC71] mov [free_space.sectors_unused+2], dx 6963 6964 ;mov cx, [cylinders] 6965 000028BC 8B1E[F271] mov bx, [free_space.space] 6966 000028C0 E8C000 call cylinders_to_percent 6967 000028C3 A3[F871] mov [free_space.percent_unused], ax 6968 6969 fpfs_15: 6970 ; Find largest free space 6971 000028C6 29C9 sub cx, cx 6972 ; 22/02/2019 6973 000028C8 29C0 sub ax, ax 6974 000028CA 31DB xor bx, bx 6975 000028CC 8A16[0271] mov dl, [freespace_count] 6976 000028D0 08D2 or dl, dl 6977 000028D2 7420 jz short fpfs_19 6978 000028D4 8816[0071] mov [_i_], dl 6979 fpfs_16: 6980 000028D8 8B97[F271] mov dx, [free_space.space+bx] 6981 000028DC 39CA cmp dx, cx 6982 000028DE 7604 jbe short fpfs_17 6983 ; 22/02/2019 6984 000028E0 89D1 mov cx, dx ; Largest free space 6985 000028E2 89D8 mov ax, bx 6986 fpfs_17: 6987 000028E4 FE0E[0071] dec byte [_i_] 6988 000028E8 7405 jz short fpfs_18 6989 6990 000028EA 83C310 add bx, 16 ; Free space structure size 6991 000028ED EBE9 jmp short fpfs_16 6992 fpfs_18: 6993 ; 22/02/2019 6994 000028EF 89C3 mov bx, ax ; offset (from 0 to 64) 6995 000028F1 C0E804 shr al, 4 ; index (from 0 to 4) 6996 fpfs_19: 6997 000028F4 C3 retn 6998 6999 ;----------------------------------------------------------------------------- 7000 7001 ; ; 15/02/2019 7002 ;find_enough_free_space: 7003 ; ; Find enough free space 7004 ; ; 7005 ; ; INPUT: 7006 ; ; AX = Requested space (in cylinders) 7007 ; ; 22/02/2019 7008 ; ; [freespace_count] = number of free spaces/gaps 7009 ; ; OUTPUT: 7010 ; ; AX = Available space 7011 ; DX = Requested space 7012 ; ; If CF = 0 -> AX >= DX 7013 ; ; If CF = 1 -> AX < DX 7014 ; ; CX = Index of available space in free space structure 7015 ; ; (GAP number, 0 to 4) - if AX > 0 - 7016 ; 7017 ; mov dx, ax ; 22/02/2019 7018 ; sub ax, ax 7019 ; xor bx, bx 7020 ; ; 22/02/2019 7021 ; mov ch, [freespace_count] 7022 ; mov [_i_], ax ; 0 7023 ; jmp short fefs_1 7024 ;fefs_0: 7025 ; ;mov al, 16 7026 ; ;mul byte [_i_] 7027 ; ;mov bx, ax 7028 ; mov bl, [_i_] 7029 ; shl bl, 4 ; * 16 7030 ;fefs_1: 7031 ; mov ax, [free_space.space+bx] 7032 ; and ax, ax 7033 ; jz short fefs_2 ; not a free space 7034 ; mov cl, [_i_] 7035 ; cmp ax, dx 7036 ; jnb short fefs_3 ; enough space 7037 ;fefs_2: 7038 ; ; 22/02/2019 7039 ; inc byte [_i_] 7040 ; cmp byte [_i_], ch 7041 ; jb short fefs_0 7042 ; sub ch, ch 7043 ; stc 7044 ; retn 7045 ;fefs_3: 7046 ; xor ch, ch 7047 ; retn 7048 7049 ;----------------------------------------------------------------------------- 7050 7051 ; 15/02/2019 7052 find_enough_free_sectors: 7053 ; Find (first) enough free space in sectors 7054 ; 7055 ; INPUT: 7056 ; DX:AX = Requested space (as non-aligned free sectors) 7057 ; 22/02/2019 7058 ; [freespace_count] = number of free spaces/gaps 7059 ; OUTPUT: 7060 ; DX:AX = AX = Available space 7061 ; If CF = 0 -> DX:AX >= Request 7062 ; If CF = 1 -> DX:AX < Request 7063 ; CX = Index of available space in free space structure 7064 ; (GAP number, 0 to 4) - if DX:AX > 0 - 7065 7066 000028F5 31FF xor di, di 7067 000028F7 31F6 xor si, si 7068 000028F9 31DB xor bx, bx 7069 ; 22/02/2019 7070 000028FB 8A2E[0271] mov ch, [freespace_count] 7071 000028FF 891E[0071] mov [_i_], bx ; 0 7072 00002903 EB07 jmp short fefss_1 7073 fefss_0: 7074 ;mov al, 16 7075 ;mul byte [_i_] 7076 ;mov bx, ax 7077 00002905 8B1E[0071] mov bx, [_i_] 7078 00002909 C0E304 shl bl, 4 ; * 16 7079 fefss_1: 7080 0000290C 81C3[FA71] add bx, free_space.sectors_unused 7081 00002910 3B5702 cmp dx, [bx+2] 7082 00002913 723B jb short fefss_7 7083 00002915 7706 ja short fefss_2 7084 00002917 3B07 cmp ax, [bx] 7085 00002919 743A je short fefss_8 7086 0000291B 7233 jb short fefss_7 ; 18/02/2019 7087 fefss_2: 7088 0000291D 833F00 cmp word [bx], 0 7089 00002920 7506 jne short fefss_3 7090 00002922 837F0200 cmp word [bx+2], 0 7091 00002926 7416 je short fefss_6 7092 fefss_3: 7093 00002928 3B7F02 cmp di, [bx+2] 7094 0000292B 7711 ja short fefss_6 7095 0000292D 7405 je short fefss_4 7096 0000292F 8B7F02 mov di, [bx+2] 7097 00002932 EB04 jmp short fefss_5 7098 fefss_4: 7099 00002934 3B37 cmp si, [bx] 7100 00002936 7306 jnb short fefss_6 7101 fefss_5: 7102 00002938 8B37 mov si, [bx] 7103 ; 22/02/2019 7104 0000293A 8A0E[0071] mov cl, [_i_] 7105 fefss_6: 7106 0000293E FE06[0071] inc byte [_i_] 7107 00002942 382E[0071] cmp byte [_i_], ch ; [freespace_count] 7108 00002946 72BD jb short fefss_0 7109 7110 00002948 89F0 mov ax, si 7111 0000294A 89FA mov dx, di 7112 0000294C 30ED xor ch, ch 7113 0000294E F9 stc 7114 0000294F C3 retn 7115 fefss_7: 7116 00002950 8B07 mov ax, [bx] 7117 00002952 8B5702 mov dx, [bx+2] 7118 fefss_8: 7119 00002955 8B0E[0071] mov cx, [_i_] 7120 00002959 C3 retn 7121 7122 ;----------------------------------------------------------------------------- 7123 7124 ; 16/02/2019 7125 get_first_free_pte: 7126 ; Find free partition table entry 7127 ; 7128 ; INPUT: 7129 ; none 7130 ; OUTPUT: 7131 ; If CF = 0 -> CX = partition table entry number 7132 ; If CF = 1 -> there is not a free entry in partition table 7133 7134 0000295A BE[FE58] mov si, MasterBootBuff+pTableOffset 7135 0000295D 31C9 xor cx, cx 7136 gffp_1: 7137 0000295F 8A4404 mov al, [si+ptFileSystemID] ; 23/02/2019 7138 7139 00002962 20C0 and al, al 7140 00002964 740E jz short gffp_3 ; empty 7141 7142 00002966 80F903 cmp cl, 3 7143 00002969 7307 jnb short gffp_2 7144 7145 0000296B FEC1 inc cl 7146 0000296D 83C610 add si, 16 ; Partition table entry size 7147 00002970 EBED jmp short gffp_1 7148 gffp_2: 7149 ; CL = 3 7150 00002972 F9 stc 7151 00002973 C3 retn 7152 gffp_3: 7153 ; CL = PTE number (0 to 3) 7154 00002974 C3 retn 7155 7156 ;----------------------------------------------------------------------------- 7157 ; 03/02/2019 7158 7159 cylinders_to_sectors: 7160 ; INPUT: 7161 ; ax = Cylinders (Total or partition's cylinder count) 7162 ; OUTPUT: 7163 ; dx:ax = Sectors 7164 7165 00002975 8B16[AC40] mov dx,[heads] 7166 00002979 F7E2 mul dx 7167 ; dx:ax = Number of tracks (cylinders*heads) 7168 0000297B 8B0E[AA40] mov cx,[sectors] 7169 0000297F E8C2E4 call mul32 7170 ; dx:ax = Number of sectors 7171 00002982 C3 retn 7172 7173 ;----------------------------------------------------------------------------- 7174 ; 03/02/2019 7175 7176 cylinders_to_percent: 7177 7178 ; INPUT: 7179 ; bx = Number of cylinders (of partition) -dividend- 7180 ; cx = Total cylinders -divisor- 7181 ; OUTPUT: 7182 ; ax = Percentage 7183 7184 ; if (cylinders_in == 0) 7185 ; percentage_out = 0; 7186 ; else if (total_cylinders == 0) 7187 ; percentage_out = 0; 7188 ; else 7189 7190 00002983 09DB or bx, bx 7191 00002985 7419 jz short ctpc_6 ; ax = 0 = percentage_out 7192 ctpc_1: 7193 00002987 09C9 or cx, cx 7194 00002989 7415 jz short ctpc_6 7195 7196 0000298B B86400 mov ax, 100 7197 0000298E F7E3 mul bx ; [cylinders_in] 7198 7199 ; dx:ax = Dividend 7200 7201 00002990 E8A3E4 call div32 ; 100*cylinders_in / total_cylinders 7202 ; DX:AX = Quotient 7203 ; BX = Remainder 7204 7205 ; ax = percentage_out 7206 7207 00002993 39CB cmp bx, cx ; is remainder >= total_cylinders/2 ? 7208 00002995 7201 jb short ctpc_5 ; No. 7209 ctpc_4: 7210 00002997 40 inc ax 7211 ctpc_5: 7212 00002998 83F864 cmp ax, 100 7213 0000299B 7603 jbe short ctpc_6 7214 0000299D B86400 mov ax, 100 7215 ctpc_6: 7216 000029A0 C3 retn 7217 7218 ;----------------------------------------------------------------------------- 7219 ; 04/02/2019 7220 7221 display_partition_table: 7222 7223 ; INPUT: 7224 ; al = 0 for MBR 7225 ; = 5 for EBR (logical drives in extended partition) 7226 ; OUTPUT: 7227 ; none 7228 7229 ;pt_positions: 7230 n_pos equ 30 ; 1 byte 7231 7232 000029A1 A2[0871] mov [_e_], al 7233 7234 ; clear screen 7235 000029A4 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 7236 000029A7 CD10 int 10h 7237 7238 000029A9 803E[0871]05 cmp byte [_e_], 5 7239 000029AE 7507 jne short dpt_1 7240 dpt_0: 7241 000029B0 BD[AA71] mov bp, ext_table_boot_ind 7242 000029B3 B045 mov al, 'E' 7243 000029B5 EB05 jmp short dpt_4 7244 dpt_1: 7245 000029B7 BD[5E71] mov bp, part_table_boot_ind 7246 000029BA B04D mov al, 'M' 7247 dpt_4: 7248 000029BC BE[A659] mov si, p_table_header 7249 000029BF 88441E mov [si+n_pos], al 7250 000029C2 E884F4 call print_msg 7251 7252 000029C5 31DB xor bx, bx 7253 000029C7 891E[0071] mov [_i_], bx 7254 dpt_5: 7255 000029CB FE06[0071] inc byte [_i_] 7256 7257 ; BX = partition entry (0 to 3) 7258 ; BP = partition table structure address 7259 7260 000029CF E86600 call display_pt_entry ; display partition table row 7261 7262 000029D2 8B1E[0071] mov bx, [_i_] 7263 7264 000029D6 80FB04 cmp bl, 4 7265 000029D9 72F0 jb short dpt_5 7266 7267 000029DB BE[E75A] mov si, p_table_footer 7268 000029DE E868F4 call print_msg 7269 7270 ; 27/02/2019 7271 000029E1 BF[9356] mov di, str_disk_sectors 7272 7273 000029E4 803E[0871]05 cmp byte [_e_], 5 7274 000029E9 741D je short dpt_9 7275 7276 ; display total disk sectors 7277 7278 ;mov di, str_disk_sectors 7279 7280 ;cmp byte [di], '0' 7281 ;jnb short dpt_8 7282 7283 000029EB A1[A06E] mov ax, [total_sectors] 7284 000029EE 8B16[A26E] mov dx, [total_sectors+2] 7285 7286 000029F2 E82200 call dpt_10 7287 dpt_8: 7288 000029F5 BE[7D56] mov si, msg_disk_sectors 7289 dpt_11: 7290 000029F8 E84EF4 call print_msg 7291 7292 000029FB BE[9356] mov si, str_disk_sectors 7293 000029FE E848F4 call print_msg 7294 7295 00002A01 BE[6756] mov si, CRLF 7296 00002A04 E842F4 call print_msg 7297 7298 00002A07 C3 retn 7299 7300 dpt_9: 7301 ; display extended partition size 7302 7303 00002A08 A1[F870] mov ax, [ep_Size] 7304 00002A0B 8B16[FA70] mov dx, [ep_Size+2] 7305 7306 00002A0F E80500 call dpt_10 7307 7308 00002A12 BE[9B56] mov si, msg_ep_size 7309 00002A15 EBE1 jmp short dpt_11 7310 7311 dpt_10: 7312 00002A17 89E6 mov si, sp 7313 00002A19 B90A00 mov cx, 10 7314 dpt_6: 7315 00002A1C E817E4 call div32 7316 7317 00002A1F 80C330 add bl, '0' 7318 00002A22 53 push bx 7319 00002A23 21C0 and ax, ax 7320 00002A25 75F5 jnz short dpt_6 7321 00002A27 21D2 and dx, dx 7322 00002A29 75F1 jnz short dpt_6 7323 7324 00002A2B 29E6 sub si, sp 7325 00002A2D D1EE shr si, 1 7326 dpt_7: 7327 00002A2F 58 pop ax 7328 00002A30 AA stosb 7329 00002A31 4E dec si 7330 00002A32 75FB jnz short dpt_7 7331 7332 00002A34 30C0 xor al, al 7333 00002A36 AA stosb 7334 7335 ; 27/02/2019 7336 00002A37 C3 retn 7337 7338 ;----------------------------------------------------------------------------- 7339 ; 04/02/2019 7340 7341 struc ptbl 7342 7343 00000000 ?? .boot_ind: resb 1 7344 00000001 ?? .start_head: resb 1 7345 00000002 ?? .start_sector: resb 1 7346 00000003 ???? .start_cyl: resw 1 7347 00000005 ?? .sys_id: resb 1 7348 00000006 ?? .end_head: resb 1 7349 00000007 ?? .end_sector: resb 1 7350 00000008 ???? .end_cyl: resw 1 7351 0000000A ???? .rel_sec_lw: resw 1 7352 0000000C ???? .rel_sec_hw: resw 1 7353 0000000E ???? .num_sec_lw: resw 1 7354 00000010 ???? .num_sec_hw: resw 1 7355 .size: 7356 7357 endstruc 7358 7359 display_pt_entry: 7360 7361 ; INPUT: 7362 ; bl = partition entry 7363 ; bh = 0 7364 ; bp = partition table structure address 7365 ; OUTPUT: 7366 ; none 7367 7368 ;pt_positions: 7369 p_pos equ 7 ; 1 byte hdi 7370 s_pos equ 9 ; 2+1 byte 7371 bh_pos equ 13 ; 2+1 bytes 7372 bs_pos equ 17 ; 2+1 bytes 7373 bc_pos equ 21 ; 2+1 bytes 7374 fs_pos equ 25 ; 2+1 bytes 7375 eh_pos equ 29 ; 2+1 bytes 7376 es_pos equ 33 ; 2+1 bytes 7377 ec_pos equ 37 ; 2+1 bytes 7378 rs_pos equ 42 ; 7 bytes 7379 ns_pos equ 52 ; 7 bytes 7380 fsx_pos equ 61 ; 14 bytes 7381 7382 00002A38 55 push bp ; 23/02/2019 7383 7384 00002A39 08DB or bl, bl 7385 00002A3B 7406 jz short dpte_0 7386 7387 ;xor bh, bh 7388 00002A3D B012 mov al, ptbl.size ; 18 7389 00002A3F F6E3 mul bl 7390 00002A41 01C5 add bp, ax 7391 dpte_0: 7392 00002A43 807E0500 cmp byte [bp+ptbl.sys_id], 0 7393 00002A47 0F860601 jna dpte_9 7394 7395 00002A4B B768 mov bh, 'h' 7396 7397 00002A4D BE[0A71] mov si, pte_row 7398 7399 ; clear partition table display buffer/row 7400 00002A50 89F7 mov di, si 7401 00002A52 B92800 mov cx, 40 7402 00002A55 B82020 mov ax, 2020h 7403 00002A58 F3AB rep stosw 7404 7405 00002A5A 88D8 mov al, bl 7406 00002A5C 0431 add al, '1' 7407 00002A5E 884407 mov [si+p_pos], al ; partition number '1' to '4' 7408 7409 ; partition status, type and CHS parameters 7410 ; (as hexadecimal number) 7411 7412 ;mov al, [bp+ptbl.boot_ind] 7413 00002A61 8A4600 mov al, [bp] 7414 00002A64 E881F4 call byte_to_hex 7415 7416 00002A67 894409 mov [si+s_pos], ax 7417 00002A6A 887C0B mov [si+s_pos+2], bh ; 'h' 7418 7419 00002A6D 8A4601 mov al, [bp+ptbl.start_head] 7420 00002A70 E875F4 call byte_to_hex 7421 7422 00002A73 89440D mov [si+bh_pos], ax 7423 00002A76 887C0F mov [si+bh_pos+2], bh ; 'h' 7424 7425 00002A79 8B4E03 mov cx, [bp+ptbl.start_cyl] 7426 00002A7C C0E506 shl ch, 6 7427 00002A7F 8A4602 mov al, [bp+ptbl.start_sector] 7428 00002A82 08E8 or al, ch 7429 00002A84 E861F4 call byte_to_hex 7430 7431 00002A87 894411 mov [si+bs_pos], ax 7432 00002A8A 887C13 mov [si+bs_pos+2], bh ; 'h' 7433 7434 ;mov al, [bp+ptbl.start_cyl] 7435 00002A8D 88C8 mov al, cl 7436 00002A8F E856F4 call byte_to_hex 7437 7438 00002A92 894415 mov [si+bc_pos], ax 7439 00002A95 887C17 mov [si+bc_pos+2], bh ; 'h' 7440 7441 00002A98 8A4605 mov al, [bp+ptbl.sys_id] 7442 00002A9B E84AF4 call byte_to_hex 7443 7444 00002A9E 894419 mov [si+fs_pos], ax 7445 00002AA1 887C1B mov [si+fs_pos+2], bh ; 'h' 7446 7447 00002AA4 8A4606 mov al, [bp+ptbl.end_head] 7448 00002AA7 E83EF4 call byte_to_hex 7449 7450 00002AAA 89441D mov [si+eh_pos], ax 7451 00002AAD 887C1F mov [si+eh_pos+2], bh ; 'h' 7452 7453 00002AB0 8B4E08 mov cx, [bp+ptbl.end_cyl] 7454 00002AB3 C0E506 shl ch, 6 7455 00002AB6 8A4607 mov al, [bp+ptbl.end_sector] 7456 00002AB9 08E8 or al, ch 7457 00002ABB E82AF4 call byte_to_hex 7458 7459 00002ABE 894421 mov [si+es_pos], ax 7460 00002AC1 887C23 mov [si+es_pos+2], bh ; 'h' 7461 7462 ;mov al, [bp+ptbl.end_cyl] 7463 00002AC4 88C8 mov al, cl 7464 00002AC6 E81FF4 call byte_to_hex 7465 7466 00002AC9 894425 mov [si+ec_pos], ax 7467 00002ACC 887C27 mov [si+ec_pos+2], bh ; 'h' 7468 7469 ; relative (start) sector address (lba) 7470 ; (as decimal number) 7471 7472 00002ACF 8B460A mov ax, [bp+ptbl.rel_sec_lw] 7473 00002AD2 8B560C mov dx, [bp+ptbl.rel_sec_hw] 7474 7475 00002AD5 89E7 mov di, sp 7476 00002AD7 B90A00 mov cx, 10 7477 dpte_1: 7478 00002ADA E859E3 call div32 7479 7480 00002ADD 80C330 add bl, '0' 7481 00002AE0 53 push bx 7482 00002AE1 21C0 and ax, ax 7483 00002AE3 75F5 jnz short dpte_1 7484 00002AE5 21D2 and dx, dx 7485 00002AE7 75F1 jnz short dpte_1 7486 7487 00002AE9 8D5C31 lea bx, [si+rs_pos+7] 7488 7489 00002AEC 29E7 sub di, sp 7490 00002AEE D1EF shr di, 1 7491 00002AF0 29FB sub bx, di 7492 dpte_2: 7493 00002AF2 58 pop ax 7494 00002AF3 8807 mov [bx], al 7495 00002AF5 4F dec di 7496 00002AF6 7403 jz short dpte_3 7497 7498 00002AF8 43 inc bx 7499 00002AF9 EBF7 jmp short dpte_2 7500 7501 dpte_3: 7502 ; number of sectors) 7503 ; (as decimal number) 7504 7505 00002AFB 8B460E mov ax, [bp+ptbl.num_sec_lw] 7506 00002AFE 8B5610 mov dx, [bp+ptbl.num_sec_hw] 7507 7508 00002B01 89E7 mov di, sp 7509 ;mov cx, 10 7510 dpte_4: 7511 00002B03 E830E3 call div32 7512 7513 00002B06 80C330 add bl, '0' 7514 00002B09 53 push bx 7515 00002B0A 21C0 and ax, ax 7516 00002B0C 75F5 jnz short dpte_4 7517 00002B0E 21D2 and dx, dx 7518 00002B10 75F1 jnz short dpte_4 7519 7520 00002B12 8D5C3B lea bx, [si+ns_pos+7] 7521 7522 00002B15 29E7 sub di, sp 7523 00002B17 D1EF shr di, 1 7524 00002B19 29FB sub bx, di 7525 dpte_5: 7526 00002B1B 58 pop ax 7527 00002B1C 8807 mov [bx], al 7528 00002B1E 4F dec di 7529 00002B1F 7403 jz short dpte_6 7530 7531 00002B21 43 inc bx 7532 00002B22 EBF7 jmp short dpte_5 7533 dpte_6: 7534 ; set file system name 7535 7536 00002B24 8A4605 mov al, [bp+ptbl.sys_id] 7537 00002B27 BF[CA41] mov di, valid_partitions 7538 00002B2A B91300 mov cx, 19 7539 00002B2D F2AE repnz scasb 7540 00002B2F 7405 jz short dpte_7 7541 00002B31 B8[BC41] mov ax, FS_OTHERS 7542 00002B34 EB0C jmp short dpte_8 7543 dpte_7: 7544 00002B36 81EF[CB41] sub di, valid_partitions + 1 7545 00002B3A B80E00 mov ax, 14 7546 00002B3D F7E7 mul di 7547 00002B3F 05[B240] add ax, FileSys_Names 7548 dpte_8: 7549 00002B42 8D7C3D lea di, [si+fsx_pos] 7550 00002B45 89C6 mov si, ax 7551 00002B47 B107 mov cl, 7 7552 00002B49 F3A5 rep movsw 7553 7554 00002B4B BE[0A71] mov si, pte_row 7555 00002B4E E8F8F2 call print_msg 7556 dpte_9: 7557 00002B51 5D pop bp ; 23/02/2019 7558 7559 00002B52 C3 retn 7560 7561 ;----------------------------------------------------------------------------- 7562 ; 24/02/2019 7563 7564 partition_table_fix: 7565 ; DELETE or EXIT option for Invalid Partition Table Entry 7566 ; INPUT: 7567 ; DS:SI = PTE address in MBR buffer 7568 7569 00002B53 56 push si ; save PTE address 7570 7571 00002B54 89F0 mov ax, si 7572 00002B56 2D[FE58] sub ax, MasterBootBuff+446 7573 00002B59 C0E804 shr al, 4 ; / 16 7574 00002B5C 0431 add al, '1' 7575 00002B5E A2[AE60] mov [inv_pte_num], al 7576 7577 ; DS:SI = PTE address in MBR buffer 7578 00002B61 E8E6F7 call show_selected_partition 7579 7580 ;mov si, CRLF 7581 ;call print_msg 7582 7583 ; Warning message... 7584 7585 00002B64 BE[8A60] mov si, msg_inv_pte 7586 00002B67 E8DFF2 call print_msg 7587 7588 00002B6A 5F pop di ; restore PTE address 7589 ptf_0: 7590 00002B6B 30E4 xor ah, ah 7591 00002B6D CD16 int 16h 7592 7593 00002B6F 3C0D cmp al, 13 7594 00002B71 7406 je short ptf_1 7595 7596 00002B73 3C1B cmp al, 27 7597 00002B75 75F4 jne short ptf_0 7598 7599 00002B77 F9 stc 7600 00002B78 C3 retn 7601 ptf_1: 7602 ; Clear that (invalid) PTE 7603 00002B79 31C0 xor ax, ax 7604 00002B7B B90800 mov cx, 8 7605 00002B7E F3AB rep stosw 7606 7607 ; Clear screen 7608 00002B80 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 7609 00002B83 CD10 int 10h 7610 7611 00002B85 C3 retn 7612 7613 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7614 ; Display (& Edit) EXTENDED (DOS) Partition Table 7615 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7616 ; 28/02/2019 7617 7618 display_extended_pt: 7619 00002B86 B005 mov al, 5 ; extended partition (logical drives) 7620 00002B88 E816FE call display_partition_table 7621 7622 00002B8B BE[8262] mov si, ebr_editing_options 7623 00002B8E E8B8F2 call print_msg 7624 7625 00002B91 BE[915E] mov si, enter_opt_num_cancel_msg 7626 00002B94 E8B2F2 call print_msg 7627 7628 00002B97 BE[6756] mov si, CRLF 7629 00002B9A E8ACF2 call print_msg 7630 dept_1: 7631 00002B9D 30E4 xor ah, ah 7632 00002B9F CD16 int 16h 7633 7634 00002BA1 3C30 cmp al, '0' 7635 00002BA3 740C je short dept_2 7636 7637 00002BA5 3C31 cmp al, '1' 7638 00002BA7 7467 je short edit_ext_table_create 7639 00002BA9 3C32 cmp al, '2' 7640 00002BAB 7407 je short edit_ext_table_delete 7641 7642 00002BAD 3C1B cmp al, 27 ; ESCape 7643 00002BAF 75EC jne short dept_1 7644 dept_2: 7645 00002BB1 E963D8 jmp A_48 7646 7647 edit_ext_table_delete: 7648 ; 28/02/2019 7649 00002BB4 B005 mov al, 5 ; extended partition (logical drives) 7650 00002BB6 E8E8FD call display_partition_table 7651 7652 00002BB9 BE[0163] mov si, msg_delete_ldd_q 7653 00002BBC E88AF2 call print_msg 7654 7655 ;mov si, CRLF 7656 ;call print_msg 7657 eetd_1: 7658 00002BBF 30E4 xor ah, ah 7659 00002BC1 CD16 int 16h 7660 7661 00002BC3 3C1B cmp al, 27 7662 00002BC5 7410 je short eetd_2 7663 7664 00002BC7 24DF and al, 0DFh 7665 00002BC9 3C59 cmp al, 'Y' 7666 00002BCB 7412 je short eetd_yes 7667 00002BCD 3C4E cmp al, 'N' 7668 00002BCF 75EE jne short eetd_1 7669 eetd_no: 7670 00002BD1 BE[115E] mov si, msg_NO ; Write 'NO' (it may be shown for a moment) 7671 00002BD4 E872F2 call print_msg 7672 eetd_2: 7673 00002BD7 BE[6756] mov si, CRLF ; Next line 7674 00002BDA E86CF2 call print_msg 7675 00002BDD EBA7 jmp short display_extended_pt 7676 eetd_yes: 7677 00002BDF BE[0B5E] mov si, msg_YES ; Write 'YES' (it may be shown for a moment) 7678 00002BE2 E864F2 call print_msg 7679 00002BE5 BE[6756] mov si, CRLF ; Next line 7680 00002BE8 E85EF2 call print_msg 7681 00002BEB E8F205 call delete_logical_drives 7682 00002BEE 803E[E86E]00 cmp byte [ldrives], 0 7683 00002BF3 7791 ja short display_extended_pt 7684 00002BF5 E91FD8 jmp A_48 7685 7686 ;----------------------------------------------------------------------------- 7687 7688 eetc_2: 7689 00002BF8 BE[6763] mov si, msg_create_ldd_max_error 7690 eetc_10: 7691 00002BFB E84BF2 call print_msg 7692 00002BFE BE[2057] mov si, msg_press_any_key 7693 00002C01 E845F2 call print_msg 7694 00002C04 30E4 xor ah, ah 7695 00002C06 CD16 int 16h 7696 00002C08 E97BFF jmp display_extended_pt 7697 7698 ; 05/03/2019 7699 eetc_9: 7700 00002C0B BE[D065] mov si, msg_c_ldd_nofspc_error 7701 00002C0E EBEB jmp short eetc_10 7702 7703 ;----------------------------------------------------------------------------- 7704 ; 01/03/2019 7705 7706 edit_ext_table_create: 7707 7708 ; Create Method: ; 04/03/2019 7709 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 7710 ;LDD 2 <- LDD_START1, ebr 2nd entry <- EBR 1 7711 ;LDD 3 <- LDD_START2, ebr 2nd entry <- EBR 2 7712 ;LDD 4 <- LDD_START3, ebr 2nd entry <- EBR 3 7713 7714 ; 01/03/2019 7715 00002C10 803E[A971]00 cmp byte [epnumber], 0 ; check extended partition 7716 00002C15 0F86CFE3 jna B_55 ; cancel with error message 7717 7718 ; 05/03/2019 7719 00002C19 E8A102 call check_ext_free_space 7720 00002C1C 72ED jc eetc_9 ; error, no free space in extented partition 7721 7722 00002C1E 803E[E86E]04 cmp byte [ldrives], 4 7723 00002C23 73D3 jnb eetc_2 ; error, write program limit message 7724 7725 edit_ext_table_create_x: ; 02/03/2019 7726 7727 ; Get logical drive size/cylinders (request) from user 7728 00002C25 E80703 call get_ldd_size 7729 00002C28 833E[6A72]01 cmp word [lcylinders], 1 ; at least 1 cylinder 7730 00002C2D 0F8255FF jb display_extended_pt ; cancel 7731 7732 ; Open hard disk image file 7733 00002C31 BA[9959] mov dx, img_file_name 7734 00002C34 B8023D mov ax, 3D02h ; open for reading and writing 7735 00002C37 CD21 int 21h 7736 00002C39 0F82F6F1 jc D_02 7737 7738 00002C3D A3[A840] mov [img_file_handle], ax 7739 7740 ; 03/03/2019 7741 00002C40 A0[E86E] mov al, [ldrives] 7742 7743 ;cmp byte [ldrives], 1 7744 ;jnb short eetc_3 ; skip verify MBR extended partition 7745 7746 00002C43 20C0 and al, al 7747 00002C45 7578 jnz short eetc_3 7748 7749 00002C47 31ED xor bp, bp 7750 7751 ; Read MBR at EBR buffer 7752 ;xor ax, ax 7753 00002C49 31D2 xor dx, dx 7754 00002C4B BB[EE6E] mov bx, ebr_buffer 7755 00002C4E E846F2 call read_hd_sector 7756 00002C51 7218 jc short eetc_0 7757 7758 00002C53 A0[A971] mov al, [epnumber] 7759 00002C56 98 cbw 7760 00002C57 C0E004 shl al, 4 ; * 16 7761 00002C5A BE[AC70] mov si, ebr_buffer+446 7762 00002C5D 01C6 add si, ax 7763 00002C5F BF[FE58] mov di, MasterBootBuff+446 7764 00002C62 01C7 add di, ax 7765 00002C64 B90800 mov cx, 8 7766 00002C67 F3A7 repe cmpsw ; repeat comparising while cx > 0 and zf = 1 7767 00002C69 E30C jcxz eetc_1 ; Extended partition entry is not changed 7768 ; Different PTE (means there is a new extended partition) 7769 eetc_0: 7770 ; Write current MBR (with modified PT) 7771 00002C6B BB[4057] mov bx, MasterBootBuff 7772 00002C6E 31C0 xor ax, ax 7773 ; 25/10/2020 7774 ;xor dx, dx 7775 00002C70 E8E5F1 call write_hd_sector 7776 00002C73 0F82B2F1 jc D_01 ; ! display error msg and then exit ! 7777 eetc_1: 7778 ; clear EBR buffer 7779 00002C77 BF[EE6E] mov di, ebr_buffer 7780 00002C7A 31C0 xor ax, ax 7781 00002C7C B9FF00 mov cx, 255 7782 00002C7F F3AB rep stosw 7783 00002C81 C70555AA mov word [di], 0AA55h 7784 7785 ; Set logical dos drive parameters in it's EBR 7786 00002C85 BF[AC70] mov di, ebr_buffer+446 7787 7788 00002C88 8B0E[AA40] mov cx, [sectors] 7789 00002C8C 29DB sub bx, bx ; 0 7790 00002C8E A1[F070] mov ax, [ep_StartSector] 7791 00002C91 8B16[F270] mov dx, [ep_StartSector+2] 7792 7793 ; 03/03/2019 7794 ; set partition start address & size 7795 7796 00002C95 A3[4872] mov [ldd_start], ax 7797 00002C98 8916[4A72] mov [ldd_start+2], dx 7798 7799 ; 04/03/2019 7800 00002C9C 01C8 add ax, cx 7801 00002C9E 11DA adc dx, bx 7802 7803 00002CA0 52 push dx 7804 00002CA1 50 push ax 7805 7806 00002CA2 A0[AC40] mov al, [heads] 7807 00002CA5 F626[AA40] mul byte [sectors] 7808 00002CA9 F726[6A72] mul word [lcylinders] 7809 7810 00002CAD A3[5872] mov [ldd_size], ax 7811 00002CB0 8916[5A72] mov [ldd_size+2], dx 7812 7813 00002CB4 894D08 mov [di+ptStartSector], cx 7814 00002CB7 895D0A mov [di+ptStartSector+2], bx 7815 7816 00002CBA 58 pop ax 7817 00002CBB 5A pop dx 7818 7819 00002CBC E9DB00 jmp eetc_4 7820 7821 eetc_3: 7822 ; [ldrives] >= 1 7823 ; Read EBR 7824 ;mov al, [ldrives] 7825 ;;xor ah, ah 7826 00002CBF C0E002 shl al, 2 7827 00002CC2 89C5 mov bp, ax 7828 7829 ; 03/03/2019 7830 00002CC4 8B86[4472] mov ax, [bp+ldd_start-4] 7831 00002CC8 8B96[4672] mov dx, [bp+ldd_start-2] 7832 00002CCC BB[EE6E] mov bx, ebr_buffer 7833 00002CCF E8C5F1 call read_hd_sector 7834 00002CD2 0F8253F1 jc D_01 ; ! display error msg and then exit ! 7835 7836 ; 04/03/2019 7837 00002CD6 BE[BC70] mov si, ebr_buffer+446+16 ; 2nd entry (next EBR) 7838 7839 ; 03/03/2019 7840 00002CD9 8B86[4472] mov ax, [bp+ldd_start-4] 7841 00002CDD 8B96[4672] mov dx, [bp+ldd_start-2] 7842 00002CE1 0386[5472] add ax, [bp+ldd_size-4] 7843 00002CE5 1396[5672] adc dx, [bp+ldd_size-2] 7844 7845 00002CE9 8B0E[F070] mov cx, [ep_StartSector] 7846 00002CED 8B1E[F270] mov bx, [ep_StartSector+2] 7847 7848 00002CF1 8986[4872] mov [bp+ldd_start], ax 7849 00002CF5 8996[4A72] mov [bp+ldd_start+2], dx 7850 7851 00002CF9 52 push dx 7852 00002CFA 50 push ax 7853 7854 00002CFB 29C8 sub ax, cx 7855 00002CFD 19DA sbb dx, bx 7856 7857 00002CFF 894408 mov [si+ptStartSector], ax 7858 00002D02 89540A mov [si+ptStartSector+2], dx 7859 7860 00002D05 A0[AC40] mov al, [heads] 7861 00002D08 F626[AA40] mul byte [sectors] 7862 00002D0C F726[6A72] mul word [lcylinders] 7863 7864 00002D10 8986[5872] mov [bp+ldd_size], ax 7865 00002D14 8996[5A72] mov [bp+ldd_size+2], dx 7866 7867 00002D18 89440C mov [si+ptSectors], ax 7868 00002D1B 89540E mov [si+ptSectors+2], dx 7869 7870 00002D1E 58 pop ax 7871 00002D1F 5A pop dx 7872 7873 ; calculate CHS from LBA 7874 00002D20 E8DD01 call lba_to_chs 7875 ; ax = cylinder 7876 ; dl = sector 7877 ; dh = head 7878 7879 00002D23 C60400 mov byte [si+ptBootable], 0 7880 00002D26 887401 mov [si+ptBeginHead], dh 7881 00002D29 884403 mov [si+ptBeginCylinder], al 7882 00002D2C C0E406 shl ah, 6 7883 00002D2F 08E2 or dl, ah 7884 00002D31 885402 mov [si+ptBeginSector], dl 7885 7886 ;mov ax, [si+ptSectors] 7887 ;mov dx, [si+ptSectors+2] 7888 00002D34 8B86[5872] mov ax, [bp+ldd_size] 7889 00002D38 8B96[5A72] mov dx, [bp+ldd_size+2] 7890 00002D3C 83E801 sub ax, 1 7891 00002D3F 83DA00 sbb dx, 0 7892 00002D42 0386[4872] add ax, [bp+ldd_start] 7893 00002D46 1396[4A72] adc dx, [bp+ldd_start+2] 7894 ; dx:ax = end sector 7895 7896 00002D4A E8B301 call lba_to_chs 7897 ; ax = cylinder 7898 ; dl = sector 7899 ; dh = head 7900 7901 00002D4D C6440405 mov byte [si+ptFileSystemID], 5 ; EXTENDED 7902 00002D51 887405 mov [si+ptEndHead], dh 7903 00002D54 884407 mov [si+ptEndCylinder], al 7904 00002D57 C0E406 shl ah, 6 7905 00002D5A 08D4 or ah, dl 7906 00002D5C 886406 mov [si+ptEndSector], ah 7907 7908 ; Write EBR 7909 00002D5F 8B86[4472] mov ax, [bp+ldd_start-4] 7910 00002D63 8B96[4672] mov dx, [bp+ldd_start-2] 7911 00002D67 BB[EE6E] mov bx, ebr_buffer 7912 00002D6A E8EBF0 call write_hd_sector 7913 00002D6D 0F82B8F0 jc D_01 ; ! display error msg and then exit ! 7914 7915 ; clear EBR buffer 7916 00002D71 BF[EE6E] mov di, ebr_buffer 7917 00002D74 31C0 xor ax, ax 7918 00002D76 B9FF00 mov cx, 255 7919 00002D79 F3AB rep stosw 7920 00002D7B C70555AA mov word [di], 0AA55h 7921 7922 00002D7F BF[AC70] mov di, ebr_buffer+446 ; 1st entry points to LDD 7923 7924 00002D82 8B0E[AA40] mov cx, [sectors] 7925 00002D86 29DB sub bx, bx ; 0 7926 00002D88 8B86[4872] mov ax, [bp+ldd_start] 7927 00002D8C 8B96[4A72] mov dx, [bp+ldd_start+2] 7928 00002D90 01C8 add ax, cx 7929 00002D92 11DA adc dx, bx 7930 00002D94 894D08 mov [di+ptStartSector], cx 7931 00002D97 895D0A mov [di+ptStartSector+2], bx 7932 eetc_4: 7933 ; calculate CHS from LBA 7934 7935 00002D9A E86301 call lba_to_chs 7936 ; ax = cylinder 7937 ; dl = sector 7938 ; dh = head 7939 7940 ;mov byte [di+ptBootable], 0 7941 00002D9D 887501 mov [di+ptBeginHead], dh 7942 00002DA0 884503 mov [di+ptBeginCylinder], al 7943 00002DA3 88E3 mov bl, ah 7944 00002DA5 C0E306 shl bl, 6 7945 00002DA8 08DA or dl, bl 7946 00002DAA 885502 mov [di+ptBeginSector], dl 7947 7948 00002DAD 0306[6A72] add ax, [lcylinders] 7949 00002DB1 48 dec ax ; end cylinder 7950 00002DB2 89C3 mov bx, ax 7951 7952 ;mov [di+ptFileSystemID], 0 7953 00002DB4 8B0E[AC40] mov cx, [heads] 7954 00002DB8 FEC9 dec cl 7955 00002DBA 884D05 mov [di+ptEndHead], cl 7956 00002DBD 884507 mov [di+ptEndCylinder], al 7957 00002DC0 8B16[AA40] mov dx, [sectors] 7958 00002DC4 C0E406 shl ah, 6 7959 00002DC7 08D4 or ah, dl 7960 00002DC9 886506 mov [di+ptEndSector], ah 7961 7962 ; 02/03/2019 7963 ; Check unused space if it is 3rd LDD 7964 ; (write message to add unused space.) 7965 7966 00002DCC 803E[E86E]03 cmp byte [ldrives], 3 7967 00002DD1 727D jb eetc_7 7968 7969 00002DD3 89D0 mov ax, dx ; sectors 7970 00002DD5 F7E1 mul cx ; * [heads] - 1 7971 7972 00002DD7 52 push dx 7973 00002DD8 50 push ax 7974 7975 00002DD9 A0[AA40] mov al, [sectors] 7976 00002DDC F626[AC40] mul byte [heads] 7977 00002DE0 F7E3 mul bx ; * end cylinder 7978 7979 00002DE2 59 pop cx 7980 00002DE3 01C8 add ax, cx 7981 00002DE5 59 pop cx 7982 00002DE6 11CA adc dx, cx 7983 7984 ; 03/03/2019 7985 00002DE8 8B0E[AA40] mov cx, [sectors] 7986 00002DEC FEC9 dec cl ; [sectors] - 1 7987 00002DEE 01C8 add ax, cx 7988 00002DF0 83D200 adc dx, 0 7989 ; DX:AX = end LBA 7990 7991 00002DF3 8B0E[F470] mov cx, [ep_EndSector] 7992 00002DF7 8B1E[F670] mov bx, [ep_EndSector+2] 7993 7994 00002DFB 39DA cmp dx, bx 7995 00002DFD 7504 jne short eetc_5 7996 00002DFF 39C8 cmp ax, cx 7997 00002E01 744D je short eetc_7 ; 05/03/2019 7998 eetc_5: 7999 00002E03 53 push bx 8000 00002E04 BE[9C63] mov si, msg_c_ldd_unused_warning 8001 00002E07 E83FF0 call print_msg 8002 00002E0A 5B pop bx 8003 eetc_6: 8004 00002E0B 28E4 sub ah, ah 8005 00002E0D CD16 int 16h 8006 00002E0F 3C0D cmp al, 13 ; ENTER 8007 00002E11 743D je short eetc_7 ; continue 8008 00002E13 3C1B cmp al, 27 ; ESC 8009 00002E15 75F4 jne short eetc_6 8010 8011 ; 03/03/2019 8012 ; change end cylinder value 8013 00002E17 A0[A971] mov al, [epnumber] 8014 00002E1A FEC8 dec al 8015 00002E1C B412 mov ah, 18 ; primary partition table structure size 8016 00002E1E F6E4 mul ah 8017 00002E20 89C6 mov si, ax 8018 00002E22 8B84[6671] mov ax, [si+part_table_end_cyl] 8019 00002E26 884507 mov [di+ptEndCylinder], al 8020 00002E29 8A84[6571] mov al, [si+part_table_end_sector] 8021 00002E2D C0E406 shl ah, 6 8022 00002E30 08C4 or ah, al 8023 00002E32 886506 mov [di+ptEndSector], ah 8024 00002E35 8A84[6471] mov al, [si+part_table_end_head] 8025 00002E39 884505 mov [di+ptEndHead], al 8026 8027 00002E3C 89C8 mov ax, cx 8028 00002E3E 89DA mov dx, bx 8029 00002E40 83C001 add ax, 1 8030 00002E43 83D200 adc dx, 0 8031 ; dx:ax = end of ext partition + 1 8032 00002E46 2B86[4872] sub ax, [bp+ldd_start] 8033 00002E4A 1B96[4A72] sbb dx, [bp+ldd_start+2] 8034 ; dx:ax = new sector count of the ldd 8035 ;mov [bp+ldd_size], ax 8036 ;mov [bp+ldd_size+2], dx 8037 00002E4E EB08 jmp short eetc_8 8038 eetc_7: 8039 00002E50 8B86[5872] mov ax, [bp+ldd_size] 8040 00002E54 8B96[5A72] mov dx, [bp+ldd_size+2] 8041 ; dx:ax = sector count 8042 eetc_8: 8043 00002E58 2B06[AA40] sub ax, [sectors] 8044 00002E5C 83DA00 sbb dx, 0 8045 00002E5F 89450C mov [di+ptSectors], ax 8046 00002E62 89550E mov [di+ptSectors+2], dx 8047 8048 ; Get proper FAT type in [ldd_type] 8049 ; by using DX:AX - size - 8050 00002E65 E8AD00 call size_to_fat_type 8051 8052 00002E68 884504 mov [di+ptFileSystemID], al 8053 8054 ; Write current EBR (with modified PT) 8055 00002E6B 8B86[4872] mov ax, [bp+ldd_start] 8056 00002E6F 8B96[4A72] mov dx, [bp+ldd_start+2] 8057 00002E73 BB[EE6E] mov bx, ebr_buffer 8058 00002E76 E8DFEF call write_hd_sector 8059 00002E79 0F82ACEF jc D_01 ; ! display error msg and then exit ! 8060 8061 00002E7D A0[E86E] mov al, [ldrives] 8062 00002E80 B412 mov ah, 18 ; extended partition table structure size 8063 00002E82 F6E4 mul ah 8064 8065 00002E84 89C6 mov si, ax 8066 00002E86 81C6[AA71] add si, ext_table_boot_ind 8067 00002E8A 87F7 xchg si, di 8068 8069 ; set partition (logical -dos- drive) data 8070 00002E8C A5 movsw ; boot indicator, beginning head 8071 00002E8D AC lodsb 8072 00002E8E 88C4 mov ah, al 8073 00002E90 243F and al, 3Fh 8074 00002E92 AA stosb ; beginning sector 8075 00002E93 C0EC06 shr ah, 6 8076 00002E96 AC lodsb ; beginning cylinder 8077 00002E97 AB stosw 8078 00002E98 A5 movsw ; partition id, end head 8079 00002E99 AC lodsb 8080 00002E9A 88C4 mov ah, al 8081 00002E9C 243F and al, 3Fh 8082 00002E9E AA stosb ; end sector 8083 00002E9F C0EC06 shr ah, 6 8084 00002EA2 AC lodsb ; end cylinder 8085 00002EA3 AB stosw 8086 8087 00002EA4 A5 movsw ; copy start sector (LBA) and sector count 8088 00002EA5 A5 movsw 8089 00002EA6 A5 movsw 8090 00002EA7 A5 movsw 8091 8092 00002EA8 FE06[E86E] inc byte [ldrives] 8093 8094 ; Close hard disk image file 8095 8096 00002EAC B43E mov ah, 3Eh ; close file 8097 00002EAE 8B1E[A840] mov bx, [img_file_handle] 8098 00002EB2 CD21 int 21h 8099 8100 00002EB4 C706[A840]0000 mov word [img_file_handle], 0 8101 8102 00002EBA E9C9FC jmp display_extended_pt 8103 8104 ;----------------------------------------------------------------------------- 8105 ; 05/03/2019 8106 8107 check_ext_free_space: 8108 00002EBD A1[F870] mov ax, [ep_Size] 8109 00002EC0 8B16[FA70] mov dx, [ep_Size+2] 8110 8111 00002EC4 8A1E[E86E] mov bl, [ldrives] 8112 00002EC8 20DB and bl, bl 8113 00002ECA 7433 jz short cefs_1 8114 00002ECC 80FB04 cmp bl, 4 8115 00002ECF 7602 jna short cefs_0 8116 00002ED1 B304 mov bl, 4 8117 cefs_0: 8118 00002ED3 FECB dec bl 8119 00002ED5 C0E302 shl bl, 2 ; *4 8120 00002ED8 30FF xor bh, bh 8121 00002EDA 89DE mov si, bx 8122 8123 00002EDC 8B8C[4872] mov cx, [si+ldd_start] 8124 00002EE0 8B9C[4A72] mov bx, [si+ldd_start+2] 8125 00002EE4 038C[5872] add cx, [si+ldd_size] 8126 00002EE8 139C[5A72] adc bx, [si+ldd_size+2] 8127 8128 00002EEC 0306[F070] add ax, [ep_StartSector] 8129 00002EF0 1316[F270] adc dx, [ep_StartSector+2] 8130 8131 00002EF4 29C8 sub ax, cx 8132 00002EF6 19DA sbb dx, bx 8133 00002EF8 7505 jnz short cefs_1 8134 8135 00002EFA 09C0 or ax, ax 8136 00002EFC 7501 jnz short cefs_1 8137 8138 ; cf = 0 if the result not negative 8139 8140 00002EFE F9 stc 8141 8142 ; cf = 1 if the result is negative or zero 8143 8144 ; If cf = 0 -> There is free space as in DX:AX 8145 ; NOTE: This calculation is unsafe if 8146 ; logical dos drive count > 4 ! 8147 ; (But still meaningful for creating a new ldd. 8148 ; Because a new ldd will be created only 8149 ; if ldd count < 4.) 8150 cefs_1: 8151 00002EFF C3 retn 8152 8153 ;----------------------------------------------------------------------------- 8154 ; 01/03/2019 8155 8156 lba_to_chs: 8157 ; INPUT: 8158 ; DX:AX = LBA address 8159 ; OUTPUT: 8160 ; AX = cylinder 8161 ; DL = sector 8162 ; DH = head 8163 ; 8164 ; (modified registers: ax, bx, cx, dx) 8165 8166 00002F00 8B0E[AA40] mov cx, [sectors] 8167 00002F04 E82FDF call div32 8168 00002F07 FEC3 inc bl 8169 00002F09 53 push bx ; BL = sector 8170 00002F0A 8B0E[AC40] mov cx, [heads] 8171 00002F0E E825DF call div32 8172 00002F11 5A pop dx ; DL = sector 8173 00002F12 88DE mov dh, bl ; BL = head 8174 00002F14 C3 retn 8175 8176 ;----------------------------------------------------------------------------- 8177 ; 02/03/2019 8178 8179 size_to_fat_type: 8180 ; INPUT: 8181 ; DX:AX = DOS Partitition Size in sectors 8182 ; OUTPUT: 8183 ; AL = Partition type/ID (FAT type) 8184 8185 00002F15 09D2 or dx, dx 8186 00002F17 750B jnz short stft_2 8187 8188 00002F19 3DA87F cmp ax, 32680 8189 00002F1C 7703 ja short stft_1 8190 8191 00002F1E B001 mov al, 1 ; FAT12 file system 8192 00002F20 C3 retn 8193 stft_1: 8194 00002F21 B004 mov al, 4 ; FAT16 (< 32MB) 8195 00002F23 C3 retn 8196 stft_2: 8197 00002F24 83FA10 cmp dx, 10h 8198 00002F27 7303 jnb short stft_3 ; FAT32 (CHS) file system 8199 8200 00002F29 B006 mov al, 6 ; FAT16 (>= 32MB) 8201 00002F2B C3 retn 8202 stft_3: 8203 00002F2C B00B mov al, 0Bh ; FAT32 (CHS) 8204 00002F2E C3 retn 8205 8206 ;----------------------------------------------------------------------------- 8207 ; 02/03/2019 8208 8209 get_ldd_size: ; Get requested logical dos drive size (from user) 8210 ; INPUT -> none 8211 ; 8212 ; OUTPUT -> 8213 ; [lcylinders] = cylinder count 8214 ; 8215 ; (Modified registers: ax, bx, cx, dx, si, di) 8216 8217 00002F2F B80300 mov ax, 3 ; clear screen 8218 00002F32 CD10 int 10h 8219 8220 00002F34 BE[0C49] mov si, msg_create_dos_partition_h 8221 00002F37 E80FEF call print_msg 8222 8223 ; 03/03/2019 8224 00002F3A A0[E86E] mov al, [ldrives] 8225 00002F3D 08C0 or al, al ; cmp byte [ldrives], 0 8226 00002F3F 740D jz short gldds_1 ; jna short gldds_0 8227 8228 ;push ax ; * 8229 8230 ;dec al 8231 ;mov ah, 18 8232 ;mul ah 8233 8234 ;mov di, ext_table_rel_sec_lw 8235 ;add di, ax 8236 8237 00002F41 BE[204F] mov si, msg_use_all_space 8238 00002F44 E802EF call print_msg 8239 8240 ; Calculate available space 8241 8242 ;mov ax, [ep_Size] ; ext part size in sectors 8243 ;mov dx, [ep_Size+2] 8244 8245 ; 04/03/2019 8246 ;gldds_0: 8247 ;mov cx, [di] ; start sector 8248 ;mov bx, [di+2] 8249 ;add cx, [di+4] ; sectors 8250 ;adc bx, [di+6] 8251 ; ; bx:cx = start of next ldd 8252 ;sub ax, cx 8253 ;sbb dx, bx 8254 ; ; dx:ax = free space in sectors 8255 ; 8256 ;pop cx ; * 8257 ;dec cl 8258 ;jz short gldds_2 8259 ;sub di, 18 8260 ;push cx ; * 8261 ;jmp short gldds_0 8262 8263 ; 05/03/2019 8264 00002F47 E873FF call check_ext_free_space 8265 00002F4A 7243 jc short gldds_cancel 8266 ; DX:AX = free sectors in extended partition 8267 00002F4C EB0D jmp short gldds_2 8268 gldds_1: 8269 00002F4E BE[534F] mov si, msg_use_entire_ep_space 8270 00002F51 E8F5EE call print_msg 8271 8272 ; Calculate free space in extended partition 8273 00002F54 A1[F870] mov ax, [ep_Size] 8274 00002F57 8B16[FA70] mov dx, [ep_Size+2] 8275 gldds_2: 8276 ; subtrack start offset (which always equals to spt value) 8277 00002F5B 2B06[AA40] sub ax, [sectors] 8278 00002F5F 83DA00 sbb dx, 0 8279 8280 00002F62 89C1 mov cx, ax 8281 00002F64 A0[AC40] mov al, [heads] 8282 00002F67 F626[AA40] mul byte [sectors] 8283 00002F6B 91 xchg ax, cx 8284 ; dx:ax = sectors 8285 ; cx = heads*spt 8286 00002F6C E8C7DE call div32 8287 ; ax = cylinders 8288 ; bx = remainder 8289 ; dx = 0 8290 00002F6F 21DB and bx, bx 8291 00002F71 7401 jz short gldds_3 8292 00002F73 40 inc ax 8293 gldds_3: 8294 00002F74 A3[6A72] mov [lcylinders], ax 8295 gldds_getchar: 8296 00002F77 30E4 xor ah, ah 8297 00002F79 CD16 int 16h 8298 8299 00002F7B 3C1B cmp al, 27 ; ESCAPE key 8300 00002F7D 7410 je short gldds_cancel 8301 00002F7F 24DF and al, 0DFh 8302 00002F81 3C4E cmp al, 'N' 8303 00002F83 7411 je short gldds_4 8304 00002F85 3C59 cmp al, 'Y' 8305 00002F87 75EE jne short gldds_getchar 8306 00002F89 BE[0A5E] mov si, _msg_YES 8307 ;call print_msg 8308 ;retn 8309 00002F8C E9BAEE jmp print_msg 8310 8311 gldds_cancel: 8312 00002F8F C706[6A72]0000 mov word [lcylinders], 0 8313 gldds_28: 8314 00002F95 C3 retn 8315 gldds_4: 8316 00002F96 BE[105E] mov si, _msg_NO 8317 00002F99 E8ADEE call print_msg 8318 gldds_26: 8319 00002F9C B80300 mov ax, 3 ; clear screen 8320 00002F9F CD10 int 10h 8321 8322 00002FA1 BE[0C49] mov si, msg_create_dos_partition_h 8323 00002FA4 E8A2EE call print_msg 8324 8325 00002FA7 BE[2264] mov si, msg_create_ldd_s 8326 00002FAA E89CEE call print_msg 8327 00002FAD BE[DE4E] mov si, msg_press_esc_to_cancel 8328 00002FB0 E896EE call print_msg 8329 gldds_25: 8330 00002FB3 30E4 xor ah, ah 8331 00002FB5 CD16 int 16h 8332 8333 00002FB7 3C1B cmp al, 27 ; ESCAPE key 8334 00002FB9 7502 jne short gldds_5 8335 8336 00002FBB EBD2 jmp short gldds_cancel 8337 gldds_5: 8338 ; 04/03/2019 8339 00002FBD 3C20 cmp al, 32 ; SPACE key 8340 00002FBF 74D4 je short gldds_28 8341 8342 00002FC1 C606[C26E]25 mov byte [pSize_unit], '%' 8343 00002FC6 3C25 cmp al, '%' 8344 00002FC8 741A je short gldds_6 8345 00002FCA C606[C26E]4D mov byte [pSize_unit], 'M' 8346 00002FCF 3C0D cmp al, 13 ; 0Dh, Carriage Return key 8347 00002FD1 7411 je short gldds_6 8348 00002FD3 24DF and al, 0DFh 8349 00002FD5 3C4D cmp al, 'M' 8350 00002FD7 740B je short gldds_6 8351 00002FD9 A2[C26E] mov [pSize_unit], al 8352 00002FDC 3C47 cmp al, 'G' 8353 00002FDE 7404 je short gldds_6 8354 00002FE0 3C43 cmp al, 'C' 8355 00002FE2 75CF jne short gldds_25 8356 gldds_6: 8357 ; Set maximum sector count (all of extended partition) 8358 00002FE4 A0[AA40] mov al, [sectors] 8359 00002FE7 F626[AC40] mul byte [heads] 8360 00002FEB F726[6A72] mul word [lcylinders] 8361 00002FEF A3[B06E] mov [pp_Sectors], ax 8362 00002FF2 8916[B26E] mov [pp_Sectors+2], dx 8363 8364 00002FF6 E897F0 call partition_size_input 8365 00002FF9 7294 jc short gldds_cancel 8366 ; DX:AX = Partition size in sectors 8367 ;or bx, bx 8368 ;jnz short gldds_cancel 8369 00002FFB 89C1 mov cx, ax 8370 00002FFD A0[AC40] mov al, [heads] 8371 00003000 F626[AA40] mul byte [sectors] 8372 00003004 91 xchg ax, cx 8373 ; dx:ax = sectors 8374 ; cx = heads*spt 8375 00003005 E82EDE call div32 8376 ; ax = cylinders 8377 ; bx = remainder 8378 ; dx = 0 8379 00003008 21DB and bx, bx 8380 0000300A 7401 jz short gldds_7 8381 0000300C 40 inc ax 8382 gldds_7: 8383 0000300D 3B06[6A72] cmp ax, [lcylinders] 8384 00003011 7704 ja short gldds_9 8385 gldds_8: 8386 ; OK 8387 00003013 A3[6A72] mov [lcylinders], ax 8388 00003016 C3 retn 8389 8390 gldds_9: 8391 ; Partition size limit message 8392 8393 00003017 803E[C26E]43 cmp byte [pSize_unit], 'C' 8394 0000301C 7407 je short gldds_10 8395 8396 ; Tolerate 1 cylinder if unit is not cylinder 8397 0000301E 48 dec ax 8398 0000301F 3B06[6A72] cmp ax, [lcylinders] 8399 00003023 76EE jna short gldds_8 8400 gldds_10: 8401 ; clear screen 8402 00003025 B80300 mov ax, 3 ; set video mode to 03h (80x25 text) 8403 00003028 CD10 int 10h 8404 8405 0000302A BE[0C49] mov si, msg_create_dos_partition_h ; header 8406 0000302D E819EE call print_msg 8407 8408 00003030 BE[CF5F] mov si, msg_partition_size_limit 8409 00003033 E813EE call print_msg 8410 8411 00003036 803E[C26E]4D cmp byte [pSize_unit], 'M' 8412 0000303B 7413 je short gldds_11 8413 8414 0000303D 803E[C26E]25 cmp byte [pSize_unit], '%' 8415 00003042 745A je short gldds_22 8416 8417 00003044 803E[C26E]43 cmp byte [pSize_unit], 'C' 8418 00003049 7505 jne short gldds_11 8419 8420 0000304B A1[6A72] mov ax, [lcylinders] 8421 0000304E EB0F jmp short gldds_12 8422 gldds_11: 8423 ; 'M' 8424 00003050 A1[B06E] mov ax, [pp_Sectors] 8425 00003053 8B16[B26E] mov dx, [pp_Sectors+2] 8426 00003057 B90008 mov cx, 2*1024 ; sectors -> MB 8427 0000305A E8D9DD call div32 8428 ; DX = 0 8429 ; AX = Available space in Megabytes 8430 0000305D 89C7 mov di, ax 8431 gldds_12: 8432 0000305F B90A00 mov cx, 10 8433 00003062 89E5 mov bp, sp 8434 gldds_13: 8435 00003064 31D2 xor dx, dx 8436 00003066 B90A00 mov cx, 10 8437 00003069 F7F1 div cx 8438 0000306B 52 push dx 8439 0000306C 83F809 cmp ax, 9 8440 0000306F 77F3 ja short gldds_13 8441 gldds_14: 8442 00003071 BB0700 mov bx, 07h 8443 00003074 09C0 or ax, ax 8444 00003076 7501 jnz short gldds_16 8445 gldds_15: 8446 00003078 58 pop ax 8447 gldds_16: 8448 00003079 0430 add al, '0' 8449 gldds_17: 8450 0000307B B40E mov ah, 0Eh 8451 ;mov bx, 07h 8452 0000307D CD10 int 10h ; write character (as tty) 8453 8454 0000307F 39EC cmp sp, bp 8455 00003081 72F5 jb short gldds_15 8456 8457 00003083 803E[C26E]25 cmp byte [pSize_unit], '%' 8458 00003088 7508 jne short gldds_18 8459 8460 0000308A 3C25 cmp al, '%' 8461 0000308C 743C je short gldds_21 8462 0000308E B025 mov al, '%' 8463 00003090 EBE9 jmp short gldds_17 8464 gldds_18: 8465 00003092 803E[C26E]43 cmp byte [pSize_unit], 'C' 8466 00003097 751C jne short gldds_19 8467 8468 00003099 BE[6B60] mov si, msg_cylinders 8469 0000309C EB29 jmp short gldds_20 8470 8471 gldds_22: 8472 ; '%' 8473 0000309E 81C3[F871] add bx, free_space.percent_unused 8474 000030A2 8B07 mov ax, [bx] 8475 gldds_23: 8476 000030A4 89E5 mov bp, sp 8477 gldds_24: 8478 000030A6 31D2 xor dx, dx 8479 000030A8 B90A00 mov cx, 10 8480 000030AB F7F1 div cx 8481 000030AD 52 push dx 8482 000030AE 83F809 cmp ax, 9 8483 000030B1 77F3 ja short gldds_24 8484 000030B3 EBBC jmp short gldds_14 8485 8486 gldds_19: 8487 000030B5 BE[7F60] mov si, msg_megabytes 8488 000030B8 C606[8860]73 mov byte [msg_megabytes_s], 's' 8489 000030BD 83FF01 cmp di, 1 8490 000030C0 7705 ja short gldds_20 8491 000030C2 C606[8860]00 mov byte [msg_megabytes_s], 0 8492 gldds_20: 8493 000030C7 E87FED call print_msg 8494 gldds_21: 8495 000030CA BE[1C60] mov si, msg_partition_size_limit_r 8496 000030CD E879ED call print_msg 8497 gldds_27: 8498 000030D0 30E4 xor ah, ah 8499 000030D2 CD16 int 16h 8500 8501 000030D4 3C1B cmp al, 27 ; ESCAPE key 8502 000030D6 0F84C2FE je gldds_26 8503 000030DA 3C0D cmp al, 13 ; ENTER (Carriage Return) key 8504 000030DC 75F2 jne short gldds_27 8505 8506 ;mov ax, [lcylinders] 8507 000030DE C3 retn 8508 8509 ;----------------------------------------------------------------------------- 8510 ; 26/02/2019 8511 8512 init_ext_partition_tables: 8513 8514 ; INPUT -> 8515 ; [epnumber] = extended partition number 8516 ; 8517 ; OUTPUT -> none 8518 8519 ; Display Method: ; 04/03/2019 8520 ;LDD 1 <- LDD_START0, ebr 1st entry <- MBR (extended partition) - EBR 0 8521 ;LDD 2 <- LDD_START1, ebr 1st entry <- EBR 1 8522 ;LDD 3 <- LDD_START2, ebr 1st entry <- EBR 2 8523 ;LDD 4 <- LDD_START3, ebr 1st entry <- EBR 3 8524 ;LDD 5 <- LDD_START3, ebr 2nd entry (LDD 5 is not diplayed) 8525 8526 ; 08/03/2019 8527 8528 ; clear extended partition tables structure/list 8529 8530 000030DF BF[AA71] mov di, ext_table_boot_ind 8531 000030E2 89FE mov si, di ; 28/02/2019 8532 000030E4 B92400 mov cx, 36 ; 18*4 = 72 bytes 8533 000030E7 31C0 xor ax, ax ; 0 8534 000030E9 F3AB rep stosw 8535 000030EB 89F7 mov di, si ; 28/02/2019 8536 8537 ;mov byte [ldrives], 0 8538 000030ED A2[E86E] mov [ldrives], al ; 0 8539 8540 ;cmp byte [epnumber], 1 8541 ;jb short iept_0 8542 8543 000030F0 A0[A971] mov al, [epnumber] 8544 000030F3 FEC8 dec al 8545 000030F5 B412 mov ah, 18 ; partition table structure size 8546 000030F7 F6E4 mul ah 8547 000030F9 BE[6871] mov si, part_table_rel_sec_lw 8548 000030FC 01C6 add si, ax 8549 000030FE 8B04 mov ax, [si] 8550 00003100 8B5402 mov dx, [si+2] 8551 00003103 A3[F070] mov [ep_StartSector], ax 8552 00003106 8916[F270] mov [ep_StartSector+2], dx 8553 0000310A 8B4C04 mov cx, [si+4] 8554 0000310D 8B5C06 mov bx, [si+6] 8555 00003110 890E[F870] mov [ep_Size], cx 8556 00003114 891E[FA70] mov [ep_Size+2], bx 8557 00003118 83E901 sub cx, 1 8558 0000311B 83DB00 sbb bx, 0 8559 0000311E 01C1 add cx, ax 8560 00003120 11D3 adc bx, dx 8561 00003122 890E[F470] mov [ep_EndSector], cx 8562 00003126 891E[F670] mov [ep_EndSector+2], bx 8563 8564 ; 27/02/2019 8565 0000312A A3[4872] mov [ldd_start], ax 8566 0000312D 8916[4A72] mov [ldd_start+2], dx 8567 8568 ; 03/03/2019 8569 ;mov word [ldd_size], 0 8570 ;mov word [ldd_size+2], 0 8571 8572 00003131 BB[EE6E] mov bx, ebr_buffer 8573 ; dx:ax = Extended partition address 8574 ; es:bx = Extended partition buffer 8575 00003134 E860ED call read_hd_sector 8576 00003137 7209 jc short iept_0 8577 8578 ; Check EBR if it is a valid boot record or not 8579 00003139 813E[EC70]55AA cmp word [ebr_buffer+510], 0AA55h 8580 0000313F 7402 je short iept_1 8581 iept_stc_retn: 8582 00003141 F9 stc 8583 iept_0: 8584 00003142 C3 retn 8585 iept_1: 8586 ; Check PTE 1, if it is valid or not 8587 00003143 A0[B070] mov al, [ebr_buffer+446+ptFileSystemID] 8588 00003146 20C0 and al, al 8589 00003148 74F7 jz short iept_stc_retn ; empty pte, error 8590 0000314A 3C05 cmp al, 5 8591 0000314C 74F3 je short iept_stc_retn ; extended partition, error 8592 8593 ;inc byte [ldrives] ; logical (dos) drive count 8594 8595 0000314E BE[AC70] mov si, ebr_buffer+446 ; Partition table offset 8596 00003151 B90400 mov cx, 4 8597 8598 ; set partition (logical -dos- drive) data 8599 00003154 A5 movsw ; boot indicator, beginning head 8600 00003155 AC lodsb 8601 00003156 88C4 mov ah, al 8602 00003158 243F and al, 3Fh 8603 0000315A AA stosb ; beginning sector 8604 0000315B C0EC06 shr ah, 6 8605 0000315E AC lodsb ; beginning cylinder 8606 0000315F AB stosw 8607 00003160 A5 movsw ; partition id, end head 8608 00003161 AC lodsb 8609 00003162 88C4 mov ah, al 8610 00003164 243F and al, 3Fh 8611 00003166 AA stosb ; end sector 8612 00003167 C0EC06 shr ah, 6 8613 0000316A AC lodsb ; end cylinder 8614 0000316B AB stosw 8615 8616 ; 04/03/2019 8617 0000316C 8A1E[E86E] mov bl, [ldrives] 8618 ;dec bl 8619 ;jnz short iept_2 8620 8621 ; 05/03/2019 8622 00003170 08DB or bl, bl 8623 00003172 7518 jnz short iept_2 8624 8625 00003174 8B04 mov ax, [si] ; start sector of 1st LDD (offset) 8626 00003176 8B5402 mov dx, [si+2] 8627 00003179 034404 add ax, [si+4] ; size of 1st LDD (volume) 8628 0000317C 135406 adc dx, [si+6] 8629 8630 0000317F A3[5872] mov [ldd_size], ax ; size of 1st LDD (partition) 8631 00003182 8916[5A72] mov [ldd_size+2], dx 8632 ; 05/03/2019 8633 00003186 FE06[E86E] inc byte [ldrives] ; logical (dos) drive count 8634 0000318A FEC3 inc bl 8635 iept_2: 8636 0000318C F3A5 rep movsw ; copy start sector (LBA) and sector count 8637 8638 ; get next extended partition (logical -dos- drive) data 8639 0000318E 8A4404 mov al, [si+ptFileSystemID] 8640 00003191 20C0 and al, al ; EMPTY 8641 00003193 74AD jz short iept_0 ; end of logical -dos- drive chain 8642 8643 00003195 3C05 cmp al, 5 ; EXTENDED 8644 00003197 75A8 jne short iept_stc_retn ; 2nd PTE must have 8645 ; extended partition ID 8646 8647 ; 05/03/2019 8648 00003199 FE06[E86E] inc byte [ldrives] ; logical (dos) drive count 8649 8650 ;cmp byte [ldrives], al ; 5 8651 0000319D 80FB04 cmp bl, 4 ; number of logical dos drives (till here) 8652 000031A0 733D jnb short iept_3 8653 8654 000031A2 83C608 add si, 8 8655 8656 000031A5 AD lodsw 8657 000031A6 89C2 mov dx, ax ; start sector 8658 000031A8 AD lodsw 8659 000031A9 92 xchg dx, ax ; start sector + 2 8660 8661 ; 04/03/2019 8662 000031AA 0306[F070] add ax, [ep_StartSector] 8663 000031AE 1316[F270] adc dx, [ep_StartSector+2] 8664 8665 000031B2 30FF xor bh, bh 8666 000031B4 C0E302 shl bl, 2 ; *4 8667 8668 ; 28/02/2019 8669 000031B7 8987[4872] mov [bx+ldd_start], ax ; start of (next) LDD (partition) 8670 000031BB 8997[4A72] mov [bx+ldd_start+2], dx 8671 8672 ; 03/03/2019 8673 ; set partition size for logical dos drive 8674 000031BF 8B0C mov cx, [si] 8675 000031C1 898F[5872] mov [bx+ldd_size], cx 8676 000031C5 8B4C02 mov cx, [si+2] 8677 000031C8 898F[5A72] mov [bx+ldd_size+2], cx 8678 8679 000031CC BB[EE6E] mov bx, ebr_buffer 8680 ; dx:ax = Extended partition address 8681 ; es:bx = Extended partition buffer 8682 000031CF E8C5EC call read_hd_sector 8683 000031D2 720B jc short iept_3 ; 03/03/2019 8684 8685 ; Check EBR if it is valid or not 8686 000031D4 813E[EC70]55AA cmp word [ebr_buffer+510], 0AA55h 8687 000031DA 0F8465FF je iept_1 8688 8689 000031DE F9 stc 8690 iept_3: 8691 000031DF C3 retn 8692 8693 ;----------------------------------------------------------------------------- 8694 ; 27/02/2019 8695 8696 delete_logical_drives: 8697 8698 ; Delete Method: ; 04/03/2019 8699 ;LDD 5 <- LDD_START3, ebr 2nd entry 8700 ;LDD 4 <- LDD_START2, ebr 2nd entry 8701 ;LDD 3 <- LDD_START1, ebr 2nd entry 8702 ;LDD 2 <- LDD_START0, ebr 2nd entry 8703 ;LDD 1 <- LDD_START0, ebr 1st entry 8704 8705 ;cmp byte [ldrives], 0 8706 ;jna short dld_stc 8707 8708 000031E0 B005 mov al, 5 ; extended partition (logical drives) 8709 000031E2 E8BCF7 call display_partition_table 8710 8711 000031E5 A0[E86E] mov al, [ldrives] 8712 000031E8 0430 add al, '0' 8713 000031EA A2[F561] mov [lddp_num], al 8714 8715 000031ED BE[A261] mov si, msg_delete_ldd 8716 000031F0 E856EC call print_msg 8717 8718 000031F3 BE[DE4E] mov si, msg_press_esc_to_cancel 8719 000031F6 E850EC call print_msg 8720 dld_0: 8721 000031F9 30E4 xor ah, ah 8722 000031FB CD16 int 16h 8723 8724 000031FD 80FC53 cmp ah, 53h ; DELETE or DEL key 8725 00003200 7527 jne short dld_1 8726 8727 ; Open disk image file again. 8728 00003202 BA[9959] mov dx, img_file_name 8729 00003205 B8023D mov ax, 3D02h ; open for reading and writing 8730 00003208 CD21 int 21h 8731 0000320A 7221 jc short dld_5 8732 8733 0000320C A3[A840] mov [img_file_handle], ax 8734 8735 ; Delete PTE 1 & PTE 2 on EBR 1 8736 ;xor ah, ah 8737 0000320F A0[E86E] mov al, [ldrives] 8738 00003212 FEC8 dec al 8739 00003214 7518 jnz short dld_2 8740 8741 00003216 BF[AC70] mov di, ebr_buffer+446 8742 00003219 B91000 mov cx, 16 8743 0000321C F3AB rep stosw 8744 8745 ; 04/03/2019 8746 ; Clear ldd data in extended partition table/structure 8747 0000321E BF[AA71] mov di, ext_table_boot_ind 8748 00003221 B109 mov cl, 9 8749 00003223 F3AB rep stosw 8750 00003225 31F6 xor si, si 8751 00003227 EB40 jmp short dld_3 8752 dld_1: 8753 00003229 3C1B cmp al, 27 ; ESC key 8754 0000322B 75CC jne short dld_0 8755 dld_5: 8756 0000322D C3 retn 8757 8758 ;dld_stc: 8759 ; stc 8760 ; retn 8761 8762 dld_2: 8763 ; 04/03/2019 8764 ; Delete 2nd PTE on EBR 2 to 4 8765 0000322E FEC8 dec al 8766 00003230 C0E002 shl al, 2 ; *4 8767 00003233 89C6 mov si, ax 8768 8769 00003235 8B84[4872] mov ax, [si+ldd_start] 8770 00003239 8B94[4A72] mov dx, [si+ldd_start+2] 8771 0000323D BB[EE6E] mov bx, ebr_buffer 8772 00003240 E854EC call read_hd_sector 8773 00003243 7238 jc short dld_4 8774 8775 00003245 BF[BC70] mov di, ebr_buffer+446+16 8776 00003248 B90800 mov cx, 8 8777 0000324B 29C0 sub ax, ax 8778 0000324D F3AB rep stosw 8779 8780 ; 04/03/2019 8781 ;cmp byte [ldrives], 5 8782 ;jnb short dld_3 8783 0000324F 8A26[E86E] mov ah, [ldrives] 8784 00003253 80FC05 cmp ah, 5 8785 00003256 7311 jnb short dld_3 8786 8787 ; Clear ldd data in extended partition table/structure 8788 ;mov ah, [ldrives] 8789 00003258 FECC dec ah 8790 0000325A B012 mov al, 18 8791 0000325C F6E4 mul ah 8792 0000325E BF[AA71] mov di, ext_table_boot_ind 8793 00003261 01C7 add di, ax 8794 ;mov cx, 9 8795 00003263 B109 mov cl, 9 8796 ;xor ax, ax 8797 00003265 30C0 xor al, al 8798 00003267 F3AB rep stosw 8799 dld_3: 8800 ; Write changed EBR 8801 00003269 8B84[4872] mov ax, [si+ldd_start] 8802 0000326D 8B94[4A72] mov dx, [si+ldd_start+2] 8803 00003271 BB[EE6E] mov bx, ebr_buffer 8804 00003274 E8E1EB call write_hd_sector 8805 00003277 7204 jc short dld_4 8806 8807 ; 28/02/2019 8808 00003279 FE0E[E86E] dec byte [ldrives] 8809 dld_4: 8810 ; Close file 8811 0000327D 8B1E[A840] mov bx, [img_file_handle] 8812 00003281 B43E mov ah, 3Eh ; close file 8813 00003283 CD21 int 21h 8814 8815 00003285 C706[A840]0000 mov word [img_file_handle], 0 8816 8817 0000328B 803E[E86E]00 cmp byte [ldrives], 0 8818 00003290 0F874CFF ja delete_logical_drives 8819 8820 00003294 C3 retn 8821 8822 ;============================================================================= 8823 ; initialized data 8824 ;============================================================================= 8825 8826 00003295 00 db 0 8827 8828 TRDOS386_MASTERBOOT_SECTOR: 8829 00003296 incbin 'FS1_MBR.BIN' ; Singlix FS1 MBR 8830 8831 TRDOS_FAT_hd_bs: 8832 ;incbin 'TRHDBS.BIN' 8833 ; 04/05/2024 8834 ;TRDOS_FAT32_hd_bs: 8835 ;incbin 'FAT32_BS.BIN' ; 27/04/2024 8836 RD5_FAT32_hd_bs: 8837 00003496 incbin 'RD5HDBS3.BIN' ; 29/01/2026 8838 ;TRDOS_FAT16_hd_bs: 8839 ;incbin 'FAT16_BS.BIN' ; 26/12/2017 8840 RD5_FAT16_hd_bs: 8841 00003896 incbin 'RD5HDBS2.BIN' ; 20/04/2024 8842 ;TRDOS_FAT12_hd_bs: 8843 ;incbin 'FAT12_BS.BIN' ; 26/12/2017 8844 RD5_FAT12_hd_bs: 8845 00003A96 incbin 'RD5HDBS1.BIN' ; 20/04/2024 8846 8847 TRDOS_TRFS1_chs_bs: 8848 00003C96 incbin 'TRFS1CHS.BIN' ; Singlix FS1 (CHS+LBA Disk) BS 8849 TRDOS_TRFS1_lba_bs: 8850 00003E96 incbin 'TRFS1LBA.BIN' ; Singlix FS1 (LBA Disk) BS 8851 8852 00004096 00 db 0 8853 8854 hexchrs: 8855 00004097 303132333435363738- db '0123456789ABCDEF' 8855 000040A0 39414243444546 8856 8857 000040A7 90 align 2 8858 8859 img_file_handle: 8860 000040A8 0000 dw 0 8861 8862 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 8863 8864 sectors: ; sectors per track (63) 8865 000040AA 3F00 dw 63 8866 heads: ; number of heads (16 or 32 or 64) 8867 000040AC 1000 dw 16 8868 cylinders: ; number of cylinders (16 to 1024) 8869 000040AE 0004 dw 1024 8870 8871 random: 8872 000040B0 00 db 0 ; random write to file (0 = sequental) 8873 newdisk: 8874 000040B1 00 db 0 8875 8876 FileSys_Names: ; 2003-2017 8877 ; (Valid FileSystems for TRDOS 386, SINGLIX, RETRO UNIX OS projects in 2017) 8878 000040B2 464154313220202020- FS_FAT12: db "FAT12 " ; 01h = FAT12 8878 000040BB 2020202020 8879 000040C0 58454E495820202020- FS_XENIX: db "XENIX " ; 02h , XENIX System V root 8879 000040C9 2020202020 8880 000040CE 58454E495820757372- FS_XENIX_USR: db "XENIX usr " ; 03h , XENIX System V user 8880 000040D7 2020202020 8881 000040DC 464154313620283034- FS_FAT16: db "FAT16 (04h) " ; 04h = FAT16 < 32MB 8881 000040E5 6829202020 8882 000040EA 455854454E44454420- FS_EXT_CHS: db "EXTENDED (CHS)" ; 05h = Extended DOS Partition 8882 000040F3 2843485329 8883 000040F8 464154313620283036- FS_FAT16_BIG: db "FAT16 (06h) " ; 06h = FAT16 > 32MB, CHS mode 8883 00004101 6829202020 8884 00004106 4E5446532020202020- FS_NTFS: db "NTFS " ; 07h , WINDOWS NTFS Partition 8884 0000410F 2020202020 8885 00004114 464154333220284348- FS_FAT32_CHS: db "FAT32 (CHS) " ; 0Bh = FAT32, CHS mode 8885 0000411D 5329202020 8886 00004122 464154333220284C42- FS_FAT32_LBA: db "FAT32 (LBA) " ; 0Ch = FAT32, LBA mode 8886 0000412B 4129202020 8887 00004130 464154313620284C42- FS_FAT16_LBA: db "FAT16 (LBA) " ; 0Eh = FAT16, LBA mode 8887 00004139 4129202020 8888 0000413E 455854454E44454420- FS_EXT_LBA: db "EXTENDED (LBA)" ; 0Fh = Extented Partition, LBA mode 8888 00004147 284C424129 8889 0000414C 554E49582053595354- FS_UNIX_SYSV: db "UNIX SYSTEM V " ; 63h , SCO UNIX, UNIXWARE, OPENSERVER 8889 00004155 454D205620 8890 0000415A 524554524F20554E49- FS_RETROUNIX: db "RETRO UNIX " ; 71h , Retro UNIX 386 v2 Partition 8890 00004163 5820202020 8891 00004168 554E49582056372020- FS_UNIX_V7: db "UNIX V7 " ; 72h , UNIX v7 x86 Partition 8891 00004171 2020202020 8892 00004176 4C494E555820535741- FS_LINUXSWAP: db "LINUX SWAP " ; 82h , LINUX SWAP Partition 8892 0000417F 5020202020 8893 00004184 4C494E555820202020- FS_LINUX: db "LINUX " ; 83h , LINUX NATIVE (ext2) Partition 8893 0000418D 2020202020 8894 00004192 4C494E555820455854- FS_LINUXEXT: db "LINUX EXTENDED" ; 85h , LINUX EXTENDED Partition 8894 0000419B 454E444544 8895 000041A0 524444202020202020- FS_TRDD: db "RDD " ; A0h , (Random Data Disk) LBA 8895 000041A9 2020202020 8896 000041AE 53494E474C49582046- FS_TRFS: db "SINGLIX FS1 " ; A1h , (32 bit, 512 bytes per sector) 8896 000041B7 5331202020 8897 000041BC 554E4B4E4F574E2046- FS_OTHERS: db "UNKNOWN FS " ; Another or Unknown File Systems 8897 000041C5 5320202020 8898 8899 valid_partitions: ; (*) 8900 000041CA 01020304050607 db 01h, 02h, 03h, 04h, 05h, 06h, 07h 8901 000041D1 0B0C0E0F637172 db 0Bh, 0Ch, 0Eh, 0Fh, 63h, 71h, 72h 8902 000041D8 828385A0A1 db 82h, 83h, 85h, 0A0h, 0A1h 8903 8904 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8905 ; Messages 8906 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8907 8908 CHS_msg: ; 80 bytes per row 8909 000041DD 507265737320274327- db "Press 'C' to set cylinders then press '+,-' keys to change number of cylinders. " 8909 000041E6 20746F207365742063- 8909 000041EF 796C696E6465727320- 8909 000041F8 7468656E2070726573- 8909 00004201 7320272B2C2D27206B- 8909 0000420A 65797320746F206368- 8909 00004213 616E6765206E756D62- 8909 0000421C 6572206F662063796C- 8909 00004225 696E646572732E20 8910 0000422D 507265737320274827- db "Press 'H' to set heads then press '+,-' keys to change number of heads. " 8910 00004236 20746F207365742068- 8910 0000423F 65616473207468656E- 8910 00004248 20707265737320272B- 8910 00004251 2C2D27206B65797320- 8910 0000425A 746F206368616E6765- 8910 00004263 206E756D626572206F- 8910 0000426C 662068656164732E20- 8910 00004275 2020202020202020 8911 0000427D 507265737320275327- db "Press 'S' to set sectors then press '+,-' keys to change numb of sectors/track. " 8911 00004286 20746F207365742073- 8911 0000428F 6563746F7273207468- 8911 00004298 656E20707265737320- 8911 000042A1 272B2C2D27206B6579- 8911 000042AA 7320746F206368616E- 8911 000042B3 6765206E756D62206F- 8911 000042BC 6620736563746F7273- 8911 000042C5 2F747261636B2E20 8912 000042CD 202020202020202020- db " " 8912 000042D6 202020202020202020- 8912 000042DF 202020202020202020- 8912 000042E8 202020202020202020- 8912 000042F1 202020202020202020- 8912 000042FA 202020202020202020- 8912 00004303 202020202020202020- 8912 0000430C 202020202020202020- 8912 00004315 2020202020202020 8913 0000431D 202020202020202020- db " " 8913 00004326 202020202020202020- 8913 0000432F 202020202020202020- 8913 00004338 202020202020202020- 8913 00004341 202020202020202020- 8913 0000434A 202020202020202020- 8913 00004353 202020202020202020- 8913 0000435C 202020202020202020- 8913 00004365 2020202020202020 8914 0000436D 507265737320454E54- db "Press ENTER to use current CHS values. " 8914 00004376 455220746F20757365- 8914 0000437F 2063757272656E7420- 8914 00004388 4348532076616C7565- 8914 00004391 732E20202020202020- 8914 0000439A 202020202020202020- 8914 000043A3 202020202020202020- 8914 000043AC 202020202020202020- 8914 000043B5 2020202020202020 8915 000043BD 202020202020202020- db " " 8915 000043C6 202020202020202020- 8915 000043CF 202020202020202020- 8915 000043D8 202020202020202020- 8915 000043E1 202020202020202020- 8915 000043EA 202020202020202020- 8915 000043F3 202020202020202020- 8915 000043FC 202020202020202020- 8915 00004405 2020202020202020 8916 0000440D 507265737320455343- db "Press ESC to cancel. " 8916 00004416 20746F2063616E6365- 8916 0000441F 6C2E20202020202020- 8916 00004428 202020202020202020- 8916 00004431 202020202020202020- 8916 0000443A 202020202020202020- 8916 00004443 202020202020202020- 8916 0000444C 202020202020202020- 8916 00004455 2020202020202020 8917 0000445D 202020202020202020- db " " 8917 00004466 202020202020202020- 8917 0000446F 202020202020202020- 8917 00004478 202020202020202020- 8917 00004481 202020202020202020- 8917 0000448A 202020202020202020- 8917 00004493 202020202020202020- 8917 0000449C 202020202020202020- 8917 000044A5 2020202020202020 8918 000044AD 00 db 0 8919 8920 ; 04/05/2024 8921 ;TrDOS_Welcome: 8922 RD5_Welcome: 8923 000044AE 0D0A db 0Dh, 0Ah 8924 ;db 'TR-DOS 386 Fixed Disk Image Format Utility' 8925 000044B0 526574726F20444F53- db 'Retro DOS v5 Fixed Disk Image Format Utility' 8925 000044B9 207635204669786564- 8925 000044C2 204469736B20496D61- 8925 000044CB 676520466F726D6174- 8925 000044D4 205574696C697479 8926 000044DC 0D0A db 0Dh, 0Ah 8927 ;;db "v1.1.240503 (c) Erdogan TAN 2019-2024" 8928 ;db "v2.0.240715 (c) Erdogan TAN 2019-2024" 8929 000044DE 76322E302E32363031- db "v2.0.260129 (c) Erdogan TAN 2019-2026" 8929 000044E7 323920286329204572- 8929 000044F0 646F67616E2054414E- 8929 000044F9 20323031392D323032- 8929 00004502 36 8930 00004503 0D0A db 0Dh,0Ah 8931 00004505 0D0A db 0Dh,0Ah 8932 ;db 'Usage: hdimage ' 8933 00004507 55736167653A207264- db 'Usage: rd5hdimg ' 8933 00004510 356864696D67203C69- 8933 00004519 6D6167652066696C65- 8933 00004522 206E616D653E20 8934 00004529 00 db 0 8935 8936 msg_inv_file_name: 8937 0000452A 0D0A db 0Dh, 0Ah 8938 0000452C 496E76616C69642066- db "Invalid file name !", 0Dh, 0Ah 8938 00004535 696C65206E616D6520- 8938 0000453E 210D0A 8939 00004541 2846696C65206E616D- db "(File name must fit to 8.3 DOS format) !" 8939 0000454A 65206D757374206669- 8939 00004553 7420746F20382E3320- 8939 0000455C 444F5320666F726D61- 8939 00004565 74292021 8940 00004569 0D0A00 db 0Dh, 0Ah, 0 8941 8942 msg_inv_image_file: 8943 0000456C 0D0A db 0Dh, 0Ah 8944 0000456E 496E76616C69642066- db "Invalid fixed disk image file !", 0Dh, 0Ah 8944 00004577 69786564206469736B- 8944 00004580 20696D616765206669- 8944 00004589 6C6520210D0A 8945 0000458F 2846696C652073697A- db "(File size or masterboot sector is not compatible) !" 8945 00004598 65206F72206D617374- 8945 000045A1 6572626F6F74207365- 8945 000045AA 63746F72206973206E- 8945 000045B3 6F7420636F6D706174- 8945 000045BC 69626C65292021 8946 000045C3 0D0A00 db 0Dh, 0Ah, 0 8947 8948 msg_min_8mb_disk: 8949 000045C6 0D0A db 0Dh, 0Ah 8950 000045C8 4D696E696D756D2038- db "Minimum 8 MB disk size is needed for a proper hard disk image !" 8950 000045D1 204D42206469736B20- 8950 000045DA 73697A65206973206E- 8950 000045E3 656564656420666F72- 8950 000045EC 20612070726F706572- 8950 000045F5 206861726420646973- 8950 000045FE 6B20696D6167652021 8951 00004607 0D0A db 0Dh, 0Ah 8952 00004609 28507265737320616E- db "(Press any key to continue..)" 8952 00004612 79206B657920746F20- 8952 0000461B 636F6E74696E75652E- 8952 00004624 2E29 8953 00004626 0D0A00 db 0Dh, 0Ah, 0 8954 8955 msg_any_key_esc_exit: 8956 00004629 0D0A db 0Dh, 0Ah 8957 0000462B 507265737320455343- db "Press ESC to exit or press another key to continue..." 8957 00004634 20746F206578697420- 8957 0000463D 6F7220707265737320- 8957 00004646 616E6F74686572206B- 8957 0000464F 657920746F20636F6E- 8957 00004658 74696E75652E2E2E 8958 00004660 00 db 0 8959 8960 msg_create_partition_h: 8961 00004661 0D0A db 0Dh, 0Ah 8962 00004663 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8962 0000466C 2D2D2D2D2D2D2D2D2D- 8962 00004675 2D2D2D2D2D2D2D2D2D- 8962 0000467E 2D2D2D2D2D2D2D2D2D- 8962 00004687 2D2D2D2D2D2D2D2D2D- 8962 00004690 2D2D2D2D2D2D2D2D2D- 8962 00004699 2D2D2D2D2D2D2D2D2D- 8962 000046A2 2D2D2D2D2D2D2D2D2D- 8962 000046AB 2D2D2D2D2D2D2D2D 8963 000046B3 202020202020202020- db " Create Partition " 8963 000046BC 202020202020202020- 8963 000046C5 202020202020202020- 8963 000046CE 202020204372656174- 8963 000046D7 652050617274697469- 8963 000046E0 6F6E20202020202020- 8963 000046E9 202020202020202020- 8963 000046F2 202020202020202020- 8963 000046FB 2020202020202020 8964 00004703 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8964 0000470C 2D2D2D2D2D2D2D2D2D- 8964 00004715 2D2D2D2D2D2D2D2D2D- 8964 0000471E 2D2D2D2D2D2D2D2D2D- 8964 00004727 2D2D2D2D2D2D2D2D2D- 8964 00004730 2D2D2D2D2D2D2D2D2D- 8964 00004739 2D2D2D2D2D2D2D2D2D- 8964 00004742 2D2D2D2D2D2D2D2D2D- 8964 0000474B 2D2D2D2D2D2D2D2D 8965 00004753 0D0A00 db 0Dh, 0Ah, 0 8966 msg_create_partition_m: 8967 00004756 53656C65637420616E- db "Select an option: " 8967 0000475F 206F7074696F6E3A20 8968 00004768 0D0A db 0Dh, 0Ah 8969 0000476A 0D0A db 0Dh, 0Ah 8970 0000476C 202031292043726561- db " 1) Create DOS partition ", 0Dh, 0Ah 8970 00004775 746520444F53207061- 8970 0000477E 72746974696F6E200D- 8970 00004787 0A 8971 00004788 202032292043726561- db " 2) Create SINGLIX FS partition ", 0Dh, 0Ah 8971 00004791 74652053494E474C49- 8971 0000479A 582046532070617274- 8971 000047A3 6974696F6E200D0A 8972 000047AB 202033292043726561- db " 3) Create RETRO UNIX partition ", 0Dh, 0Ah 8972 000047B4 746520524554524F20- 8972 000047BD 554E49582070617274- 8972 000047C6 6974696F6E200D0A 8973 000047CE 202034292043726561- db " 4) Create another type of partition ", 0Dh, 0Ah 8973 000047D7 746520616E6F746865- 8973 000047E0 722074797065206F66- 8973 000047E9 20706172746974696F- 8973 000047F2 6E200D0A 8974 000047F6 0D0A db 0Dh, 0Ah 8975 000047F8 507265737320455343- db "Press ESC or 0 to cancel .. " 8975 00004801 206F72203020746F20- 8975 0000480A 63616E63656C202E2E- 8975 00004813 20 8976 00004814 0D0A00 db 0Dh, 0Ah, 0 8977 8978 msg_create_primary_partition_h: 8979 00004817 0D0A db 0Dh, 0Ah 8980 00004819 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8980 00004822 2D2D2D2D2D2D2D2D2D- 8980 0000482B 2D2D2D2D2D2D2D2D2D- 8980 00004834 2D2D2D2D2D2D2D2D2D- 8980 0000483D 2D2D2D2D2D2D2D2D2D- 8980 00004846 2D2D2D2D2D2D2D2D2D- 8980 0000484F 2D2D2D2D2D2D2D2D2D- 8980 00004858 2D2D2D2D2D2D2D2D2D- 8980 00004861 2D2D2D2D2D2D2D2D 8981 00004869 202020202020202020- db " Create Primary DOS Partition " 8981 00004872 202020202020202020- 8981 0000487B 202020202020202043- 8981 00004884 726561746520507269- 8981 0000488D 6D61727920444F5320- 8981 00004896 506172746974696F6E- 8981 0000489F 202020202020202020- 8981 000048A8 202020202020202020- 8981 000048B1 2020202020202020 8982 000048B9 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8982 000048C2 2D2D2D2D2D2D2D2D2D- 8982 000048CB 2D2D2D2D2D2D2D2D2D- 8982 000048D4 2D2D2D2D2D2D2D2D2D- 8982 000048DD 2D2D2D2D2D2D2D2D2D- 8982 000048E6 2D2D2D2D2D2D2D2D2D- 8982 000048EF 2D2D2D2D2D2D2D2D2D- 8982 000048F8 2D2D2D2D2D2D2D2D2D- 8982 00004901 2D2D2D2D2D2D2D2D 8983 00004909 0D0A00 db 0Dh, 0Ah, 0 8984 8985 msg_create_dos_partition_h: 8986 0000490C 0D0A db 0Dh, 0Ah 8987 0000490E 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8987 00004917 2D2D2D2D2D2D2D2D2D- 8987 00004920 2D2D2D2D2D2D2D2D2D- 8987 00004929 2D2D2D2D2D2D2D2D2D- 8987 00004932 2D2D2D2D2D2D2D2D2D- 8987 0000493B 2D2D2D2D2D2D2D2D2D- 8987 00004944 2D2D2D2D2D2D2D2D2D- 8987 0000494D 2D2D2D2D2D2D2D2D2D- 8987 00004956 2D2D2D2D2D2D2D2D 8988 0000495E 202020202020202020- db " Create DOS Partition or Logical DOS Drive " 8988 00004967 202020202020202020- 8988 00004970 204372656174652044- 8988 00004979 4F5320506172746974- 8988 00004982 696F6E206F72204C6F- 8988 0000498B 676963616C20444F53- 8988 00004994 204472697665202020- 8988 0000499D 202020202020202020- 8988 000049A6 2020202020202020 8989 000049AE 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8989 000049B7 2D2D2D2D2D2D2D2D2D- 8989 000049C0 2D2D2D2D2D2D2D2D2D- 8989 000049C9 2D2D2D2D2D2D2D2D2D- 8989 000049D2 2D2D2D2D2D2D2D2D2D- 8989 000049DB 2D2D2D2D2D2D2D2D2D- 8989 000049E4 2D2D2D2D2D2D2D2D2D- 8989 000049ED 2D2D2D2D2D2D2D2D2D- 8989 000049F6 2D2D2D2D2D2D2D2D 8990 000049FE 0D0A00 db 0Dh, 0Ah, 0 8991 8992 msg_create_ext_partition_h: 8993 00004A01 0D0A db 0Dh, 0Ah 8994 00004A03 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8994 00004A0C 2D2D2D2D2D2D2D2D2D- 8994 00004A15 2D2D2D2D2D2D2D2D2D- 8994 00004A1E 2D2D2D2D2D2D2D2D2D- 8994 00004A27 2D2D2D2D2D2D2D2D2D- 8994 00004A30 2D2D2D2D2D2D2D2D2D- 8994 00004A39 2D2D2D2D2D2D2D2D2D- 8994 00004A42 2D2D2D2D2D2D2D2D2D- 8994 00004A4B 2D2D2D2D2D2D2D2D 8995 00004A53 202020202020202020- db " Create Extended DOS Partition " 8995 00004A5C 202020202020202020- 8995 00004A65 202020202020204372- 8995 00004A6E 656174652045787465- 8995 00004A77 6E64656420444F5320- 8995 00004A80 506172746974696F6E- 8995 00004A89 202020202020202020- 8995 00004A92 202020202020202020- 8995 00004A9B 2020202020202020 8996 00004AA3 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 8996 00004AAC 2D2D2D2D2D2D2D2D2D- 8996 00004AB5 2D2D2D2D2D2D2D2D2D- 8996 00004ABE 2D2D2D2D2D2D2D2D2D- 8996 00004AC7 2D2D2D2D2D2D2D2D2D- 8996 00004AD0 2D2D2D2D2D2D2D2D2D- 8996 00004AD9 2D2D2D2D2D2D2D2D2D- 8996 00004AE2 2D2D2D2D2D2D2D2D2D- 8996 00004AEB 2D2D2D2D2D2D2D2D 8997 00004AF3 0D0A00 db 0Dh, 0Ah, 0 8998 8999 msg_create_logical_drive_h: 9000 00004AF6 0D0A db 0Dh, 0Ah 9001 00004AF8 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9001 00004B01 2D2D2D2D2D2D2D2D2D- 9001 00004B0A 2D2D2D2D2D2D2D2D2D- 9001 00004B13 2D2D2D2D2D2D2D2D2D- 9001 00004B1C 2D2D2D2D2D2D2D2D2D- 9001 00004B25 2D2D2D2D2D2D2D2D2D- 9001 00004B2E 2D2D2D2D2D2D2D2D2D- 9001 00004B37 2D2D2D2D2D2D2D2D2D- 9001 00004B40 2D2D2D2D2D2D2D2D 9002 00004B48 202020202020202020- db " Create Logical DOS Drive " 9002 00004B51 202020202020202020- 9002 00004B5A 202020202020202020- 9002 00004B63 20437265617465204C- 9002 00004B6C 6F676963616C20444F- 9002 00004B75 532044726976652020- 9002 00004B7E 202020202020202020- 9002 00004B87 202020202020202020- 9002 00004B90 2020202020202020 9003 00004B98 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9003 00004BA1 2D2D2D2D2D2D2D2D2D- 9003 00004BAA 2D2D2D2D2D2D2D2D2D- 9003 00004BB3 2D2D2D2D2D2D2D2D2D- 9003 00004BBC 2D2D2D2D2D2D2D2D2D- 9003 00004BC5 2D2D2D2D2D2D2D2D2D- 9003 00004BCE 2D2D2D2D2D2D2D2D2D- 9003 00004BD7 2D2D2D2D2D2D2D2D2D- 9003 00004BE0 2D2D2D2D2D2D2D2D 9004 00004BE8 0D0A00 db 0Dh, 0Ah, 0 9005 9006 msg_create_nondos_partition_h: 9007 00004BEB 0D0A db 0Dh, 0Ah 9008 00004BED 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9008 00004BF6 2D2D2D2D2D2D2D2D2D- 9008 00004BFF 2D2D2D2D2D2D2D2D2D- 9008 00004C08 2D2D2D2D2D2D2D2D2D- 9008 00004C11 2D2D2D2D2D2D2D2D2D- 9008 00004C1A 2D2D2D2D2D2D2D2D2D- 9008 00004C23 2D2D2D2D2D2D2D2D2D- 9008 00004C2C 2D2D2D2D2D2D2D2D2D- 9008 00004C35 2D2D2D2D2D2D2D2D 9009 00004C3D 202020202020202020- db " Create NON-DOS Partition " 9009 00004C46 202020202020202020- 9009 00004C4F 202020202020202020- 9009 00004C58 20437265617465204E- 9009 00004C61 4F4E2D444F53205061- 9009 00004C6A 72746974696F6E2020- 9009 00004C73 202020202020202020- 9009 00004C7C 202020202020202020- 9009 00004C85 2020202020202020 9010 00004C8D 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9010 00004C96 2D2D2D2D2D2D2D2D2D- 9010 00004C9F 2D2D2D2D2D2D2D2D2D- 9010 00004CA8 2D2D2D2D2D2D2D2D2D- 9010 00004CB1 2D2D2D2D2D2D2D2D2D- 9010 00004CBA 2D2D2D2D2D2D2D2D2D- 9010 00004CC3 2D2D2D2D2D2D2D2D2D- 9010 00004CCC 2D2D2D2D2D2D2D2D2D- 9010 00004CD5 2D2D2D2D2D2D2D2D 9011 00004CDD 0D0A00 db 0Dh, 0Ah, 0 9012 9013 msg_create_dos_partition_m: 9014 00004CE0 53656C65637420616E- db "Select an option: " 9014 00004CE9 206F7074696F6E3A20 9015 00004CF2 0D0A db 0Dh, 0Ah 9016 00004CF4 0D0A db 0Dh, 0Ah 9017 00004CF6 202031292043726561- db " 1) Create Primary DOS partition ", 0Dh, 0Ah 9017 00004CFF 7465205072696D6172- 9017 00004D08 7920444F5320706172- 9017 00004D11 746974696F6E200D0A 9018 00004D1A 202032292043726561- db " 2) Create Extended DOS partition ", 0Dh, 0Ah 9018 00004D23 746520457874656E64- 9018 00004D2C 656420444F53207061- 9018 00004D35 72746974696F6E200D- 9018 00004D3E 0A 9019 00004D3F 202033292043726561- db " 3) Create Logical DOS drive(s) in Extended DOS partition ", 0Dh, 0Ah 9019 00004D48 7465204C6F67696361- 9019 00004D51 6C20444F5320647269- 9019 00004D5A 766528732920696E20- 9019 00004D63 457874656E64656420- 9019 00004D6C 444F53207061727469- 9019 00004D75 74696F6E200D0A 9020 00004D7C 0D0A db 0Dh, 0Ah 9021 00004D7E 507265737320455343- db "Press ESC or 0 to cancel .. " 9021 00004D87 206F72203020746F20- 9021 00004D90 63616E63656C202E2E- 9021 00004D99 20 9022 00004D9A 0D0A00 db 0Dh, 0Ah, 0 9023 9024 msg_create_dos_partition_s: 9025 00004D9D 53656C65637420616E- db "Select an option to set partition size: " 9025 00004DA6 206F7074696F6E2074- 9025 00004DAF 6F2073657420706172- 9025 00004DB8 746974696F6E207369- 9025 00004DC1 7A653A20 9026 00004DC5 0D0A db 0Dh, 0Ah 9027 00004DC7 0D0A db 0Dh, 0Ah 9028 00004DC9 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 9028 00004DD2 6E64657220636F756E- 9028 00004DDB 740D0A 9029 00004DDE 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 9029 00004DE7 6D652070657263656E- 9029 00004DF0 746167652028232325- 9029 00004DF9 290D0A 9030 00004DFC 202053292053656374- db " S) Sectors (number of 512 bytes)", 0Dh, 0Ah 9030 00004E05 6F727320286E756D62- 9030 00004E0E 6572206F6620353132- 9030 00004E17 206279746573290D0A 9031 00004E20 20204B29204B696C6F- db " K) Kilo bytes (KB, 2*K sectors)", 0Dh, 0Ah 9031 00004E29 20627974657320284B- 9031 00004E32 422C20322A4B207365- 9031 00004E3B 63746F7273290D0A 9032 00004E43 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 9032 00004E4C 20627974657320284D- 9032 00004E55 422C20322A31303234- 9032 00004E5E 2A4D20736563746F72- 9032 00004E67 73290D0A 9033 00004E6B 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 9033 00004E74 206279746573202847- 9033 00004E7D 422C20322A31303234- 9033 00004E86 2A313032342A472073- 9033 00004E8F 6563746F7273290D0A 9034 00004E98 0D0A db 0Dh, 0Ah 9035 00004E9A 507265737320535041- db "Press SPACE to use whole disk or press ENTER to set sector count .. " 9035 00004EA3 434520746F20757365- 9035 00004EAC 2077686F6C65206469- 9035 00004EB5 736B206F7220707265- 9035 00004EBE 737320454E54455220- 9035 00004EC7 746F20736574207365- 9035 00004ED0 63746F7220636F756E- 9035 00004ED9 74202E2E20 9036 msg_press_esc_to_cancel: 9037 00004EDE 0D0A db 0Dh, 0Ah 9038 00004EE0 285072657373204553- db "(Press ESC to CANCEL) " 9038 00004EE9 4320746F2043414E43- 9038 00004EF2 454C2920 9039 00004EF6 0D0A00 db 0Dh, 0Ah, 0 9040 9041 msg_use_whole_disk: 9042 00004EF9 446F20796F75207761- db "Do you want to use WHOLE disk !? (Y/N)", 0 9042 00004F02 6E7420746F20757365- 9042 00004F0B 2057484F4C45206469- 9042 00004F14 736B20213F2028592F- 9042 00004F1D 4E2900 9043 9044 msg_use_all_space: 9045 00004F20 446F20796F75207761- db "Do you want to use all of available space !? (Y/N)", 0 9045 00004F29 6E7420746F20757365- 9045 00004F32 20616C6C206F662061- 9045 00004F3B 7661696C61626C6520- 9045 00004F44 737061636520213F20- 9045 00004F4D 28592F4E2900 9046 9047 msg_use_entire_ep_space: 9048 00004F53 446F20796F75207761- db "Do you want to use entire extended partition space !? (Y/N)", 0 9048 00004F5C 6E7420746F20757365- 9048 00004F65 20656E746972652065- 9048 00004F6E 7874656E6465642070- 9048 00004F77 6172746974696F6E20- 9048 00004F80 737061636520213F20- 9048 00004F89 28592F4E2900 9049 9050 msg_partition_size: 9051 00004F8F 0D0A db 0Dh, 0Ah 9052 00004F91 0D0A db 0Dh, 0Ah 9053 00004F93 506172746974696F6E- db "Partition size (" 9053 00004F9C 2073697A652028 9054 msg_partition_size_x: 9055 00004FA3 3F29203A20 db "?) : " 9056 00004FA8 00 db 0 9057 9058 msg_partition_type: 9059 00004FA9 0D0A db 0Dh, 0Ah 9060 00004FAB 0D0A db 0Dh, 0Ah 9061 00004FAD 506172746974696F6E- db "Partition type : " 9061 00004FB6 2074797065203A20 9062 00004FBE 00 db 0 9063 9064 msg_ptype_num: 9065 00004FBF 3030680D0A00 db "00h", 0Dh, 0Ah, 0 9066 9067 msg_partition_type_error: 9068 00004FC5 506172746974696F6E- db "Partition size is not proper for selected partition type !" 9068 00004FCE 2073697A6520697320- 9068 00004FD7 6E6F742070726F7065- 9068 00004FE0 7220666F722073656C- 9068 00004FE9 656374656420706172- 9068 00004FF2 746974696F6E207479- 9068 00004FFB 70652021 9069 00004FFF 0D0A db 0Dh, 0Ah 9070 msg_any_key_to_retry: 9071 00005001 28507265737320616E- db "(Press any key to retry..)" 9071 0000500A 79206B657920746F20- 9071 00005013 72657472792E2E29 9072 0000501B 0D0A00 db 0Dh, 0Ah, 0 9073 9074 msg_partition_size_overs: 9075 0000501E 0D0A db 0Dh, 0Ah 9076 00005020 506172746974696F6E- db "Partition size overs the disk capacity !" 9076 00005029 2073697A65206F7665- 9076 00005032 727320746865206469- 9076 0000503B 736B20636170616369- 9076 00005044 74792021 9077 00005048 0D0A db 0Dh, 0Ah 9078 0000504A 28507265737320454E- db "(Press ENTER to use WHOLE disk or press ESC key to retry..)" 9078 00005053 54455220746F207573- 9078 0000505C 652057484F4C452064- 9078 00005065 69736B206F72207072- 9078 0000506E 65737320455343206B- 9078 00005077 657920746F20726574- 9078 00005080 72792E2E29 9079 00005085 0D0A00 db 0Dh, 0Ah, 0 9080 9081 msg_ext_partition_error: 9082 00005088 457874656E64656420- db "Extended partition must be created after primary partition !" 9082 00005091 706172746974696F6E- 9082 0000509A 206D75737420626520- 9082 000050A3 637265617465642061- 9082 000050AC 66746572207072696D- 9082 000050B5 617279207061727469- 9082 000050BE 74696F6E2021 9083 000050C4 0D0A00 db 0Dh, 0Ah,0 9084 9085 msg_logical_drive_error: 9086 000050C7 5072696D6172792061- db "Primary and extended partitions must be created before logical drive !" 9086 000050D0 6E6420657874656E64- 9086 000050D9 656420706172746974- 9086 000050E2 696F6E73206D757374- 9086 000050EB 206265206372656174- 9086 000050F4 6564206265666F7265- 9086 000050FD 206C6F676963616C20- 9086 00005106 64726976652021 9087 0000510D 0D0A00 db 0Dh, 0Ah,0 9088 9089 msg_cylinder_boundary_set: 9090 00005110 0D0A db 0Dh, 0Ah 9091 00005112 446F20796F75207761- db "Do you want to adjust partition size to cylinder boundary ? (Y/N)" 9091 0000511B 6E7420746F2061646A- 9091 00005124 757374207061727469- 9091 0000512D 74696F6E2073697A65- 9091 00005136 20746F2063796C696E- 9091 0000513F 64657220626F756E64- 9091 00005148 617279203F2028592F- 9091 00005151 4E29 9092 00005153 00 db 0 9093 9094 msg_selected_partition: 9095 00005154 202020202020202020- db " PARTITION 0 " 9095 0000515D 202020202020202020- 9095 00005166 202020202020202020- 9095 0000516F 202020202020504152- 9095 00005178 544954494F4E203020- 9095 00005181 202020202020202020- 9095 0000518A 202020202020202020- 9095 00005193 202020202020202020- 9095 0000519C 2020202020202020 9096 000051A4 3D3D3D3D3D3D3D3D3D- db "================================================================================" 9096 000051AD 3D3D3D3D3D3D3D3D3D- 9096 000051B6 3D3D3D3D3D3D3D3D3D- 9096 000051BF 3D3D3D3D3D3D3D3D3D- 9096 000051C8 3D3D3D3D3D3D3D3D3D- 9096 000051D1 3D3D3D3D3D3D3D3D3D- 9096 000051DA 3D3D3D3D3D3D3D3D3D- 9096 000051E3 3D3D3D3D3D3D3D3D3D- 9096 000051EC 3D3D3D3D3D3D3D3D 9097 000051F4 202020202020202053- db " S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 9097 000051FD 202042482020425320- 9097 00005206 204243202046532020- 9097 0000520F 454820204553202045- 9097 00005218 432020202053544152- 9097 00005221 542053454320202053- 9097 0000522A 4543544F5253202020- 9097 00005233 46494C452053595354- 9097 0000523C 454D202020202020 9098 00005244 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9098 0000524D 2D2D2D2D2D2D2D2D2D- 9098 00005256 2D2D2D2D2D2D2D2D2D- 9098 0000525F 2D2D2D2D2D2D2D2D2D- 9098 00005268 2D2D2D2D2D2D2D2D2D- 9098 00005271 2D2D2D2D2D2D2D2D2D- 9098 0000527A 2D2D2D2D2D2D2D2D2D- 9098 00005283 2D2D2D2D2D2D2D2D2D- 9098 0000528C 2D2D2D2D2D2D2D2D 9099 00005294 202020202020202020- pt_row: db " " 9099 0000529D 202020202020202020- 9099 000052A6 202020202020202020- 9099 000052AF 202020202020202020- 9099 000052B8 202020202020202020- 9099 000052C1 202020202020202020- 9099 000052CA 202020202020202020- 9099 000052D3 202020202020202020- 9099 000052DC 2020202020202020 9100 000052E4 3D3D3D3D3D3D3D3D3D- db "================================================================================" 9100 000052ED 3D3D3D3D3D3D3D3D3D- 9100 000052F6 3D3D3D3D3D3D3D3D3D- 9100 000052FF 3D3D3D3D3D3D3D3D3D- 9100 00005308 3D3D3D3D3D3D3D3D3D- 9100 00005311 3D3D3D3D3D3D3D3D3D- 9100 0000531A 3D3D3D3D3D3D3D3D3D- 9100 00005323 3D3D3D3D3D3D3D3D3D- 9100 0000532C 3D3D3D3D3D3D3D3D 9101 00005334 00 db 0 9102 msg_boot_indicator: 9103 00005335 0D0A db 0Dh, 0Ah 9104 00005337 20202020426F6F7420- db " Boot Indicator : ", 0 ; "YES", "NO" 9104 00005340 496E64696361746F72- 9104 00005349 203A2000 9105 msg_starting_head: 9106 0000534D 0D0A db 0Dh, 0Ah 9107 0000534F 202020202053746172- db " Starting Head : ", 0 9107 00005358 74696E672048656164- 9107 00005361 203A2000 9108 msg_starting_sector: 9109 00005365 0D0A db 0Dh, 0Ah 9110 00005367 202020537461727469- db " Starting Sector : ", 0 9110 00005370 6E6720536563746F72- 9110 00005379 203A2000 9111 msg_starting_cylinder: 9112 0000537D 0D0A db 0Dh, 0Ah 9113 0000537F 205374617274696E67- db " Starting Cylinder : ", 0 9113 00005388 2043796C696E646572- 9113 00005391 203A2000 9114 msg_system_id: 9115 00005395 0D0A db 0Dh, 0Ah 9116 00005397 202020202020202020- db " System ID : ", 0 9116 000053A0 53797374656D204944- 9116 000053A9 203A2000 9117 msg_ending_head: 9118 000053AD 0D0A db 0Dh, 0Ah 9119 000053AF 20202020202020456E- db " Ending Head : ", 0 9119 000053B8 64696E672048656164- 9119 000053C1 203A2000 9120 msg_ending_sector: 9121 000053C5 0D0A db 0Dh, 0Ah 9122 000053C7 2020202020456E6469- db " Ending Sector : ", 0 9122 000053D0 6E6720536563746F72- 9122 000053D9 203A2000 9123 msg_ending_cylinder: 9124 000053DD 0D0A db 0Dh, 0Ah 9125 000053DF 202020456E64696E67- db " Ending Cylinder : ", 0 9125 000053E8 2043796C696E646572- 9125 000053F1 203A2000 9126 msg_relative_sectors: 9127 000053F5 0D0A db 0Dh, 0Ah 9128 000053F7 0D0A db 0Dh, 0Ah 9129 000053F9 202052656C61746976- db " Relative Sectors : ", 0 9129 00005402 6520536563746F7273- 9129 0000540B 203A2000 9130 msg_total_sectors: 9131 0000540F 0D0A db 0Dh, 0Ah 9132 00005411 2020202020546F7461- db " Total Sectors : ", 0 9132 0000541A 6C20536563746F7273- 9132 00005423 203A2000 9133 9134 msg_format_stage: 9135 00005427 0D0A db 0Dh, 0Ah 9136 00005429 507265737320454E54- db "Press ENTER to FORMAT disk partition " 9136 00005432 455220746F20464F52- 9136 0000543B 4D4154206469736B20- 9136 00005444 706172746974696F6E- 9136 0000544D 20 9137 partition_num_chr: 9138 0000544E 30 db "0" 9139 0000544F 206F72207072657373- db " or press ESC to EXIT.." 9139 00005458 2045534320746F2045- 9139 00005461 5849542E2E 9140 00005466 00 db 0 9141 msg_partition_edit: 9142 00005467 0D0A db 0Dh, 0Ah 9143 00005469 2E2E206F7220707265- db ".. or press SPACE to EDIT partition table." 9143 00005472 737320535041434520- 9143 0000547B 746F20454449542070- 9143 00005484 6172746974696F6E20- 9143 0000548D 7461626C652E 9144 00005493 0D0A00 db 0Dh, 0Ah, 0 9145 9146 msg_edit_or_exit: 9147 00005496 0D0A db 0Dh, 0Ah 9148 00005498 507265737320454E54- db "Press ENTER to continue or press ESC to exit.." 9148 000054A1 455220746F20636F6E- 9148 000054AA 74696E7565206F7220- 9148 000054B3 707265737320455343- 9148 000054BC 20746F20657869742E- 9148 000054C5 2E 9149 000054C6 00 db 0 9150 9151 msg_overwrite_question1: 9152 000054C7 0D0A db 0Dh, 0Ah 9153 000054C9 446F20796F75207761- db 'Do you want to overwrite ' 9153 000054D2 6E7420746F206F7665- 9153 000054DB 72777269746520 9154 000054E2 27 db 27h 9155 000054E3 00 db 0 9156 9157 msg_overwrite_question2: 9158 000054E4 27 db 27h 9159 000054E5 2066696C6520 db ' file ' 9160 000054EB 00 db 0 9161 9162 msg_format_question: 9163 000054EC 0D0A db 0Dh, 0Ah 9164 000054EE 446F20796F75207761- db "Do you want to format partition " 9164 000054F7 6E7420746F20666F72- 9164 00005500 6D6174207061727469- 9164 00005509 74696F6E20 9165 partition_num_txt: 9166 0000550E 3020 db "0 " 9167 msg_yes_no: 9168 00005510 285965732F4E6F293F- db '(Yes/No)? ', 0 9168 00005519 2000 9169 9170 msg_writing_mbr: 9171 0000551B 57726974696E67206D- db "Writing masterboot sector...", 0 9171 00005524 6173746572626F6F74- 9171 0000552D 20736563746F722E2E- 9171 00005536 2E00 9172 9173 msg_writing_disk_sectors: 9174 00005538 57726974696E672064- db "Writing disk sector: ", 0 9174 00005541 69736B20736563746F- 9174 0000554A 723A2000 9175 9176 Msg_Writing_Boot_Sector: 9177 0000554E 57726974696E672074- db "Writing trdos boot sector...", 0 9177 00005557 72646F7320626F6F74- 9177 00005560 20736563746F722E2E- 9177 00005569 2E00 9178 9179 Msg_Writing_Root_Dir: 9180 0000556B 57726974696E672072- db "Writing root directory sectors...", 0 9180 00005574 6F6F74206469726563- 9180 0000557D 746F72792073656374- 9180 00005586 6F72732E2E2E00 9181 9182 Msg_Writing_Data_Sectors: 9183 0000558D 57726974696E672064- db "Writing data sector: ", 0 9183 00005596 61746120736563746F- 9183 0000559F 723A2000 9184 9185 Sector_Str: 9186 000055A3 3030303030303000 db "0000000", 0 9187 Cursor_Pos: 9188 000055AB 0000 dw 0 9189 9190 Msg_Writing_FAT_Sectors: 9191 000055AD 57726974696E672046- db "Writing FAT sectors...", 0 9191 000055B6 415420736563746F72- 9191 000055BF 732E2E2E00 9192 9193 StrVolumeName: 9194 ;times 12 db 0 9195 000055C4 00 times 65 db 0 ; 05/01/2018 (fs1 volume name) 9196 9197 Msg_Volume_Name: 9198 00005605 0D0A db 0Dh, 0Ah 9199 00005607 0D0A db 0Dh, 0Ah 9200 00005609 566F6C756D65204E61- db "Volume Name: ", 0 9200 00005612 6D653A2000 9201 9202 Msg_Volume_Serial: 9203 00005617 566F6C756D65205365- db "Volume Serial No: " 9203 00005620 7269616C204E6F3A20 9204 Vol_Serial1: 9205 00005629 30303030 db "0000" 9206 0000562D 2D db "-" 9207 Vol_Serial2: 9208 0000562E 30303030 db "0000" 9209 00005632 0D0A00 db 0Dh, 0Ah, 0 9210 9211 msg_cluster_count: 9212 00005635 436C75737465722043- db "Cluster Count: ", 0 9212 0000563E 6F756E743A2000 9213 cluster_count_str: 9214 00005645 30303030303030 db "0000000" 9215 0000564C 0D0A00 db 0Dh, 0Ah, 0 9216 msg_formatting: 9217 0000564F 466F726D617474696E- db "Formatting ", 0 9217 00005658 672000 9218 format_percent_str: 9219 0000565B 30303025 db "000%" 9220 0000565F 00 db 0 9221 9222 Msg_3dot_OK: 9223 00005660 2E2E2E db "..." 9224 Msg_OK: 9225 00005663 204F4B2E db ' OK.' 9226 CRLF: 9227 00005667 0D0A00 db 0Dh, 0Ah, 0 9228 9229 Msg_Error: 9230 0000566A 0D0A db 0Dh, 0Ah 9231 0000566C 4572726F72202120 db 'Error ! ' 9232 00005674 28 db '(' 9233 error_code: 9234 00005675 3030 dw 3030h 9235 00005677 68 db 'h' 9236 00005678 2920 db ') ' 9237 0000567A 0D0A db 0Dh, 0Ah 9238 0000567C 00 db 0 9239 9240 msg_disk_sectors: 9241 0000567D 546F74616C20446973- db "Total Disk Sectors : ", 0 9241 00005686 6B20536563746F7273- 9241 0000568F 203A2000 9242 9243 str_disk_sectors: 9244 00005693 00 times 8 db 0 9245 9246 msg_ep_size: 9247 0000569B 457874656E64656420- db "Extended Partition Size in Sectors: ", 0 9247 000056A4 506172746974696F6E- 9247 000056AD 2053697A6520696E20- 9247 000056B6 536563746F72733A20- 9247 000056BF 00 9248 9249 msg_file_size: 9250 000056C0 484420496D61676520- db "HD Image File Size : ", 0 9250 000056C9 46696C652053697A65- 9250 000056D2 203A2000 9251 9252 str_file_size: 9253 000056D6 00 times 11 db 0 9254 9255 msg_bytes: 9256 000056E1 206279746573 db " bytes" 9257 000056E7 0D0A00 db 0Dh, 0Ah, 0 9258 9259 msg_enter_cancel: 9260 000056EA 0D0A db 0Dh, 0Ah 9261 000056EC 507265737320454E54- db "Press ENTER to write file or press ESC to cancel." 9261 000056F5 455220746F20777269- 9261 000056FE 74652066696C65206F- 9261 00005707 722070726573732045- 9261 00005710 534320746F2063616E- 9261 00005719 63656C2E 9262 0000571D 0D0A00 db 0Dh, 0Ah, 0 9263 9264 msg_press_any_key: 9265 00005720 0D0A db 0Dh, 0Ah 9266 00005722 50726573732061206B- db "Press a key to continue..." 9266 0000572B 657920746F20636F6E- 9266 00005734 74696E75652E2E2E 9267 0000573C 0D0A00 db 0Dh, 0Ah, 0 9268 9269 0000573F 90 align 2 9270 9271 ; Masterboot sector 9272 9273 MasterBootBuff: 9274 MasterBootCode: 9275 00005740 00 times 446 db 0 9276 PartitionTable: 9277 000058FE 00 times 64 db 0 9278 MBIDCode: 9279 0000593E 0000 dw 0 9280 9281 PTable_Buffer: 9282 00005940 00 times 64 db 0 9283 9284 00005980 286329204572646F67- db '(c) Erdogan TAN 2019-2026' 9284 00005989 616E2054414E203230- 9284 00005992 31392D32303236 9285 9286 img_file_name: 9287 00005999 00 times 13 db 0 9288 9289 p_table_header: 9290 000059A6 202020202020202020- db " ?BR PARTITION TABLE " 9290 000059AF 202020202020202020- 9290 000059B8 202020202020202020- 9290 000059C1 2020203F4252205041- 9290 000059CA 52544954494F4E2054- 9290 000059D3 41424C452020202020- 9290 000059DC 202020202020202020- 9290 000059E5 202020202020202020- 9290 000059EE 2020202020202020 9291 000059F6 3D3D3D3D3D3D3D3D3D- db "================================================================================" 9291 000059FF 3D3D3D3D3D3D3D3D3D- 9291 00005A08 3D3D3D3D3D3D3D3D3D- 9291 00005A11 3D3D3D3D3D3D3D3D3D- 9291 00005A1A 3D3D3D3D3D3D3D3D3D- 9291 00005A23 3D3D3D3D3D3D3D3D3D- 9291 00005A2C 3D3D3D3D3D3D3D3D3D- 9291 00005A35 3D3D3D3D3D3D3D3D3D- 9291 00005A3E 3D3D3D3D3D3D3D3D 9292 00005A46 202020202020205020- db " P S BH BS BC FS EH ES EC START SEC SECTORS FILE SYSTEM " 9292 00005A4F 205320204248202042- 9292 00005A58 532020424320204653- 9292 00005A61 202045482020455320- 9292 00005A6A 204543202053544152- 9292 00005A73 542053454320205345- 9292 00005A7C 43544F525320204649- 9292 00005A85 4C452053595354454D- 9292 00005A8E 2020202020202020 9293 00005A96 2D2D2D2D2D2D2D2D2D- db "--------------------------------------------------------------------------------" 9293 00005A9F 2D2D2D2D2D2D2D2D2D- 9293 00005AA8 2D2D2D2D2D2D2D2D2D- 9293 00005AB1 2D2D2D2D2D2D2D2D2D- 9293 00005ABA 2D2D2D2D2D2D2D2D2D- 9293 00005AC3 2D2D2D2D2D2D2D2D2D- 9293 00005ACC 2D2D2D2D2D2D2D2D2D- 9293 00005AD5 2D2D2D2D2D2D2D2D2D- 9293 00005ADE 2D2D2D2D2D2D2D2D 9294 00005AE6 00 db 0 9295 p_table_footer: 9296 00005AE7 3D3D3D3D3D3D3D3D3D- db "================================================================================" 9296 00005AF0 3D3D3D3D3D3D3D3D3D- 9296 00005AF9 3D3D3D3D3D3D3D3D3D- 9296 00005B02 3D3D3D3D3D3D3D3D3D- 9296 00005B0B 3D3D3D3D3D3D3D3D3D- 9296 00005B14 3D3D3D3D3D3D3D3D3D- 9296 00005B1D 3D3D3D3D3D3D3D3D3D- 9296 00005B26 3D3D3D3D3D3D3D3D3D- 9296 00005B2F 3D3D3D3D3D3D3D3D 9297 00005B37 0D0A00 db 0Dh,0Ah,0 9298 9299 mbr_editing_options: 9300 00005B3A 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9301 00005B3E 4D4252205061727469- db "MBR Partition Table Editing Options:" 9301 00005B47 74696F6E205461626C- 9301 00005B50 652045646974696E67- 9301 00005B59 204F7074696F6E733A 9302 00005B62 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9303 00005B66 20202020202020312E- db " 1. Create Partition", 0Dh, 0Ah 9303 00005B6F 204372656174652050- 9303 00005B78 6172746974696F6E0D- 9303 00005B81 0A 9304 00005B82 20202020202020322E- db " 2. Set Active Partition", 0Dh, 0Ah 9304 00005B8B 205365742041637469- 9304 00005B94 766520506172746974- 9304 00005B9D 696F6E0D0A 9305 00005BA2 20202020202020332E- db " 3. Delete Partition", 0Dh, 0Ah 9305 00005BAB 2044656C6574652050- 9305 00005BB4 6172746974696F6E0D- 9305 00005BBD 0A 9306 00005BBE 20202020202020342E- db " 4. Write Current Partition Table", 0Dh, 0Ah, 0 9306 00005BC7 205772697465204375- 9306 00005BD0 7272656E7420506172- 9306 00005BD9 746974696F6E205461- 9306 00005BE2 626C650D0A00 9307 9308 enter_option_number_msg: 9309 00005BE8 0D0A db 0Dh, 0Ah 9310 00005BEA 456E74657220746865- db "Enter the option number or press ESC to exit ...", 0Dh, 0Ah 9310 00005BF3 206F7074696F6E206E- 9310 00005BFC 756D626572206F7220- 9310 00005C05 707265737320455343- 9310 00005C0E 20746F206578697420- 9310 00005C17 2E2E2E0D0A 9311 ;db 0Dh, 0Ah, 0 9312 00005C1C 00 db 0 9313 9314 msg_zero_partition_size: ; 19/02/2019 9315 00005C1D 0D0A db 0Dh, 0Ah 9316 00005C1F 506172746974696F6E- db "Partition size input must not be ZERO !", 0Dh, 0Ah 9316 00005C28 2073697A6520696E70- 9316 00005C31 7574206D757374206E- 9316 00005C3A 6F74206265205A4552- 9316 00005C43 4F20210D0A 9317 00005C48 285072657373204553- db "(Press ESC to exit or press another key to retry..)", 0Dh, 0Ah 9317 00005C51 4320746F2065786974- 9317 00005C5A 206F72207072657373- 9317 00005C63 20616E6F7468657220- 9317 00005C6C 6B657920746F207265- 9317 00005C75 7472792E2E290D0A 9318 00005C7D 00 db 0 9319 9320 msg_empty_pt: 9321 00005C7E 0D0A db 0Dh, 0Ah 9322 00005C80 456D70747920706172- db "Empty partition table !", 0Dh, 0Ah 9322 00005C89 746974696F6E207461- 9322 00005C92 626C6520210D0A 9323 00005C99 28412076616C696420- db "(A valid partition must be created at first..)", 0Dh, 0Ah 9323 00005CA2 706172746974696F6E- 9323 00005CAB 206D75737420626520- 9323 00005CB4 637265617465642061- 9323 00005CBD 742066697273742E2E- 9323 00005CC6 290D0A 9324 00005CC9 00 db 0 9325 9326 msg_full_pt: 9327 00005CCA 0D0A db 0Dh, 0Ah 9328 00005CCC 546865726520697320- db "There is not a free partition table entry ", 0 9328 00005CD5 6E6F74206120667265- 9328 00005CDE 652070617274697469- 9328 00005CE7 6F6E207461626C6520- 9328 00005CF0 656E7472792000 9329 msg_to_create_new_p: 9330 00005CF7 746F20637265617465- db "to create a new partition !", 0Dh, 0Ah 9330 00005D00 2061206E6577207061- 9330 00005D09 72746974696F6E2021- 9330 00005D12 0D0A 9331 00005D14 00 db 0 9332 msg_no_free_space: 9333 00005D15 0D0A db 0Dh, 0Ah 9334 00005D17 546865726520697320- db "There is not (enough) free space ", 0 9334 00005D20 6E6F742028656E6F75- 9334 00005D29 676829206672656520- 9334 00005D32 73706163652000 9335 9336 msg_enter_pn_to_del: 9337 00005D39 0D0A db 0Dh, 0Ah 9338 00005D3B 456E74657220706172- db "Enter partition number to delete: " 9338 00005D44 746974696F6E206E75- 9338 00005D4D 6D62657220746F2064- 9338 00005D56 656C6574653A20 9339 chr_del_pnum1: 9340 00005D5D 00 db 0 9341 00005D5E 0D0A00 db 0Dh, 0Ah, 0 9342 9343 msg_delete_partition_q: 9344 00005D61 0D0A db 0Dh, 0Ah 9345 00005D63 5741524E494E472120- db "WARNING! All of data in the selected partition will be lost", 0Dh, 0Ah 9345 00005D6C 416C6C206F66206461- 9345 00005D75 746120696E20746865- 9345 00005D7E 2073656C6563746564- 9345 00005D87 20706172746974696F- 9345 00005D90 6E2077696C6C206265- 9345 00005D99 206C6F73740D0A 9346 00005DA0 202020202020202020- db " after you write changed partition table to disk !!", 0Dh, 0Ah 9346 00005DA9 616674657220796F75- 9346 00005DB2 207772697465206368- 9346 00005DBB 616E67656420706172- 9346 00005DC4 746974696F6E207461- 9346 00005DCD 626C6520746F206469- 9346 00005DD6 736B2021210D0A 9347 00005DDD 0D0A db 0Dh, 0Ah 9348 00005DDF 446F20796F75207761- db "Do you want to delete PARTITION " 9348 00005DE8 6E7420746F2064656C- 9348 00005DF1 657465205041525449- 9348 00005DFA 54494F4E20 9349 chr_del_pnum2: 9350 00005DFF 30 db '0' 9351 00005E00 203F2028592F4E2920- db ' ? (Y/N) ', 0 9351 00005E09 00 9352 9353 _msg_YES: 9354 00005E0A 20 db 20h 9355 msg_YES: 9356 00005E0B 5945532000 db 'YES ', 0 9357 _msg_NO: 9358 00005E10 20 db 20h 9359 msg_NO: 9360 00005E11 4E4F2000 db 'NO ', 0 9361 9362 ; 11/02/2019 9363 msg_write_masterboot_sector: 9364 00005E15 0D0A db 0Dh, 0Ah 9365 00005E17 577269746520437572- db "Write Current Partition Table:" 9365 00005E20 72656E742050617274- 9365 00005E29 6974696F6E20546162- 9365 00005E32 6C653A 9366 00005E35 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9367 00005E39 20312E205772697465- db " 1. Write Partition Table only", 0Dh, 0Ah 9367 00005E42 20506172746974696F- 9367 00005E4B 6E205461626C65206F- 9367 00005E54 6E6C790D0A 9368 00005E59 20322E205772697465- db " 2. Write Partition Table and Singlix Master Boot Code", 0Dh, 0Ah 9368 00005E62 20506172746974696F- 9368 00005E6B 6E205461626C652061- 9368 00005E74 6E642053696E676C69- 9368 00005E7D 78204D617374657220- 9368 00005E86 426F6F7420436F6465- 9368 00005E8F 0D0A 9369 enter_opt_num_cancel_msg: 9370 00005E91 0D0A db 0Dh, 0Ah 9371 00005E93 456E74657220746865- db "Enter the option number or press ESC to cancel ...", 0 9371 00005E9C 206F7074696F6E206E- 9371 00005EA5 756D626572206F7220- 9371 00005EAE 707265737320455343- 9371 00005EB7 20746F2063616E6365- 9371 00005EC0 6C202E2E2E00 9372 9373 msg_writing_ptable: 9374 00005EC6 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9375 00005ECA 57726974696E672070- db "Writing partition table on disk ... ", 0 9375 00005ED3 6172746974696F6E20- 9375 00005EDC 7461626C65206F6E20- 9375 00005EE5 6469736B202E2E2E20- 9375 00005EEE 00 9376 _msg_OK: 9377 ;db 7 9378 00005EEF 0D0A db 0Dh, 0Ah 9379 00005EF1 4F4B2021 db "OK !" 9380 00005EF5 0D0A00 db 0Dh, 0Ah, 0 9381 9382 option_input: 9383 00005EF8 205B205D00 db ' [ ]', 0 9384 9385 msg_enter_pn_to_act: 9386 00005EFD 0D0A db 0Dh, 0Ah 9387 00005EFF 456E74657220706172- db "Enter partition number to set as active: ", 0 9387 00005F08 746974696F6E206E75- 9387 00005F11 6D62657220746F2073- 9387 00005F1A 657420617320616374- 9387 00005F23 6976653A2000 9388 9389 ;trdos386_disk_chs_header: 9390 retrodos5_disk_chs_header: 9391 00005F29 0D0A db 0Dh, 0Ah 9392 ;db " TRDOS 386 (SINGLIX) HARD DISK IMAGE " 9393 ; 04/05/2024 9394 00005F2B 202020202020202020- db " RETRO DOS V5 HARD DISK IMAGE " 9394 00005F34 202020202020202020- 9394 00005F3D 202020202020205245- 9394 00005F46 54524F20444F532056- 9394 00005F4F 352048415244204449- 9394 00005F58 534B20494D41474520- 9394 00005F61 202020202020202020- 9394 00005F6A 202020202020202020- 9394 00005F73 2020202020202020 9395 00005F7B 00 db 0 9396 9397 disk_chs_header: 9398 00005F7C 0D0A db 0Dh, 0Ah 9399 00005F7E 202020202020202020- db " HARD DISK IMAGE " 9399 00005F87 202020202020202020- 9399 00005F90 202020202020202020- 9399 00005F99 202020202048415244- 9399 00005FA2 204449534B20494D41- 9399 00005FAB 474520202020202020- 9399 00005FB4 202020202020202020- 9399 00005FBD 202020202020202020- 9399 00005FC6 2020202020202020 9400 00005FCE 00 db 0 9401 9402 msg_partition_size_limit: 9403 00005FCF 0D0A db 0Dh, 0Ah 9404 00005FD1 506172746974696F6E- db "Partition size overs available free space !" 9404 00005FDA 2073697A65206F7665- 9404 00005FE3 727320617661696C61- 9404 00005FEC 626C65206672656520- 9404 00005FF5 73706163652021 9405 00005FFC 0D0A db 0Dh, 0Ah 9406 00005FFE 4D61782E2061766169- db "Max. available free space is ", 0 9406 00006007 6C61626C6520667265- 9406 00006010 652073706163652069- 9406 00006019 732000 9407 9408 msg_partition_size_limit_r: 9409 0000601C 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9410 00006020 28507265737320454E- db "(Press ENTER to use all of available space or press ESC key to retry..) " 9410 00006029 54455220746F207573- 9410 00006032 6520616C6C206F6620- 9410 0000603B 617661696C61626C65- 9410 00006044 207370616365206F72- 9410 0000604D 207072657373204553- 9410 00006056 43206B657920746F20- 9410 0000605F 72657472792E2E2920 9411 00006068 000A00 db 0D, 0Ah, 0 9412 9413 msg_cylinders: 9414 0000606B 2063796C696E646572- db " cylinders", 0 9414 00006074 7300 9415 msg_sectors: 9416 00006076 20736563746F727300 db " sectors", 0 9417 9418 ; 02/03/2019 9419 msg_megabytes: 9420 0000607F 206D65676162797465 db " megabyte" 9421 msg_megabytes_s: 9422 00006088 0000 db 0, 0 9423 9424 msg_inv_pte: 9425 0000608A 0D0A db 0Dh, 0Ah 9426 0000608C 496E76616C69642070- db "Invalid partition table entry ! (P" 9426 00006095 6172746974696F6E20- 9426 0000609E 7461626C6520656E74- 9426 000060A7 72792021202850 9427 000060AE 3F290D0A inv_pte_num: db "?)", 0Dh, 0Ah 9428 000060B2 28507265737320454E- db "(Press ENTER to DELETE or press ESC to EXIT..)" 9428 000060BB 54455220746F204445- 9428 000060C4 4C455445206F722070- 9428 000060CD 726573732045534320- 9428 000060D6 746F20455849542E2E- 9428 000060DF 29 9429 000060E0 0D0A00 db 0Dh, 0Ah, 0 9430 9431 msg_ext_partition_exists: 9432 000060E3 457874656E64656420- db "Extended partition already exists !" 9432 000060EC 706172746974696F6E- 9432 000060F5 20616C726561647920- 9432 000060FE 6578697374732021 9433 00006106 0D0A00 db 0Dh, 0Ah, 0 9434 9435 msg_defective_pt: 9436 00006109 0D0A db 0Dh, 0Ah 9437 0000610B 446566656374697665- db "Defective partition table !", 0 9437 00006114 20706172746974696F- 9437 0000611D 6E207461626C652021- 9437 00006126 00 9438 9439 ; 27/02/2019 9440 msg_ext_part_del_error: 9441 00006127 0D0A db 0Dh, 0Ah 9442 00006129 457874656E64656420- db "Extended partition must be deleted after logical drive(s) !" 9442 00006132 706172746974696F6E- 9442 0000613B 206D75737420626520- 9442 00006144 64656C657465642061- 9442 0000614D 66746572206C6F6769- 9442 00006156 63616C206472697665- 9442 0000615F 2873292021 9443 00006164 0D0A00 db 0Dh, 0Ah, 0 9444 9445 msg_cancel_continue: 9446 00006167 285072657373204553- db "(Press ESC to cancel or press another key to continue..)" 9446 00006170 4320746F2063616E63- 9446 00006179 656C206F7220707265- 9446 00006182 737320616E6F746865- 9446 0000618B 72206B657920746F20- 9446 00006194 636F6E74696E75652E- 9446 0000619D 2E29 9447 0000619F 0D0A00 db 0Dh, 0Ah, 0 9448 9449 msg_delete_ldd: 9450 000061A2 0D0A db 0Dh, 0Ah 9451 000061A4 0D0A db 0Dh, 0Ah 9452 000061A6 44656C657465204C6F- db "Delete Logical (DOS) Drive:" 9452 000061AF 676963616C2028444F- 9452 000061B8 53292044726976653A 9453 000061C1 0D0A db 0Dh, 0Ah 9454 000061C3 50726573732044454C- db "Press DELETE key to delete logical disk partition " 9454 000061CC 455445206B65792074- 9454 000061D5 6F2064656C65746520- 9454 000061DE 6C6F676963616C2064- 9454 000061E7 69736B207061727469- 9454 000061F0 74696F6E20 9455 000061F5 3F2E lddp_num: db "?." 9456 000061F7 0D0A00 db 0Dh, 0Ah, 0 9457 9458 msg_delete_ext_part: 9459 000061FA 0D0A db 0Dh, 0Ah 9460 000061FC 0D0A db 0Dh, 0Ah 9461 000061FE 44656C657465204578- db "Delete Extended (DOS) Partition:" 9461 00006207 74656E646564202844- 9461 00006210 4F5329205061727469- 9461 00006219 74696F6E3A 9462 0000621E 0D0A db 0Dh, 0Ah 9463 00006220 507265737320454E54- db "Press ENTER to delete or press ESC to cancel.." 9463 00006229 455220746F2064656C- 9463 00006232 657465206F72207072- 9463 0000623B 657373204553432074- 9463 00006244 6F2063616E63656C2E- 9463 0000624D 2E 9464 0000624E 0D0A00 db 0Dh, 0Ah, 0 9465 9466 str_display_ebr_pt: 9467 00006251 285072657373205350- db "(Press SPACE to edit EXTENDED Partition Table)", 0Dh, 0Ah, 0 9467 0000625A 41434520746F206564- 9467 00006263 697420455854454E44- 9467 0000626C 454420506172746974- 9467 00006275 696F6E205461626C65- 9467 0000627E 290D0A00 9468 9469 ebr_editing_options: 9470 00006282 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9471 00006286 457874656E64656420- db "Extended Partition Table Editing Options:" 9471 0000628F 506172746974696F6E- 9471 00006298 205461626C65204564- 9471 000062A1 6974696E67204F7074- 9471 000062AA 696F6E733A 9472 000062AF 0D0A0D0A db 0Dh, 0Ah, 0Dh, 0Ah 9473 000062B3 20202020202020312E- db " 1. Create Logical DOS Drive", 0Dh, 0Ah 9473 000062BC 20437265617465204C- 9473 000062C5 6F676963616C20444F- 9473 000062CE 532044726976650D0A 9474 000062D7 20202020202020322E- db " 2. Delete Logical (DOS) Drive(s)",0Dh, 0Ah, 0 9474 000062E0 2044656C657465204C- 9474 000062E9 6F676963616C202844- 9474 000062F2 4F5329204472697665- 9474 000062FB 2873290D0A00 9475 9476 msg_delete_ldd_q: 9477 00006301 0D0A db 0Dh, 0Ah 9478 00006303 5741524E494E47210D- db "WARNING!", 0Dh, 0Ah 9478 0000630C 0A 9479 0000630D 416C6C206F66206461- db "All of data in logical (DOS) drive(s) will be lost !!", 0Dh, 0Ah 9479 00006316 746120696E206C6F67- 9479 0000631F 6963616C2028444F53- 9479 00006328 292064726976652873- 9479 00006331 292077696C6C206265- 9479 0000633A 206C6F73742021210D- 9479 00006343 0A 9480 00006344 0D0A db 0Dh, 0Ah 9481 00006346 446F20796F75207761- db "Do you want to continue ? (Y/N) ", 0 9481 0000634F 6E7420746F20636F6E- 9481 00006358 74696E7565203F2028- 9481 00006361 592F4E292000 9482 9483 msg_create_ldd_max_error: 9484 00006367 0D0A db 0Dh, 0Ah 9485 00006369 50726F6772616D206C- db "Program limit for logical dos drive count is 4 !" 9485 00006372 696D697420666F7220- 9485 0000637B 6C6F676963616C2064- 9485 00006384 6F7320647269766520- 9485 0000638D 636F756E7420697320- 9485 00006396 342021 9486 00006399 0D0A00 db 0Dh, 0Ah, 0 9487 9488 msg_c_ldd_unused_warning: 9489 0000639C 0D0A db 0Dh, 0Ah 9490 0000639E 546865726520697320- db "There is unused extended partition space after logical dos drive 4 !" 9490 000063A7 756E75736564206578- 9490 000063B0 74656E646564207061- 9490 000063B9 72746974696F6E2073- 9490 000063C2 706163652061667465- 9490 000063CB 72206C6F676963616C- 9490 000063D4 20646F732064726976- 9490 000063DD 6520342021 9491 000063E2 0D0A db 0Dh, 0Ah 9492 000063E4 285072657373204553- db "(Press ESC to add unused space or press ENTER to continue.)" 9492 000063ED 4320746F2061646420- 9492 000063F6 756E75736564207370- 9492 000063FF 616365206F72207072- 9492 00006408 65737320454E544552- 9492 00006411 20746F20636F6E7469- 9492 0000641A 6E75652E29 9493 0000641F 0D0A00 db 0Dh, 0Ah, 0 9494 9495 msg_create_ldd_s: 9496 00006422 53656C65637420616E- db "Select an option to set logical dos drive size: " 9496 0000642B 206F7074696F6E2074- 9496 00006434 6F20736574206C6F67- 9496 0000643D 6963616C20646F7320- 9496 00006446 64726976652073697A- 9496 0000644F 653A20 9497 00006452 0D0A db 0Dh, 0Ah 9498 00006454 0D0A db 0Dh, 0Ah 9499 00006456 202043292043796C69- db " C) Cylinder count", 0Dh, 0Ah 9499 0000645F 6E64657220636F756E- 9499 00006468 740D0A 9500 0000646B 2020252920566F6C75- db " %) Volume percentage (##%)", 0Dh, 0Ah 9500 00006474 6D652070657263656E- 9500 0000647D 746167652028232325- 9500 00006486 290D0A 9501 00006489 20204D29204D656761- db " M) Mega bytes (MB, 2*1024*M sectors)", 0Dh, 0Ah 9501 00006492 20627974657320284D- 9501 0000649B 422C20322A31303234- 9501 000064A4 2A4D20736563746F72- 9501 000064AD 73290D0A 9502 000064B1 202047292047696761- db " G) Giga bytes (GB, 2*1024*1024*G sectors)", 0Dh, 0Ah 9502 000064BA 206279746573202847- 9502 000064C3 422C20322A31303234- 9502 000064CC 2A313032342A472073- 9502 000064D5 6563746F7273290D0A 9503 000064DE 0D0A db 0Dh, 0Ah 9504 000064E0 507265737320535041- db "Press SPACE to use entire space or press ENTER to set Megabytes .. ", 0 9504 000064E9 434520746F20757365- 9504 000064F2 20656E746972652073- 9504 000064FB 70616365206F722070- 9504 00006504 7265737320454E5445- 9504 0000650D 5220746F2073657420- 9504 00006516 4D6567616279746573- 9504 0000651F 202E2E2000 9505 9506 msg_c_part_error: 9507 00006524 0D0A db 0Dh, 0Ah 9508 00006526 4E6F20667265652073- db "No free space for a new primary partition", 0Dh, 0Ah, 0 9508 0000652F 7061636520666F7220- 9508 00006538 61206E657720707269- 9508 00006541 6D6172792070617274- 9508 0000654A 6974696F6E0D0A00 9509 msg_c_ldd_error: 9510 00006552 616E64206C6F676963- db "and logical dos drives over program limit (4) !", 0Dh, 0Ah, 0 9510 0000655B 616C20646F73206472- 9510 00006564 69766573206F766572- 9510 0000656D 2070726F6772616D20- 9510 00006576 6C696D697420283429- 9510 0000657F 20210D0A00 9511 msg_c_ldd_q: 9512 00006584 0D0A db 0Dh, 0Ah 9513 00006586 446F20796F75207761- db "Do you want to create logical dos drive in extended dos partition " 9513 0000658F 6E7420746F20637265- 9513 00006598 617465206C6F676963- 9513 000065A1 616C20646F73206472- 9513 000065AA 69766520696E206578- 9513 000065B3 74656E64656420646F- 9513 000065BC 732070617274697469- 9513 000065C5 6F6E20 9514 000065C8 3F2028592F4E2900 db '? (Y/N)', 0 9515 9516 msg_c_ldd_nofspc_error: 9517 000065D0 0D0A db 0Dh, 0Ah 9518 000065D2 4E6F20667265652073- db "No free space for a new logical dos drive !", 0Dh, 0Ah, 0 9518 000065DB 7061636520666F7220- 9518 000065E4 61206E6577206C6F67- 9518 000065ED 6963616C20646F7320- 9518 000065F6 647269766520210D0A- 9518 000065FF 00 9519 9520 ;pt_positions: 9521 ;n_pos: dw 30 ; 1 byte 9522 ;p_pos: dw 7 ; 1 byte 9523 ;s_pos: dw 9 ; 2+1 bytes 9524 ;bh_pos: dw 13 ; 2+1 bytes 9525 ;bs_pos: dw 17 ; 2+1 bytes 9526 ;bc_pos: dw 21 ; 2+1 bytes 9527 ;fs_pos: dw 25 ; 2+1 bytes 9528 ;eh_pos: dw 29 ; 2+1 bytes 9529 ;es_pos: dw 33 ; 2+1 bytes 9530 ;ec_pos: dw 37 ; 2+1 bytes 9531 ;rs_pos: dw 42 ; 7 bytes 9532 ;ns_pos: dw 52 ; 7 bytes 9533 ;fsx_pos: dw 61 ; 14 bytes 9534 9535 align 4 9536 9537 msg_sectors_crlf: 9538 00006600 20736563746F72 db " sector" 9539 msg_sectors_crlf_s: 9540 00006607 73 db "s" 9541 00006608 0D0A00 db 0Dh, 0Ah, 0 9542 9543 vname_length: 9544 0000660B 00 db 0 ; 05/01/2018 9545 9546 bs_oem_name: 9547 ;db 'TRDOS2.0', 0 9548 ; 04/05/2024 9549 0000660C 524554524F444F5300 db 'RETRODOS', 0 9550 9551 00006615 90 align 2 9552 9553 no_name: 9554 00006616 4E4F204E414D452020- db 'NO NAME ', 0 9554 0000661F 202000 9555 9556 align 2 9557 9558 FDFORMAT_SECBUFFER: 9559 HDFORMAT_SECBUFFER: 9560 00006622 F6 times 512 db 0F6h 9561 HDFORMAT_FSINFO_BUFF: 9562 00006822 52526141 dd 41615252h ; FSI_LeadSig 9563 00006826 00 times 480 db 0 ; FSI_Reserved1 9564 00006A06 72724161 dd 61417272h ; FSI_StrucSig 9565 00006A0A FFFFFFFF dd 0FFFFFFFFh ; FSI_Free_Count 9566 00006A0E 02000000 dd 000000002h ; FSI_Nxt_Free 9567 00006A12 00 times 12 db 0 ; FSI_Reserved2 9568 00006A1E 000055AA dd 0AA550000h ; FSI_TrailSig 9569 9570 SizeOfFile equ $-100 9571 9572 ; 03/02/2019 9573 9574 ;============================================================================= 9575 ; uninitialized data 9576 ;============================================================================= 9577 9578 bss_start: 9579 9580 ABSOLUTE bss_start 9581 9582 alignb 2 9583 00006A22 ???? old_sp: resw 1 9584 9585 HDFORMAT_FATBUFFER: 9586 FDFORMAT_FATBUFFER: 9587 FDFORMAT_FATBUFFER_S9: ; temporary ! 9588 HDFORMAT_EMPTY_BUFF: 9589 00006A24 resb 512 9590 9591 00006C24 ???????? data_start: resd 1 9592 00006C28 ???????? data_sectors: resd 1 9593 00006C2C ???????? cluster_count: resd 1 9594 00006C30 ???? root_dir_secs: resw 1 9595 00006C32 ???? format_percent: resw 1 9596 00006C34 ?? prev_percent: resb 1 9597 00006C35 ?? rsvdbyte: resb 1 9598 9599 00006C36 ???? alignb 4 9600 9601 ; 05/01/2018 9602 00006C38 fs_volume_name: resb 64 9603 00006C78 ???????? fs_volume_serial: resd 1 9604 00006C7C ???? DAT_FFBit: resw 1 9605 00006C7E ???? DAT_FFSector: resw 1 9606 ;resw 1 9607 00006C80 ???? DAT_LFBit: resw 1 9608 00006C82 ???? DAT_LFSector: resw 1 9609 ;resw 1 9610 9611 ;alignb 4 9612 9613 FS_MAT_Buffer: ; TRFS1 Master Allocation Table (05/01/2018) 9614 00006C84 ?????? MAT_Sign: resb 3 ; Offset 0 ; 'MAT' 9615 00006C87 ?? MAT_Version: resb 1 ; 3 ; 0 9616 00006C88 ???????? MAT_VolumeSize: resd 1 ; 4 ; FS1 Volume Size 9617 00006C8C ???????? MAT_BeginSector: resd 1 ; 8 ; FS1 Start Sector 9618 00006C90 ???????? DAT_Address: resd 1 ; 12 ; Offset (=2) 9619 00006C94 ???????? DAT_SectorCount: resd 1 ; 16 9620 00006C98 ???????? MAT_FreeSectors: resd 1 ; 20 9621 00006C9C ???????? MAT_FirstFreeSector: resd 1 ; 24 9622 ;MAT_OS_Reserved: 9623 ; resb 9 9624 ;MAT_Unused: 9625 ; resb 112 9626 FS_DAT_Buffer: ; TRFS1 Disk Allocation Table (05/01/2018) 9627 FS_RDT_Buffer: ; TRFS1 Root Directory Description Table (05/01/2018) 9628 00006CA0 resb 512 9629 ;alignb 4 9630 9631 ; (TR-DOS 386 compatible) Hard Disk (image) parameters 9632 9633 00006EA0 ???????? total_sectors: resd 1 9634 00006EA4 ???????? pType: resb 4 9635 00006EA8 ???????? file_size: resd 1 9636 00006EAC ???????? pp_StartSector: resd 1 9637 00006EB0 ???????? pp_Sectors: resd 1 9638 00006EB4 ?? wholedisk: resb 1 9639 00006EB5 ?? pp_type: resb 1 ; Primary partition type (for this program) 9640 00006EB6 ?? pp_type_user: resb 1 9641 00006EB7 ?? chs_focus: resb 1 9642 00006EB8 ???????? pSize_temp: resd 1 9643 00006EBC ???????? pSize_multiplier: resd 1 9644 00006EC0 ?? pSize_maxdigits: resb 1 9645 00006EC1 ?? pSize_digitpos: resb 1 9646 msg_psize_unit: 9647 00006EC2 ???? pSize_unit: resw 1 9648 00006EC4 ?? resb 1 9649 00006EC5 ?????? reserved_bytes: resb 3 ; for 11 bytes of numbers 9650 msg_partition_sectors: 9651 00006EC8 ???????????????? resb 8 9652 00006ED0 ?? resb 1 9653 00006ED1 ?? format_q: resb 1 ; 03/02/2018 9654 9655 ;alignb 2 9656 00006ED2 ?? pType_pos: resb 1 9657 00006ED3 ?? pType_num: resb 1 9658 00006ED4 ?? resb 1 9659 ;cylinder_boundary: 9660 00006ED5 ?? resb 1 9661 00006ED6 ???? last_cylinder: resw 1 9662 9663 alignb 2 9664 9665 00006ED8 ?? GetChar: resb 1 ; 11/02/2019 9666 00006ED9 ?? existingfile: resb 1 ; 12/02/2019 9667 9668 00006EDA ???? min_sectors: resw 1 ; 08/02/2019 9669 00006EDC ???? pp_StartCylinder: resw 1 9670 00006EDE ???? pp_EndCylinder: resw 1 9671 9672 00006EE0 ???????? ppn_Sectors: resd 1 ; 09/02/2019 9673 9674 00006EE4 ???? input_col: resw 1 9675 00006EE6 ?? No: resb 1 9676 00006EE7 ?? Yes: resb 1 9677 9678 ; 26/02/2019 9679 00006EE8 ?? ldrives: resb 1 9680 9681 00006EE9 ?? sort_1: resb 1 9682 00006EEA ???????? sort: resb 4 9683 9684 ;max_sector: resb 8 9685 ebr_buffer: ; 26/02/2019 9686 00006EEE boot_record: resb 512 9687 9688 000070EE ?? valid_input: resb 1 9689 000070EF ?? resb 1 9690 9691 ; 26/02/2019 9692 000070F0 ???????? ep_StartSector: resd 1 9693 000070F4 ???????? ep_EndSector: resd 1 9694 000070F8 ???????? ep_Size: resd 1 9695 9696 ; 10/02/2019 9697 000070FC ???????? valid_ppnums: resb 4 9698 9699 00007100 ???? _i_: resw 1 9700 9701 00007102 ???? freespace_count: resw 1 9702 00007104 ?? last_found_partition: resb 1 9703 00007105 ?? p_type: resb 1 9704 9705 p_sorted: 9706 00007106 ?? resb 1 9707 ep_sorted: 9708 00007107 ?? resb 1 9709 9710 00007108 ?? _e_: resb 1 9711 9712 act_part_num: 9713 cre_part_num: 9714 00007109 ?? del_part_num: resb 1 ; 10/02/2019 9715 9716 alignb 2 9717 9718 0000710A pte_row: resb 80 9719 9720 0000715A ?? _zero_: resb 1 9721 9722 ;alignb 2 9723 9724 0000715B ?? resb 1 9725 9726 ; 24/02/2019 9727 goodpte: 9728 0000715C ?? resb 1 9729 0000715D ?? badpte: resb 1 9730 9731 bss_clear_end: ; 15/02/2019 9732 9733 ; PARTITION DATA STRUCTURE 9734 ; 4 partitions 9735 ; 18 byte partition data structure per partition 9736 ; 72 bytes (4*18) 9737 9738 0000715E ?? part_table_boot_ind: resb 1 9739 0000715F ?? part_table_start_head: resb 1 9740 00007160 ?? part_table_start_sector: resb 1 9741 00007161 ???? part_table_start_cyl: resw 1 9742 00007163 ?? part_table_sys_id: resb 1 9743 00007164 ?? part_table_end_head: resb 1 9744 00007165 ?? part_table_end_sector: resb 1 9745 00007166 ???? part_table_end_cyl: resw 1 9746 00007168 ???? part_table_rel_sec_lw: resw 1 9747 0000716A ???? part_table_rel_sec_hw: resw 1 9748 0000716C ???? part_table_num_sec_lw: resw 1 9749 0000716E ???? part_table_num_sec_hw: resw 1 9750 9751 00007170 resb 54 ; 3*18 9752 9753 000071A6 ?? pcount: resb 1 9754 000071A7 ?? ppcount: resb 1 9755 000071A8 ?? apcount: resb 1 9756 000071A9 ?? epnumber: resb 1 9757 9758 ; LOGICAL PARTITION DATA STRUCTURE 9759 ; (for logical partitions in extended partition) 9760 9761 ; 1 extended partition 9762 ; 4 logical drives (18 bytes) 9763 ; 72 bytes (4*18) 9764 9765 000071AA ?? ext_table_boot_ind: resb 1 9766 000071AB ?? ext_table_start_head: resb 1 9767 000071AC ?? ext_table_start_sector: resb 1 9768 000071AD ???? ext_table_start_cyl: resw 1 9769 000071AF ?? ext_table_sys_id: resb 1 9770 000071B0 ?? ext_table_end_head: resb 1 9771 000071B1 ?? ext_table_end_sector: resb 1 9772 000071B2 ???? ext_table_end_cyl: resw 1 9773 000071B4 ???? ext_table_rel_sec_lw: resw 1 9774 000071B6 ???? ext_table_rel_sec_hw: resw 1 9775 000071B8 ???? ext_table_num_sec_lw: resw 1 9776 000071BA ???? ext_table_num_sec_hw: resw 1 9777 9778 000071BC resb 54 ; 3*18 9779 9780 fspc: ; 5*8 words (for free space calculations) 9781 9782 ; Space 1 - unused cylinders before partition 0 9783 ; Space 2 - unused cylinders between partition 0 & 1 9784 ; Space 3 - unused cylinders between partition 1 & 2 9785 ; Space 4 - unused cylinders between partition 2 & 3 9786 ; Space 5 - unused cylinders after partition 3 9787 9788 000071F2 ???? free_space.space: resw 1 9789 000071F4 ???? free_space.start: resw 1 9790 000071F6 ???? free_space.end: resw 1 9791 000071F8 ???? free_space.percent_unused: resw 1 9792 000071FA ???????? free_space.sectors_unused: resd 1 9793 000071FE ???????? free_space.startsector: resd 1 ; 13/02/2019 9794 ;resw 4*6 9795 00007202 resw 4*8 ; 13/02/2019 9796 9797 ; 18/02/2019 9798 00007242 ???? c_cylinder: resw 1 9799 00007244 ???? c_fspc_offset: resw 1 9800 00007246 ?? cylinder_boundary: resb 1 9801 ;c_gap: resb 1 9802 00007247 ?? resb 1 9803 9804 ; 27/02/2019 9805 00007248 ldd_start: resd 4 9806 ; 03/03/2019 9807 00007258 ldd_size: resd 4 9808 9809 ; 25/02/2019 9810 00007268 ???? pte_address: resw 1 9811 ; 02/03/2019 9812 0000726A ???? lcylinders: resw 1 9813 9814 ;bss_clear_end: ; 18/02/2019 ; temporary 9815 9816 bss_end: