Skip to content

Commit

Permalink
Fix bug in hexadecimal output.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed Jun 18, 2024
1 parent e93190f commit adef788
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions BMR/Register.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ class BlackHole
template <typename T>
BlackHole& operator<<(T) { return *this; }
BlackHole& operator<<(BlackHole& (*__pf)(BlackHole&)) { (void)__pf; return *this; }
void fill(char) {}
void width(int) {}
void activate(bool) {}
void redirect_to_file(ostream&) {}
};
Expand Down
2 changes: 2 additions & 0 deletions Compiler/GC/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ def reverse_bytes(self):
[self.v[i:i + 8] for i in range(0, len(self.v), 8)]), []))
def reveal_print_hex(self):
""" Reveal and print in hexademical (one line per element). """
if len(self.v) % 64 != 0:
raise CompilerError('only works for lengths divisible by 64')
for x in self.reverse_bytes().elements():
x.reveal().print_reg()
def update(self, other):
Expand Down
10 changes: 7 additions & 3 deletions GC/Processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,14 @@ void Processor<T>::print_reg(int reg, int n, int size)
#ifdef DEBUG_VALUES
cout << "print_reg " << typeid(T).name() << " " << reg << " " << &C[reg] << endl;
#endif
bigint output;
out << "Reg[" << reg << "] = 0x" << hex << noshowbase;
for (int i = 0; i < size; i++)
output += bigint((unsigned long)C[reg + i].get()) << (T::default_length * i);
out << "Reg[" << reg << "] = " << hex << showbase << output << dec << " # ";
{
out.fill('0');
out.width(16);
out << (unsigned long)C[reg + size - 1 - i].get();
}
out << dec << " # ";
print_str(n);
out << endl << flush;
}
Expand Down
12 changes: 12 additions & 0 deletions Tools/SwitchableOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ class SwitchableOutput
*out << __pf;
return *this;
}

void fill(char c)
{
if (out)
out->fill(c);
}

void width(streamsize w)
{
if (out)
out->width(w);
}
};

#endif /* TOOLS_SWITCHABLEOUTPUT_H_ */

0 comments on commit adef788

Please sign in to comment.