Add stdin cat
This commit is contained in:
+16
-11
@@ -107,9 +107,9 @@ has_switch:
|
||||
mv s1, a1
|
||||
|
||||
call fetch_argc
|
||||
bnez a0, 1f
|
||||
bnez a0, .LHasSwitchNoParse
|
||||
li t0, 2
|
||||
blt a1, t0, 1f # if we have no commands other than the binary, we know there will be no switches
|
||||
blt a1, t0, .LSwitchNotFoundNoParse # if we have no commands other than the binary, we know there will be no switches
|
||||
|
||||
addi sp, sp, -24
|
||||
sd s4, 16(sp)
|
||||
@@ -118,7 +118,7 @@ has_switch:
|
||||
li s2, 1 # load first non-base command arg
|
||||
mv s4, a1 # put argc in s4
|
||||
|
||||
2:
|
||||
.LSwitchProcessNextArg:
|
||||
mv a0, s2
|
||||
call fetch_argv
|
||||
mv s3, a1 # save argv buff addr
|
||||
@@ -126,32 +126,37 @@ has_switch:
|
||||
mv a0, s3 # load argv buff addr into a0 (string 0)
|
||||
mv a1, s0 # move switch ptr 1 addr into a1 (string 1)
|
||||
call _str_cmp
|
||||
bnez a1, 5f # if the strings match, exit loop
|
||||
bnez a1, .LSwitchFound # if the strings match, exit loop
|
||||
|
||||
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, 5f # if the strings match, exit loop
|
||||
bnez a1, .LSwitchFound # if the strings match, exit loop
|
||||
|
||||
addi s2, s2, 1 # if string doesn't match we inc to the next arg
|
||||
blt s2, s4, 2b # keep going while we have untested args
|
||||
blt s2, s4, .LSwitchProcessNextArg # keep going while we have untested args
|
||||
|
||||
4:
|
||||
.LSwitchNotFound:
|
||||
li a0, 0
|
||||
li a1, 0
|
||||
j 3f
|
||||
j .LSwitchFreeSP
|
||||
|
||||
5:
|
||||
.LSwitchNotFoundNoParse:
|
||||
li a0, 0
|
||||
li a1, 0
|
||||
j .LHasSwitchNoParse
|
||||
|
||||
.LSwitchFound:
|
||||
li a0, 0
|
||||
li a1, 1
|
||||
|
||||
3:
|
||||
.LSwitchFreeSP:
|
||||
ld s3, 0(sp)
|
||||
ld s2, 8(sp)
|
||||
ld s4, 16(sp)
|
||||
addi sp, sp, 24
|
||||
|
||||
1:
|
||||
.LHasSwitchNoParse:
|
||||
ld ra, 16(sp)
|
||||
ld s1, 8(sp)
|
||||
ld s0, 0(sp)
|
||||
|
||||
Reference in New Issue
Block a user