Finish number-nonblank
This commit is contained in:
@@ -42,6 +42,26 @@ cat_file:
|
|||||||
mv s2, a0
|
mv s2, a0
|
||||||
li s1, 1
|
li s1, 1
|
||||||
|
|
||||||
|
la t1, number_nonblank
|
||||||
|
lb t1, 0(t1)
|
||||||
|
beqz t1, .LNoNonblankNumbers
|
||||||
|
|
||||||
|
mv a1, s2 # load mod buf size to a1
|
||||||
|
|
||||||
|
beqz s1, 1f
|
||||||
|
la a0, mod_buf_0 # load mod_buf_0 as read buf
|
||||||
|
la a2, mod_buf_1 # load mod_buf_1 as write buf
|
||||||
|
j 2f
|
||||||
|
1:
|
||||||
|
la a0, mod_buf_1 # load mod_buf_1 as read buf
|
||||||
|
la a2, mod_buf_0 # load mod_buf_0 as write buf
|
||||||
|
2:
|
||||||
|
|
||||||
|
call add_line_numbers
|
||||||
|
xori s1, s1, 1 # flip the mod buf to write to
|
||||||
|
mv s2, a1 # update the current byte count
|
||||||
|
.LNoNonblankNumbers:
|
||||||
|
|
||||||
la t1, number
|
la t1, number
|
||||||
lb t1, 0(t1)
|
lb t1, 0(t1)
|
||||||
beqz t1, .LNoNumbers
|
beqz t1, .LNoNumbers
|
||||||
|
|||||||
@@ -120,11 +120,10 @@ add_line_numbers:
|
|||||||
beqz s7, .LLineNumbersSkipEmptyCheck
|
beqz s7, .LLineNumbersSkipEmptyCheck
|
||||||
|
|
||||||
mv t0, s4 # move the current string buf pointer into t0
|
mv t0, s4 # move the current string buf pointer into t0
|
||||||
li t1, 1
|
addi t0, t0, 1 # move the str pointer forward one
|
||||||
sub t0, t0, t1 # move the str pointer back one
|
|
||||||
lb t0, 0(t0)
|
lb t0, 0(t0)
|
||||||
# t4 still contains a newline char
|
# t4 still contains a newline char
|
||||||
beq t0, t4, 1f # if the previous byte IS a newline, skip to writing
|
beq t0, t4, 1f # if the next byte IS a newline, skip to writing
|
||||||
|
|
||||||
.LLineNumbersSkipEmptyCheck:
|
.LLineNumbersSkipEmptyCheck:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user