Chapter Nine
There is a lot more to assembly language than knowing the operations of a handful of machine instructions. You’ve got to know how to use them and what they can do. Many instructions are useful for operations that have little to do with their mathematical or obvious functions. This chapter discusses how to convert expressions from a high level language into assembly language. It also discusses advanced arithmetic and logical operations including multiprecision operations and tricks you can play with various instructions.
9.0
Chapter Overview
This chapter discusses six main subjects: converting HLL arithmetic expressions into assembly language, logical expressions, extended precision arithmetic and logical operations, operating on different sized operands, machine and arithmetic idioms, and masking operations. Like the preceding chapters, this chapter contains considerable material that you may need to learn immediately if you’re a beginning assembly language programmer.
The sections below that have a “•” prefix are essential. Those sections with a “t” discuss advanced topics that you may want to put off for a while.
•
•
•
•
•
•
•
•
•
• t t t • t t
• t t t t
• t t t t t t
Arithmetic expressions
Simple assignments
Simple expressions
Complex expressions
Commutative operators
Logical expressions
Multiprecision operations
Multiprecision addition operations
Multiprecision subtraction operations
Extended precision comparisons
Extended precision multiplication
Extended precision division
Extended precision negation
Extended precision AND, OR, XOR, and NOT
Extended precision shift and rotate operations
Operating on different sized operands
Multiplying without MUL and IMUL
Division without DIV and IDIV
Using AND to compute remainders
Modulo-n Counters with AND
Testing for 0FFFFF...FFFh
Test operations
Testing signs with the XOR instructions
Masking