Slick way to generate Modulus 3 in PASM - Any ideas?
Beau Schwabe
Posts: 6,568
Anyone know of a slick way to generate Modulus 3 or any other user defined Modulus value in PASM?
I could use a lookup table or partial lookup table and shift it up or down, but yuck!
This will only be needed for BYTE wide variables, and of course the fastest solution the better.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I could use a lookup table or partial lookup table and shift it up or down, but yuck!
This will only be needed for BYTE wide variables, and of course the fastest solution the better.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Comments
-Phil
Yes, basically just division by 3 where all I'm interested in is the remainder, I don't care about the whole number. I can put something together that works pretty good for just Modulus 3, but I wanted to provide an option that doesn't confine it to a specific number.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
-Phil
Thanks!... I think that will work just fine. Although I think you meant to add a ,#1 after each shr modulus.
TestCode:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
-Phil