Skip to content

Commit 77f7e2a

Browse files
committed
Still debugging the printString
1 parent 0a40474 commit 77f7e2a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/io/github/coderodde/simple/stack/machine/SimpleStackMachine.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ int readWordFromTape(final int address) {
228228
throw new StackMachineException(exceptionMessage);
229229
}
230230

231-
final int word0 = Byte.toUnsignedInt(tape[address + 0]) << 0;
232-
final int word1 = Byte.toUnsignedInt(tape[address + 1]) << 8;
233-
final int word2 = Byte.toUnsignedInt(tape[address + 2]) << 16;
234-
final int word3 = Byte.toUnsignedInt(tape[address + 3]) << 24;
231+
final int word0 = Byte.toUnsignedInt(tape[address + 3]) << 0;
232+
final int word1 = Byte.toUnsignedInt(tape[address + 2]) << 8;
233+
final int word2 = Byte.toUnsignedInt(tape[address + 1]) << 16;
234+
final int word3 = Byte.toUnsignedInt(tape[address + 0]) << 24;
235235

236236
return word0 |
237237
word1 |

src/test/java/io/github/coderodde/simple/stack/machine/MachineLanguageSpecificationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public void printString() {
99
final SimpleStackMachine machine = new SimpleStackMachine();
1010
final CodeBuilder cb = new CodeBuilder(1000);
1111

12-
cb.emit(Operation.PUSH.getOpcodeByte());
13-
cb.emit(6);
1412
cb.emit(Operation.PUSH.getOpcodeByte());
1513
cb.emit(900);
14+
cb.emit(Operation.PUSH.getOpcodeByte());
15+
cb.emit(6);
1616
cb.emit(Operation.PRINT_STRING.getOpcodeByte());
1717
cb.emit(Operation.HALT.getOpcodeByte());
1818
cb.emit("Hello!", 900);

0 commit comments

Comments
 (0)