Zarathustra wrote:
I need to make some calculations with asm in D.
Could somebody write how to do this, micro tutorial ;p
x86
Especially inc, dec, add, sub, mul, imul, div, idiv instructions.
Also ja, jb, jg, jl, jo; jc ...
and, or, not, xor,
sal, shl, sar, shr

First of all: unless you really need to detect overflow or something (or just want to learn about asm), I'd recommend doing calculations in D and letting the compiler worry about what asm to generate. It'll likely be able to do a better job.


Otherwise:

If you look up those instructions (plus MOV) you should be well on your way, if all you want to do is calculations.

The NASM manual used to have a pretty good overview of instructions and what they did (including implicit register usage etc.) in appendix B. Recent versions seem to have cut this from the manual for some reason, but there are still some places where the old version can be found, such as <http://home.comcast.net/~fbkotler/nasmdoc0.html> (thank you, Google). Besides looking up the instructions themselves in B.4.*, you may also want to look at the first sections (B.1 to B.2.4) for notations used, condition codes, and status flags.

Alternatively, the Intel and AMD processor manuals contain much the same information and pdf files can be downloaded (for free) from their respective websites.

Note that IIRC all these documents document condition code jumps (ja/jb/jg/jl/jo/jc etc.) as Jcc.

Reply via email to