Complete line numbers
This commit is contained in:
@@ -93,12 +93,34 @@ add_line_numbers:
|
||||
li s2, 0 # set the str buf char offset to 0
|
||||
li s3, 0 # set the mod buf char offset to 0
|
||||
mv s5, a2 # move mod buf addr into s5
|
||||
|
||||
# there is always one line number at the very start
|
||||
call _inc_line_count
|
||||
li t2, 0 # lc char buf offset
|
||||
li t3, 6 # lc char buf max offset
|
||||
la t1, line_count # load the line count buffer addr
|
||||
add s6, s5, s3 # update mod buf + offset addr
|
||||
4:
|
||||
add t4, t1, t2
|
||||
lb t5, 0(t4)
|
||||
sb t5, 0(s6) # mod buf[s4] = t4
|
||||
addi t2, t2, 1
|
||||
addi s3, s3, 1
|
||||
add s6, s5, s3 # update mod buf + offset addr
|
||||
blt t2, t3, 4b
|
||||
li t5, 0x9 # tab character
|
||||
sb t5, 0(s6)
|
||||
addi s3, s3, 1
|
||||
|
||||
.LLineNumbersProcessChunk:
|
||||
add s4, s0, s2 # Calculate the offset address
|
||||
lb t6, 0(s4)
|
||||
li t4, 0xA # newline
|
||||
bne t6, t4, 1f # if the current byte is not a newline, skip to writing
|
||||
mv t0, s2
|
||||
addi t0, t0, 1 # move ahead one char and see if EOF
|
||||
bge t0, s1, 1f # if the newline is at the veyr end, we don't indicate a new line number
|
||||
|
||||
|
||||
call _inc_line_count
|
||||
|
||||
@@ -121,7 +143,7 @@ add_line_numbers:
|
||||
add s6, s5, s3 # update mod buf + offset addr
|
||||
blt t2, t3, 3b
|
||||
|
||||
li t5, 0x7 # tab character
|
||||
li t5, 0x9 # tab character
|
||||
sb t5, 0(s6)
|
||||
|
||||
addi s3, s3, 1
|
||||
|
||||
Reference in New Issue
Block a user