Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syscall 10 (Exit) uses last code from Syscall 93 (Exit2) #170

Closed
rladenson opened this issue Feb 9, 2023 · 1 comment
Closed

Syscall 10 (Exit) uses last code from Syscall 93 (Exit2) #170

rladenson opened this issue Feb 9, 2023 · 1 comment

Comments

@rladenson
Copy link

Syscall 10 (Exit) is supposed to always exit with code 0 (at least that's what it says in the documentation in RARS) however instead of this, if you have used Syscall 93 (Exit2, the one that lets you choose what code you exit with) since you opened the program, it uses the most recent exit code for that instead.

Repro:

  1. Open Rars
  2. Create a new file
  3. Make the contents of that file
addi a7, zero, 93
addi a0, zero, 1
ecall
  1. Assemble and run the file
  2. Change the file contents to
addi a7, zero, 10
ecall
  1. Assemble and run again

Expected: Should exit with code 0
Actual: Exits with code 1

@TheThirdOne
Copy link
Owner

Good catch. This should be a simple fix by setting exitCode to 0 in exit.

public void simulate(ProgramStatement statement) throws ExitingException {
throw new ExitingException(); // empty exception list.
}

public void simulate(ProgramStatement statement) throws ExitingException {
Globals.exitCode = RegisterFile.getValue("a0");
throw new ExitingException(); // empty error list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants