Add version switch

This commit is contained in:
2026-09-13 17:59:07 -04:00
parent fcd9109ef6
commit cec608f19c
2 changed files with 50 additions and 17 deletions
+3 -1
View File
@@ -94,7 +94,7 @@ fetch_argv:
# Check if flag was given
# @param[in] a0: ptr to null-terminated switch 1 (ie. -h).
# @param[in] a1: ptr to null-terminated switch 2 (ie. --help) (optional).
# @param[in] a1: ptr to null-terminated switch 2 (ie. --help) (optional, pass 0 for none).
# @param[out] a0: result code.
# @param[out] a1: was found (0-not found, 1-found).
has_switch:
@@ -127,12 +127,14 @@ has_switch:
mv a1, s0 # move switch ptr 1 addr into a1 (string 1)
call _str_cmp
bnez a1, .LSwitchFound # if the strings match, exit loop
beqz s1, .LSkipSecondSwitch # if we have no second switch, skip the check
mv a0, s3 # move argv buff addr into a0 (string 0)
mv a1, s1 # move switch ptr 2 addr into a1 (string 1)
call _str_cmp
bnez a1, .LSwitchFound # if the strings match, exit loop
.LSkipSecondSwitch:
addi s2, s2, 1 # if string doesn't match we inc to the next arg
blt s2, s4, .LSwitchProcessNextArg # keep going while we have untested args