BackHomeContact Us

 

rem Illustrating logical and mathematical operations

100
print "Testing addition / subtraction operation..."
rem generate a 32-bit number
rand A
rand B

C = A + B
D = C - A
if D <> B then print "...Addition / subtraction test failed."

print "Testing multiplication / division operation..."
rand E
rand F
E = E & 32767
F = F & 32767
REM to make sure that divider is not zero
F = F + 1
G = E * F
H = G / F

if H <> E then print "...multiplication / division test failed."
if H <> E then end

print "Testing modulos operation..."
rand E
rand F
E = E & 32767
F = F & 32767
REM to make sure that divider is not zero
F = F + 1
if E >= F then H = E / F else H = F / E
if E >= F then I = E % F else I = F % E
if E <= F then if (( E * H ) + I) <> F then print "...modulos operation failed."
if E <= F then if (( E * H ) + I) <> F then end

wait U

print "Testing logical operation..."
rand G
rand H
G = G * H
H = G # -1
I = G | H
if I <> -1 then print "...logical OR operation failed."
if I <> -1 then end

I = G & H
if I <> 0 then print "...logical AND operation failed."
if I <> 0 then end

I = G # -1
if I <> H then print "...logical XOR operation failed."
if I <> H then end

I = ~G
if I + G <> -1 then print "...logical unary operation failed."
if I + G <> -1 then end
goto 100
end
$

 


 

www.OESIncorp.com

Copyright ©  2002, 2003, 2004, 2005, 2006 Optimal Engineering Systems, Inc.