summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-05-13 22:27:00 -0700
committerKeith Packard <keithp@keithp.com>2013-05-13 22:27:00 -0700
commit80a6b0ea5c36c307a8edc79ad10ef7a8ff3d480e (patch)
treeed8d614d2a77d8534f1c2b7c5554dec8a25e310a /altoslib
parent9bd717e71d69338b1af521b37e8bd975e503398e (diff)
altoslib: Correct hexfile address ranges
Stop trying to use sentinal values for addresses and just keep a boolean tracking whether they've been initialized. Avoids precision errors in the variables. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosHexfile.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java
index 68f42f14..2140228a 100644
--- a/altoslib/AltosHexfile.java
+++ b/altoslib/AltosHexfile.java
@@ -230,17 +230,19 @@ public class AltosHexfile {
}
long extended_addr = 0;
- long base = 0xffffffff;
- long bound = 0x00000000;
+ long base = 0;
+ long bound = 0;
+ boolean set = false;
for (HexRecord record : record_list) {
switch (record.type) {
case 0:
long addr = extended_addr + record.address;
long r_bound = addr + record.data.length;
- if (addr < base)
+ if (!set || addr < base)
base = addr;
- if (r_bound > bound)
+ if (!set || r_bound > bound)
bound = r_bound;
+ set = true;
break;
case 1:
break;
@@ -259,7 +261,7 @@ public class AltosHexfile {
}
}
- if (base >= bound)
+ if (!set || base >= bound)
throw new IOException("invalid hex file");
if (bound - base > 4 * 1024 * 1024)