package venus.simulator

import org.junit.Test
import kotlin.test.assertEquals
import venus.riscv.Instruction
import venus.assembler.Assembler
import venus.assembler.Linker

class FunctionCallTest {
    @Test
    fun doubleJALR() {
        val prog = Assembler.assemble("""
            jal x0 main
        double:
            add a0 a0 a0
            jalr x0 ra 0
        main:
            addi a0 x0 5
            jal ra double
            add x1 a0 x0
        """)
       val linked = Linker.link(listOf(prog))
       var sim = Simulator(linked.dump())
       sim.run()
       assertEquals(10, sim.state.getReg(1))
    }
}
Add jal and jalr test
Add jal and jalr test

kvakil/venus,kvakil/venus,kvakil/venus