One that I wrote just then for use in a certain rounding (and granuality) situation:
inc eax
shr eax,2
adc eax,0
shl eax,2
Will round eax up to the nearest multiple of 4, if nesscery (ie wont round 4 up to 8).
I think this can be extened for other situations, ie if Ive allocated 34567 bytes of memory how much will of actualy been allocated becuase of the 4096 byte page granuality:
add eax,011111111111b (11 bits)
shr eax,12
adc eax,0
shl eax,12
But ive only tested the former version.
inc eax
shr eax,2
adc eax,0
shl eax,2
Will round eax up to the nearest multiple of 4, if nesscery (ie wont round 4 up to 8).
I think this can be extened for other situations, ie if Ive allocated 34567 bytes of memory how much will of actualy been allocated becuase of the 4096 byte page granuality:
add eax,011111111111b (11 bits)
shr eax,12
adc eax,0
shl eax,12
But ive only tested the former version.
Huh try this instead:
Mirno
add eax, 3
and eax, 0FFFFFFFCh
Mirno
A more general solution would be this:
add eax, R-1
and eax, -R
where R is the power of two you want to round up to.
add eax, R-1
and eax, -R
where R is the power of two you want to round up to.
my all time favorite:
mov eax, 0
break dependencies on eax :)
mov eax, 0
break dependencies on eax :)
MOV is not all time favorite :)
The AMD Athlon processor is able to avoid the false read
dependency on the XOR instruction.
dependency on the XOR instruction.
Pentium 4 processor provides special support to xor, sub, or pxor operations,
specifically when executed within the same register, recognizing that clearing a
register does not depend on the old value of the register.
specifically when executed within the same register, recognizing that clearing a
register does not depend on the old value of the register.
I have a p3 and that was just my all time favorite not the all time favorite. :)
stryker, you have luck with P3 :)
24281603.pdf
24281603.pdf
Pentium Pro and Pentium II processors provide special support to XOR a register with itself,
recognizing that clearing a register does not depend on the old value of the register.
recognizing that clearing a register does not depend on the old value of the register.
lol :grin:
This one terminates the current process on XP:
I dunno what it will do on the 95 family of windows.
not esp
int 3
I dunno what it will do on the 95 family of windows.
nop
sometimes adding a couple of this in a loop will increase the speed of an algorithm. :)
sometimes adding a couple of this in a loop will increase the speed of an algorithm. :)
*************
CLI
HLT
**************
Two bytes but powerful,
CLI
HLT
**************
Two bytes but powerful,
cli and hlt(I think) are both privileged instructions and both will cause an exception under NT -> XP
I have tested it on Windows 95 works 8-)
*********************
MOV AX,1681h
INT 21h ;Go to critical mode 8-)
*********************
Now I am not sure about this one, but I think that this will make Windows go into a beautiful mode, where no applications are executed. untill AX is filled with 1682 and the INT 21h is called, But then why should we call INT 21H,
Windows always likes to be hanged right 8-)
*********************
MOV AX,1681h
INT 21h ;Go to critical mode 8-)
*********************
Now I am not sure about this one, but I think that this will make Windows go into a beautiful mode, where no applications are executed. untill AX is filled with 1682 and the INT 21h is called, But then why should we call INT 21H,
Windows always likes to be hanged right 8-)
What preempts under XP when an app doesn't return from a wind_msg_loop?
sajen - XP is built on a kernel in which security is actually implemented. I dont think there is any general method from which you can hang XP without ring0 priviledges, and I dont think there is anyway of getting ring zero priviledges without writing a driver.
But then again, like most people I consider this a good thing :)
eet_1024 - I presume that would be the point in which windows decideds your app is not responding?
But then again, like most people I consider this a good thing :)
eet_1024 - I presume that would be the point in which windows decideds your app is not responding?
Since windows is cooperative, is there a watch dog timer that returns control to windows?
Since windows is cooperative, is there a watch dog timer that returns control to windows?
Windows versions later than 3.11 (or NT+) are not cooperative, they are preemptive. The timer calls a SwitchProcess / SwitchThread interupt which transfers control to another process or thread. If an application is freezed or crashed, windows will hopefully detect it and kill it.