summaryrefslogtreecommitdiff
path: root/lib/alu.c
diff options
context:
space:
mode:
authorPixel <>2001-04-17 03:58:16 +0000
committerPixel <>2001-04-17 03:58:16 +0000
commita19da7ded119713b955816f1de69d71eef191ab0 (patch)
treeab5d3c8f41dda31834bb98f513d36f9d9e8166e1 /lib/alu.c
parent2a4ea1660a5a4ef6168940176f2f81fa1be93632 (diff)
Indentation
Diffstat (limited to 'lib/alu.c')
-rw-r--r--lib/alu.c91
1 files changed, 40 insertions, 51 deletions
diff --git a/lib/alu.c b/lib/alu.c
index 0adac7d..a23494e 100644
--- a/lib/alu.c
+++ b/lib/alu.c
@@ -15,34 +15,36 @@ Uint32 SecondResult = 0;
/* ALU rapide */
-Uint32 RNot(Uint32 a) {
+Uint32 RNot(Uint32 a)
+{
return (~a) + 1;
}
Uint32 RAdditionNonSigne(Uint32 a, Uint32 b)
{
unsigned long long tr = a, masq = 1;
+
tr += b;
-
+
masq <<= 32;
if (masq & tr) {
SetOverflow();
} else {
ResetOverflow();
}
-
+
if (tr) {
ResetZero();
} else {
SetZero();
}
-
+
if (tr & 1) {
SetParity();
} else {
ResetParity();
}
-
+
ResetSign();
return tr;
}
@@ -50,6 +52,7 @@ Uint32 RAdditionNonSigne(Uint32 a, Uint32 b)
Uint32 RAdditionSigne(long int a, long int b)
{
long int tr = a;
+
tr += b;
if (((a & 0x80000000) && (b & 0x80000000) && !(tr & 0x80000000)) ||
@@ -58,19 +61,19 @@ Uint32 RAdditionSigne(long int a, long int b)
} else {
ResetOverflow();
}
-
+
if (tr) {
ResetZero();
} else {
SetZero();
}
-
+
if (tr & 1) {
SetParity();
} else {
ResetParity();
}
-
+
if (tr & 0x80000000) {
SetSign();
} else {
@@ -159,7 +162,7 @@ Uint32 RDivisionNonSigne(Uint32 a, Uint32 b)
Uint32 RDivisionSigne(long int a, long int b)
{
long long temp = a;
-
+
temp /= b;
if (temp & 1) {
SetParity();
@@ -819,63 +822,50 @@ couple MultipliSig(Uint32 x, Uint32 y)
Uint32 NDivisionNonSigne(Uint32 a, Uint32 b)
{
Uint32 quot, rest;
- if (b>a)
- {
- quot=0;
- rest=a;
- }
- else
- {
- if (b==a)
- {
- quot=1;
- rest=0;
- }
- else
- {
- quot=0;
- rest=a;
- while (rest>=b)
- {
- rest=NSoustractionNonSigne(rest,b);
+
+ if (b > a) {
+ quot = 0;
+ rest = a;
+ } else {
+ if (b == a) {
+ quot = 1;
+ rest = 0;
+ } else {
+ quot = 0;
+ rest = a;
+ while (rest >= b) {
+ rest = NSoustractionNonSigne(rest, b);
quot++;
}
}
}
SecondResult = rest;
return quot;
-}
+}
Uint32 NDivisionSigne(long int a, long int b)
{
long int quot, rest;
-
- if (b>a)
- {
- quot=0;
- rest=a;
- }
- else
- {
- if (b==a)
- {
- quot=1;
- rest=0;
- }
- else
- {
- quot=0;
- rest=a;
- while (rest>=b)
- {
- rest=NSoustractionNonSigne(rest,b);
+
+ if (b > a) {
+ quot = 0;
+ rest = a;
+ } else {
+ if (b == a) {
+ quot = 1;
+ rest = 0;
+ } else {
+ quot = 0;
+ rest = a;
+ while (rest >= b) {
+ rest = NSoustractionNonSigne(rest, b);
quot++;
}
}
}
SecondResult = rest;
return quot;
-}
+}
Uint32 NMultiplicationNonSigne(Uint32 a, Uint32 b)
{
@@ -1004,4 +994,3 @@ Uint32 SHR(Uint32 a)
return NSHR(a);
}
}
-