- Home
- Products
- Articles
- 4 Axis Robot Arm
- A Stepper Motor Driven Ferris Wheel (Version 3 Compiler required)
- An Update on Keith Cameron's Lift
- Automatic Tram Layout
- Bug in Increment Word Instruction
- Compiler Version Releases
- Industrial Arc Welding Robot
- MotorVating the Speed Play Robot
- Reproducing the Electronic Set Models
- Sensor Expansion Port Pinout Diagram
- Sheet 1 - Hardware from NZ 240 volt wall socket to...
- Sheet 3 Meccano Car model controlled by the MotorVator and Director.
- Sheet 2 - Hardware from Motor(s) to MotorVator®.
- User Input Options
- Version 3 Manual Released
- 16/32 Bit Maths Routines
- Build Your Own Photo Sensor
- Controlling Stepper Motors
- Magnetic reed switch as a non contact sensor
- MeccCompiler III Tutorial
- More Inputs and/or Motors: Port Replication
- More Inputs: the Sensor Expansion Port
- Square Root Function
- Tutorial: Rev Counter
- Use of the opto switch or opto interrupter as a ro...
- FAQ
16/32 Bit Maths Routines
In the process of developing code for my Plotter project, I have had to write a number of routines for handling 32 bit numbers.
The routines include
Mult16 - multiple two 16bit word values together (giving a 32 bit value)
Divide32 - divides a 32 bit value by a 16bit word, and returns a Word result
Add32 - Add two 32 bit values together
Sub32 - Subtracts a 32 bit value from another 32 bit value
Sqroot - returns the Square Root of a Word Value
SqRoot32 - returns a word value, containing the Square Root of a 32 bit value.
The 32 bit values are help in a 4 byte data table, e.g.
Declare DataPointer Temp32P
Declare DataTable Temp32 ; Temporary store for
; intermediate 32 bit results
Reserve 4 ; reserve 4 bytes = 32 bits
End DataTable
Declare Word Result
to use, you need to pass pointers to the value, rather than the value itself.
For example
Temp32P = SetPointer(Temp32)
Result = SqRoot32(Temp32P)
. 16 and 32 Bit RoutinesRoutines for 16 and 32 bit maths.
Use an Include File "16BitMult.txt" statement in your program, so that you can keep the routines in a common library directory.