This patch fixes a bug that caused semihosted exit to always return status 0; it was incorrectly using the value of D0 (which contains the HOSTED_EXIT request number) instead of D1.
Note that per the newlib documentation for the m68k semihosting protocol https://www.sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/m68k/m68k-semi.txt;h=50520c15292aa7edf7eef28e09fd9202ce75b153;hb=HEAD for the HOSTED_EXIT syscall the parameter is passed directly in the register instead of in a parameter block pointed to by the register. Signed-off-by: Sandra Loosemore <san...@codesourcery.com> Reviewed-by: Laurent Vivier <laur...@vivier.eu> --- target/m68k/m68k-semi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 8e5fbfc..f189c92 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -194,8 +194,8 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) args = env->dregs[1]; switch (nr) { case HOSTED_EXIT: - gdb_exit(env, env->dregs[0]); - exit(env->dregs[0]); + gdb_exit(env, env->dregs[1]); + exit(env->dregs[1]); case HOSTED_OPEN: GET_ARG(0); GET_ARG(1); -- 2.8.1