User:Johnburger/Demo/Pad/HardDisk
< User:Johnburger | Demo
Jump to navigation
Jump to search
A HardDisk image doesn't care how little or big it is, as long as it is an even multiple of Sector size. To that end the following has some round-up calculations, and then emits precisely the correct number of 00h
bytes to pad it to the next size up.
Demo/Pad/HardDisk.inc
;
; Pad/HardDisk.inc
;
; This file performs the necessary padding to generate a HardDisk image file.
; All of the hard work has been done: all we need to do is generate sufficient
; extra bytes to round the resultant output file to the next Sector Size.
SEGMENT HardDisk
; Take the current Size for the program, and round it UP to the next Sector.Size
HardDisk.Last EQU (Demo.Size + BIOS.Disk.Sector.Size - 1) & ~(BIOS.Disk.Sector.Size - 1)
HardDisk.Padding EQU HardDisk.Last - Demo.Size
TIMES HardDisk.Padding DB 00h
HardDisk.Size EQU $ - $$
%assign Demo.Size Demo.Size + HardDisk.Size