From 1c843d015054bf244886c9323eabb9594365521e Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Jan 2024 18:18:12 +0900 Subject: [PATCH] [sample] save ra in bf.cpp --- sample/bf.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sample/bf.cpp b/sample/bf.cpp index b9c304d..3c007e9 100644 --- a/sample/bf.cpp +++ b/sample/bf.cpp @@ -24,11 +24,12 @@ class Brainfuck : public Xbyak_riscv::CodeGenerator { const auto &pPutchar = s2; const auto &pGetchar = s3; const auto &stack = s4; - const int saveSize = 16*3; + const int saveSize = 16*2; addi(sp, sp, -saveSize); - sd(pPutchar, sp, 16); - sd(pGetchar, sp, 24); - sd(stack, sp, 32); + sd(pPutchar, sp, 8); + sd(pGetchar, sp, 16); + sd(stack, sp, 24); + sd(ra, sp, 32); mv(pPutchar, a0); mv(pGetchar, a1); @@ -88,9 +89,10 @@ class Brainfuck : public Xbyak_riscv::CodeGenerator { } } - ld(stack, sp, 32); - ld(pGetchar, sp, 24); - ld(pPutchar, sp, 16); + ld(ra, sp, 32); + ld(stack, sp, 24); + ld(pGetchar, sp, 16); + ld(pPutchar, sp, 8); addi(sp, sp, saveSize); ret(); }