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.
Posted on 2002-09-06 06:07:59 by huh
Huh try this instead:


add eax, 3
and eax, 0FFFFFFFCh


Mirno
Posted on 2002-09-06 06:48:29 by 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.
Posted on 2002-09-06 08:44:39 by gliptic
my all time favorite:

mov eax, 0

break dependencies on eax :)
Posted on 2002-09-07 19:44:55 by stryker
MOV is not all time favorite :)
The AMD Athlon processor is able to avoid the false read
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.
Posted on 2002-09-08 02:14:22 by Nexo
I have a p3 and that was just my all time favorite not the all time favorite. :)
Posted on 2002-09-08 09:46:30 by stryker
stryker, you have luck with P3 :)

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.
Posted on 2002-09-08 11:02:00 by Nexo
lol :grin:
Posted on 2002-09-08 11:11:50 by stryker
This one terminates the current process on XP:


not esp
int 3


I dunno what it will do on the 95 family of windows.
Posted on 2002-09-12 22:36:05 by huh
nop

sometimes adding a couple of this in a loop will increase the speed of an algorithm. :)
Posted on 2002-09-12 23:36:07 by stryker
*************

CLI
HLT

**************


Two bytes but powerful,
Posted on 2002-09-13 00:21:05 by sajen
cli and hlt(I think) are both privileged instructions and both will cause an exception under NT -> XP
Posted on 2002-09-13 00:48:42 by huh
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-)
Posted on 2002-09-13 01:09:06 by sajen
What preempts under XP when an app doesn't return from a wind_msg_loop?
Posted on 2002-09-13 03:40:31 by eet_1024
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?
Posted on 2002-09-13 03:48:12 by huh
Since windows is cooperative, is there a watch dog timer that returns control to windows?
Posted on 2002-09-14 01:23:40 by eet_1024

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.
Posted on 2002-09-17 04:35:04 by gliptic