What does test do?
What would be best for me would be a complete x86 assembly instruction
textfile... which I havent found.
--
-- Erlend J. Leiknes (noo...@online.no)
NEVER eat more than you can lift.
It performs a "mental AND" on its two operands, and updates the flags as if
the operation took place. That is, it's the same as the AND operation, except
that it discards the result, and keeps the flags which might have been set.
This:
test reg, reg
jz <address>
...is a common way of testing whether reg is zero -- remember that (reg AND
reg = reg). je is a synonym for jz, and jne is a synonym for jnz. So can you
guess what the code you posted does?
As for x86 references, the ones I rely on are the one that comes with NASM,
and the 386intel.txt which seems to be floating around the internet.
http://ftp.unina.it/pub/docs/386htm/toc.htm
lea took me a while too. The Intel docs are pretty terse about it. lea is
an artifact of the 386 addressing modes. It does an address computation,
and then loads it's argument with the result of the computation. Because
it's just doing what the CPU does for any memory reference anyway, it's
only 2 clocks. Thus it can be as much as...
shift a register by 1, 2 or 4
add that to another register
add a literal to that
put the result in a chosen register
in 2 clocks. All 3 registers can be the same register, so you can do wierd
things like multiply by 9 in 2 clocks.
I was shown recently in comp.lang.forth by Gary Chanson how lea can be
really handy for implementing a stack pointer for a virtual machine stack
additional to the return stack, which Forth requires.
Rick Hohensee
Test is a lot like cmp, except that it does and AND instead of a SUB.
The basic idea in both cases, however, is that you take two operands,
carry out an operation on them, but discard the result. The only
effect of a test or a cmp is to set flags based on the result.
Normally, test is used to see whether a particular set of bits in an
operand are set. For a rather silly example, you could test whether
a number is odd using test:
mov eax, number
test eax, 1
jnz its_odd
--
Later,
Jerry.
The Universe is a figment of its own imagination.
Jerry Coffin <jco...@taeus.com> wrote in message
news:MPG.15f094afa...@news.direcpc.com...
That checks if it's zero or not. It's probably followed by a jz or jnz,
yes? And perhaps also, uh, parity, sign, but not carry or overflow.
HEY! Everybody take a 386 instruction and do a tutorial description! Beth
can start with NOP since she likes it terse :o)
Rick Hohensee
LEA AX,[BX+SI].VARIABLE
places in AX the sum of the contents of BX plus the contents of SI
plus the offset to VARIABLE.