0

I made a long research to use the Modulo operator in Assembly language and the closest I found was the DIV operator however it's not available on the simple educational Assembler PEP8 http://www.filewatcher.com/b/ftp/ftp.pepperdine.edu/pub/compsci/pep8/downloads.0.0.html with the following operators http://pastebin.com/f595fb11b (translation from French ''Annexe C'' in http://www.er.uqam.ca/nobel/k20250/Notes_cours.html detailled in "Chapitre 7").

Is there a way to do modulo with only ADD, SUB and bitwise operations (ASL, ROL, AND, OR, ...) ?

Thank you kindly
I've been having trouble with subscription so if someone could reply something today, a tip or a preliminary reply, it would be great !

2
Contributors
1
Reply
4
Views
8 Years
Discussion Span
Last Post by sysop_fb
0

Just think about it.

Given 11 % 3 how would you find the remainder? Well how would you do divide?
11 - 3 = +1 cycle with 8 left over
8 is > 3 so keep going
8 - 3 = +1 cycle with 5 left over
5 > 3 so...
5 - 3 = +1 cycle with 2 left over
2 is < 3 and > 0 so the remainder is 2 after 11 % 3

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.