Re: Jumping into middle of instruction
- From: "Wolfgang Kern" <spamtrap@xxxxxxxxxx>
- Date: Thu, 28 Feb 2008 15:59:56 +0100
Bob Masta wrote:
mybwpp asked:
Can we categorize this technique of jumping into middle ofNo, SMC is a different story.
instructions, as 'self modifying code'?
start:
; this works only in true RealMode!
cmp al,80h
jns L1:
mov word CS:[L2],9090h ;two NOPs
L1:
... ;put some code in here to avoid prefetched remains
mov ax...
add ax,cx
L2:
JC L3 ;this two bytes may become NOPS
...
How does Real Mode make a difference here?
You can't direct write to CodeSeg in protected mode.
I thought it only had to do with the processor architecture,
regarding the depth of the
prefetch queue and whether it was smart enough to know when to
invalidate the queue when you use short forward SMC.
Yes, but I encountered this prefetch issue also on modern CPUS.
On modern processors it's probably not a good idea to
depend upon a certain depth of prefetch queue, but in the
Olden Days (before CPUID) when there were only a few x86 CPUs and
they had known queue differences, you could identify the CPU by
its queue length. You modified code at known distances ahead,
and if the modifications were ignored you knew that those instructions
must have already been in the queue.
Right.
SMC is of rare use anyway, I use it only on video mode changes to
save on just minor different routines and make this 'variables'
to contants for speed reason.
To answer the OP, self-modifying code is anything that alters
the actual code. The jump-into-instruction leaves the code
unaltered, and just takes a different path through it.
Yeah.
__
wolfgang
.
- Follow-Ups:
- Re: Jumping into middle of instruction
- From: Bob Masta
- Re: Jumping into middle of instruction
- References:
- Jumping into middle of instruction
- From: mybwpp@xxxxxxxxxxxxxx
- Re: Jumping into middle of instruction
- From: Wolfgang Kern
- Re: Jumping into middle of instruction
- From: mybwpp@xxxxxxxxxxxxxx
- Re: Jumping into middle of instruction
- From: Wolfgang Kern
- Re: Jumping into middle of instruction
- From: Bob Masta
- Jumping into middle of instruction
- Prev by Date: Re: Jumping into middle of instruction
- Next by Date: Re: Jumping into middle of instruction
- Previous by thread: Re: Jumping into middle of instruction
- Next by thread: Re: Jumping into middle of instruction
- Index(es):
Relevant Pages
|