简体   繁体   中英

Alternative form for Modulo Operation in Assembly x86

There is a way to compute the mod operation, without using DIV or IDIV in assembly x86 language?

For instance, one could use DIV in order to take the remainder of the division. But, instead to use DIV, there are other options?

  • You can always write the division algorithm yourself, completly not using the DIV or IDIV instructions.

  • There's of course a range of modulo's where you basically just need an AND instruction:

     and eax, 255 ;Gives modulo 256 and eax, 15 ;Gives modulo 16 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM