Work with decimals in assembler

0

Hello everyone.

The fact is that I'm still new to everything that is programming in assembly language, and I'm working with x86, but I'm having a problem and I need to work with decimals but the records I use (eax, ebx, ecx and edx) are integers. How could I work directly with divisions and multiplications with decimals?

    
asked by Kam 18.04.2017 в 22:55
source

2 answers

1

Look you can not work with decimals directly, what if you can is to use functions for example: in ax I have 10 and I divide it by 3 with the function DIV, mathematically the answer is 3.333333 but in ensablador it is of the following way: AL with the value 3 and AH with the value 1. In AH I saved how many times the value 3 fits in 10 and in AL I save it when I guess it would be 1.

Here is an explanation: link

    
answered by 19.04.2017 в 01:05
0

To work with decimals you need to use the FUP (floating point unit) , this unit has its own records. The instructions that the FUP has are similar to what you have already used, but they have an f at the beginning. Example:

  • fadd is floating sum
  • fdiv is floating division

Here are some links that can help you.
Explanation of the FUP link



Instructions of the FUP link

    
answered by 19.04.2017 в 06:36