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

code is ran all over again after exit #372

Open
bsuvonov opened this issue Oct 7, 2024 · 0 comments
Open

code is ran all over again after exit #372

bsuvonov opened this issue Oct 7, 2024 · 0 comments

Comments

@bsuvonov
Copy link

bsuvonov commented Oct 7, 2024

Here is the code that works fine:

main:
    addi x9, x0, 30    # size = 30, change this for demo
    add x10, x0, x18   # x10 = 0 + x18, x18 is tempArray[0]
    jal x1, assign
    jal x0, exit
assign:
    # x10 holds the base address where the array should be stored
    addi x5, x0, 31
    sw x5, 0(x10)
    addi x5, x0, 7
    sw x5, 4(x10)
    addi x5, x0, 16
    sw x5, 8(x10)
    jalr x0, x1(0)
 exit: 
     li a7, 93     # Load the syscall number for exit into a7
     li a0, 0      # Load the exit status into a0 (0 typically means success)
     ecall

If you store a few more integers in memory in assign function, then ripes doesnt stop running the code. Once exit is reached, it starts from top of the code again.

Here is the code that runs infinitely:

main:
    addi x9, x0, 30    # size = 30, change this for demo
    add x10, x0, x18   # x10 = 0 + x18, x18 is tempArray[0]
    jal x1, assign
    jal x0, exit
assign:
    # x10 holds the base address where the array should be stored
    addi x5, x0, 31
    sw x5, 0(x10)
    addi x5, x0, 7
    sw x5, 4(x10)
    addi x5, x0, 16
    sw x5, 8(x10)
    addi x5, x0, 4
    sw x5, 12(x10)
    jalr x0, x1(0)
 exit: 
     li a7, 93     # Load the syscall number for exit into a7
     li a0, 0      # Load the exit status into a0 (0 typically means success)
     ecall

You can store more variables in the same way and issue still insists.

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

1 participant