Bug fix. Now works on 32-bit and with -O3.

git-svn-id: http://www.cdkersey.com/harp/harptool@120 0246edb2-e076-4747-b392-db732a341fa2
This commit is contained in:
chad
2013-01-18 11:07:23 +00:00
parent 707c7a19f1
commit 38ab04e988
5 changed files with 39 additions and 30 deletions

View File

@@ -11,6 +11,7 @@
#include "archdef.h"
#include "enc.h"
#include "mem.h"
#include "debug.h"
namespace Harp {
#ifdef EMU_INSTRUMENTATION

View File

@@ -57,18 +57,19 @@ namespace Harp {
{}
virtual void bind(Addr addr, Addr base = 0) {
Size bytes = bits/8, remainder = bits%8, i;
Size bytes(bits/8), remainder(bits%8);
if (relative) {
addr = addr - base;
Word_s addr_s(addr);
if ((addr_s >> bits) != -1 && (addr_s >> bits) != 0) goto noFit;
if ((addr_s >> bits) != ~0ull && (addr_s >> bits) != 0) goto noFit;
} else {
Addr mask = (1ll<<bits)-1;
Addr mask = (1ull<<bits)-1;
if (addr > mask) goto noFit;
}
{ Byte mask((1<<remainder) - 1);
{ Byte mask((1ull<<remainder) - 1);
Size i;
for (i = 0; i < bytes; i++) {
data[offset+i] = addr & 0xff;
addr >>= 8;
@@ -176,7 +177,7 @@ namespace Harp {
class HOFReader : public ObjReader {
public:
HOFReader(ArchDef arch) : arch(arch) {}
HOFReader(ArchDef &arch) : arch(arch) {}
Obj *read(std::istream &input);
private:
const ArchDef &arch;
@@ -192,7 +193,7 @@ namespace Harp {
class HOFWriter : public ObjWriter {
public:
HOFWriter(ArchDef arch) : arch(arch) {}
HOFWriter(ArchDef &arch) : arch(arch) {}
virtual void write(std::ostream &output, const Obj &obj);
private:
const ArchDef &arch;