Ok maybe I've had too much coffee today, but I can't see why this:
Code:
unsigned c = 0;
for (size_t i = 0; i < sz; i++, c++) {
cout << " " << *(b + i);
if (c == 2) {
cout << "\n";
c = 0;
}
}
Doesn't output how I want it to. It's a snippet from one of my debugging functions, to output the program as it appears in memory. I was fine having it all dumped on one line spaced out until I started writing larger test programs. Basically I want it in this format:
Code:
opcode operand1 operand2
opcode operand1 operand2
...
So that's a newline every 3 items, right? Then why do I get this output?
Code:
*** DEBUG [PROGRAM DISASSEMBLY] ***
3 9 61442
4 61442
0 65535
0 0
*** END ***
*** DEBUG [REGISTERS] ***
R0: 9
R1: 0
PC: 4
Z: 0
*** END ***
*** DEBUG [REGISTERS] ***
R0: 10
R1: 0
PC: 65535
Z: 0
*** END ***
Press any key to continue
The first line is fine, then it all goes haywire. The 0 on the 3rd line should be at the end of the 2nd line and, well, you get the idea.