In this recipe, we will learn to divide two numbers using the inline assembly language in C. The assembly language provides us with better control over CPU registers, so we have to manually place the divisor and dividend in their respective registers. Additionally, after the division, the quotient and remainder will be automatically saved in their respective registers.
Dividing two numbers using assembly code in C
How to do it…
To divide two numbers using assembly code in C, perform the following steps:
- Load the dividend into the eax register.
- Load the divisor into the ebx register.
- Initialize the edx register to zero.
- Execute the divl assembly statement to divide the content of the eax register by the...