longmul()

longmul()

Description

This function is used to multiply 64-bit numbers.

Mathematical function which multiplies val with val2 (val*val2=res).

Syntax

longmul(valL, valH, val2L, val2H, resL, resH);

Parameters

Variable

Input

Variable

Input

valL

variable which holds least significant 32 bits of number you want to multiply with val2.

valH

variable which holds most significant 32 bits of number you want to multiply with val2.

val2L

variable which holds least significant 32 bits of number you want to multiply with val.

val2H

variable which holds most significant 32 bits of number you want to multiply with val.

rezL

variable which will hold most significant 32 bits of multiplication result between val and val2.

rezH

variable which will hold least significant 32 bits of multiplication result between val and val2.

Returns

Always returns SCRIPT_OPERATION_SUCCESS.

Function call example

Example of 64 bit multiplication
new Number1MSB = 100; new Number1LSB = 20; new Number2MSB = 35; new Number2LSB = 5; new ResultMSB = 0; new ResultLSB = 0; main() { longmul(Number1LSB, Number1MSB, Number2LSB, Number2MSB, ResultLSB, ResultMSB); //ResultMSB = 1000 and ResultLSB = 100 for(;;) { Delay(1000); } }