longsub()

longsub()

Description

This function is used to subtract 64-bit numbers.

Mathematical function which subtracts val with val2 (val-val2=res).

Syntax

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

Parameters

Variable

Input

Variable

Input

valL

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

valH

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

val2L

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

val2H

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

rezL

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

rezH

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

Returns

Always returns SCRIPT_OPERATION_SUCCESS.

Function call example

Example of 64 bit subtraction
new Number1MSB = 100; new Number1LSB = 20; new Number2MSB = 25; new Number2LSB = 5; new ResultMSB = 0; new ResultLSB = 0; main() { longsub(Number1LSB, Number1MSB, Number2LSB, Number2MSB, ResultLSB, ResultMSB); // ResultMSB = 75 and ResultLSB = 15 for(;;) { Delay(1000); } }