Re: DRL updated!
Bart Oldeman <[email protected]>
| Newsgroups | gmane.os.freedos.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 23 Oct 2002, Arkady V.Belousov wrote: > 23-ïËÔ-2002 11:06 [email protected] (Aitor Santamaria Merino) wrote to > [email protected]: > > ASM> ??? Does this mean that EMM386 (or other VMM monitor) would not let me > ASM> run self-modifying code?? > > It can't prevent this! Don't know if it may trap write access through > CS (probably not), but it can't trap write access through DS, which may > equal to CS. V86 mode can only trap write accesses to individual (usually 4K) pages, not through the name of the segment. But if a VMM monitor wants to let DOS programs run it should not write protect any normal DOS memory (but might protect emulated ROMs, video memory and so on). There is however one problem with SMC that wasn't mentioned: in the following self-modifying code: mov word [cs:label+1], 1 label: mov bx, 0 you might get 1 in bx on some CPU's (386, 486) and 0 in bx on others, because "mov bx, 0" is already in the prefetch queue. You'd have to avoid that by doing a jump or call, like this. mov word [cs:label+1], 1 jmp short label label: mov bx, 0 Earlier CPUs don't have that problem, and later ones (Pentium xxx) neither. Although on modern CPUs you get a quite severe performance penalty because the instruction cache and prefetch queues are automatically flushed whenever a write like the above occurs. Of course, when you build up code in the data segment or on the stack (Jave JIT compilers need to do that) you simply have to jump to it so you automatically avoid the problem. Bart