16 bit multiply in PASM - another question
Chris_D
Posts: 305
Hello,
I have been working in PASM for a few months now and I really like it.· I can handle the basic stuff pretty good but cannot seem to grasp how to use the example multiplication and division routines referenced in the manual (Appendix B, Math samples and Function tables).
It appears they have to be treated as a subroutine and called which I have not figured out how to do.· Does someone know of an example program that is VERY simple in nature that takes a couple of variables and performs the multiplication on them?·
Ultimately, what I need to do is square two variables.· Both variables will be able to fit in 16 bit vars so it looks like the multiplication routine would be best suited.· However, expecting to do division in PASM at some point in time, I hope to learn how to use both of those routines at the same time.
Thanks
Chris
Post Edited (Chris_D) : 3/12/2010 11:26:14 PM GMT
I have been working in PASM for a few months now and I really like it.· I can handle the basic stuff pretty good but cannot seem to grasp how to use the example multiplication and division routines referenced in the manual (Appendix B, Math samples and Function tables).
It appears they have to be treated as a subroutine and called which I have not figured out how to do.· Does someone know of an example program that is VERY simple in nature that takes a couple of variables and performs the multiplication on them?·
Ultimately, what I need to do is square two variables.· Both variables will be able to fit in 16 bit vars so it looks like the multiplication routine would be best suited.· However, expecting to do division in PASM at some point in time, I hope to learn how to use both of those routines at the same time.
Thanks
Chris
Post Edited (Chris_D) : 3/12/2010 11:26:14 PM GMT
Comments
Of course you have to define the LONGs to hold your numbers and x, y and the temporary variable t that multiply uses.
If you are multiplying by small constant (< 9 bits) value put it directly in the mov instruction e.g.
mov someNumber, #42
Don't forget the example multiply in the manual is for positive numbers only.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Thanks very much for responding.· That is exactly what I needed and more.· I completely forgot about the positive only values.· I suspect that I can work that out in the rest of the code without too much trouble though.
Thanks again!
Chris
If an example value is needed and example would be 3500 x 3500
Thanks
Chris
Thanks much for answering my question (and the follow up before I even asked it)!
Knowing that the time is a constant helps a lot as I work through a new program I am writing.· It will be a time-critical program and knowing the times of all the "little things" is of great importance.
Thanks again
Chris