RISC-V Implementation for Absolute Value of an integer

I am trying to write some RISC-V (standard) code that will calculate the absolute value of an integer. My unit tests are failing so i am not sure where the bug in my logic is. Does anybody have any advice?

.globl abs

.text
# =================================================================
# FUNCTION: Given an int return its absolute value.
# Arguments:
# 	a0 (int) is input integer
# Returns:
#	a0 (int) the absolute value of the input
# =================================================================
abs:
    # Prologue

    # return 0
    mv a0, zero

    # Epilogue

    ret

More questions in this forum