hex.input_ptr_lineΒΆ
Reads bytes from input into the pointed buffer, until a '\n' or a 0-byte (EOF); writes the byte count into len[:w/4].
SignatureΒΆ
def input_ptr_line ptr, len @ loop, store, finish, wptr, bytebuf, nl, end { ... }
Defined in hex/strings.fj β lines 9β27 (view on GitHub).
ComplexityΒΆ
Time:
len(w(0.75@+5) + 39@+79)Space:
w(2.25@+44) + 34@+381
See the complexity glossary for what @, w, dw, dbit, n mean.
Requires initΒΆ
The following must be initialised before this macro is invoked:
hex.init and stl.ptr_init (or stl.startup_and_init_all).
SourceΒΆ
Click to view the macro body
def input_ptr_line ptr, len @ loop, store, finish, wptr, bytebuf, nl, end {
.mov w/4, wptr, ptr
.zero w/4, len
loop:
.input bytebuf
.if0 2, bytebuf, finish // 0-byte = EOF
.cmp 2, bytebuf, nl, store, finish, store // == '\n' -> stop
store:
.write_byte_and_inc wptr, bytebuf
.inc w/4, len
;loop
finish:
;end
wptr: .vec w/4
bytebuf: .vec 2
nl: .vec 2, '\n'
end:
}
Depends onΒΆ
Next: hex.print_ptr_text β