Skip to content

Commit

Permalink
SyscallPrintChar.simulate consistently writes UFT-8 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
privat committed Jun 28, 2024
1 parent db9811e commit 8365b4e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rars/riscv/syscalls/SyscallPrintChar.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import rars.riscv.hardware.RegisterFile;
import rars.util.SystemIO;

import java.nio.charset.StandardCharsets;

/*
Copyright (c) 2003-2006, Pete Sanderson and Kenneth Vollmar
Expand Down Expand Up @@ -40,8 +42,9 @@ public SyscallPrintChar() {
}

public void simulate(ProgramStatement statement) {
char t = (char) (RegisterFile.getValue("a0") & 0x000000ff);
SystemIO.printString(Character.toString(t));
byte[] t = new byte[1];
t[0] = (byte) RegisterFile.getValue("a0");
SystemIO.printString(new String(t, StandardCharsets.UTF_8));
}

}

0 comments on commit 8365b4e

Please sign in to comment.