Self-modifying code: Difference between revisions

Content deleted Content added
K1767 (talk | contribs)
Fix a grammar error.
K1767 (talk | contribs)
Fix a typing mistake and make another phrase slightly clearer.
Line 220:
==Notes==
{{reflist|group="nb"|refs=
{{r|group="nb"|name="NB_DR-DOS_386"|r=For example, when running on [[i386|386]] or higher processors, later [[Novell DOS 7]] updates<!-- not the early updates, and not OpenDOS 7.01 --> as well as [[DR-DOS 7.02]]<!-- actually since Matthias R. Paul's Alpha 1 --> and higher will dynamically replace some default sequences of 16-bit <code>REP MOVSW</code> ("copy words") instructions in the kernel's runtime image by 32-bit <code>REP MOVSD</code> ("copy double-words") instructions when copying data from one memory ___location to another (and half the count of necessary repetitions) in order to speed up disk data transfers. [[Edge case]]s such as odd counts are taken care offof.<ref name="Caldera_1997_DOSSRC"/><ref name="Paul_1997_OD-A3"/>}}
{{r|group="nb"|name="NB_DR-DOS_707"|r=As an example, the [[DR-DOS]] [[master boot record|MBR]]s and [[volume boot record|boot sector]]s (which also hold the [[partition table]] and [[BIOS Parameter Block]], leaving less than 446<!-- MBR --> respectively 423<!-- 512-87-2 (ignoring the 3-byte-jump which can be counted as code) in the case of FAT32, a bit more with FAT12/FAT16 --> bytes for the code) were traditionally able to locate the boot file in the [[FAT12]] or [[FAT16]] file system by themselves and load it into memory as a whole, in contrast to their [[MS-DOS]]/[[PC&nbsp;DOS]] counterparts, which instead relied on the system files to occupy the first two directory entries in the file system and the first three sectors of [[IBMBIO.COM]] to be stored at the start of the data area in contiguous sectors containing a secondary loader to load the remainder of the file into memory (requiring [[SYS (DOS command)|SYS]] to take care of all these conditions). When [[FAT32]] and [[logical block addressing|LBA]] support was added, [[Microsoft]] even switched to require [[Intel 80386|386]] instructions and split the boot code over two sectors for size reasons, which was nonot an option to follow for DR-DOS as it would have broken [[backward compatibility|backward]]- and cross-compatibility with other operating systems in [[multi-boot]] and [[chain load]] scenarios, as well as with older [[IBM PC compatible|PC]]s. Instead, the [[DR-DOS 7.07]] boot sectors resorted to self-modifying code, [[opcode]]-level programming in [[machine language]], controlled utilization of (documented) [[side effect (computer science)|side effect]]s, multi-level data/code [[instruction overlapping|overlapping]] and algorithmic [[fold (function)|fold]]ing techniques to still fit everything into a physical sector of only 512 bytes without giving up any of their extended functionality<!-- and adding some more -->.}}
{{r|group="nb"|name="NB_CHOICE"|r=Later versions of DOS (since version 6.0) introduced the external [[CHOICE (DOS command)|CHOICE]] command (in [[DR-DOS]]<!-- 6.0 and higher --> also the internal command and [[CONFIG.SYS]] directive [[SWITCH (CONFIG.SYS directive)|SWITCH]]), so, for this specific example application of a menu system, it was no longer necessary to refer to self-modifying batchjobs, however for other applications it continued to be a viable solution.}}
}}