- Mastering Assembly Programming
- Alexey Lyashko
- 315字
- 2021-08-20 10:23:25
Accumulators
The EAX register is also known as an accumulator and is used with multiplication and division operations, both as implied and target operands. It is important to mention that the result of a binary multiplication is twice the size of the operands and the result of a binary division consists of two parts (quotient and remainder), each of which has the same bit width as the operands. Since the x86 architecture began with 16-bit registers and for the sake of backward compatibility, the EDX register is used for storing partial results when the values of the operands are larger than could fit into 8 bits. For example, if we want to multiply two bytes, 0x50 and 0x04, we would expect the result to be 0x140, which cannot be stored in a single byte. However, since the operands were 8 bits in size, the result is stored into the AX register, which is 16 bits. But if we want to multiply 0x150 by 0x104, the result would need 17 bits to be stored (0x150 * 0x104 = 0x15540) and, as we have mentioned already, the first x86 registers were only 16 bits. This is the reason for using an additional register; in the case of the Intel architecture, this register is EDX (to be more precise, only the DX part would be used in this specific case). As a verbal explanation may sometimes be too generalized, it would be better to simply demonstrate the rule.

Division implies a slightly different rule. To be more precise, this is the inverted multiplication rule, meaning that the result of the operation is half the bit width of the dividend, which in turn means that the largest dividend in the long mode may be 128-bit wide. The smallest dividend value remains the same as in the smallest value of the source operand in the case of multiplication--8 bits.

- Designing Machine Learning Systems with Python
- Mobile Application Development:JavaScript Frameworks
- Mastering ServiceStack
- Mastering phpMyAdmin 3.4 for Effective MySQL Management
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題精解(C語言實(shí)現(xiàn)+微課視頻)
- VSTO開發(fā)入門教程
- HTML5游戲開發(fā)案例教程
- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Visual C++數(shù)字圖像處理技術(shù)詳解
- Apache Spark 2.x for Java Developers
- RabbitMQ Essentials
- 編程菜鳥學(xué)Python數(shù)據(jù)分析
- Python3.5從零開始學(xué)
- Visual Basic程序設(shè)計習(xí)題與上機(jī)實(shí)踐
- 深入實(shí)踐Kotlin元編程