client__pollin: read as much as possible; client__pollout: do processing

This commit is contained in:
root 2025-05-17 08:10:55 +00:00
parent 8ab750ba97
commit 484d81baa8
3 changed files with 149 additions and 92 deletions

View file

@ -1,43 +1,20 @@
; Returns:
; rax - read(2) length
; rdi - if line is complete, line length;
; if line was incomplete, 0;
; if EOF or read(2) returned an error, undefined
; Errors (in rax):
; -1024 - line too long
; other negative - error from read(2)
; 0 - EOF from read(2)
; rax - if line: line length; otherwise: 0
; Arguments:
; rdi - fd
; rsi - buffer
; rdx - max length
readline:
push rsi
push rdx
mov rax, SYS_READ
syscall
pop rdx
pop rsi
cmp rax, 0
jl return
mov r10, 0
; rdi - buffer
; rsi - max length
scanline:
mov rax, 0
readline__scan:
cmp r10, rdx
jge readline__overflow
cmp r10, rax
jge readline__incomplete_line
mov r11b, [rsi + r10]
add r10, 1
cmp r11b, 0x0a ; '\n'
jne readline__scan
mov rdi, r10
scanline__loop:
cmp rax, rsi
jge scanline__incomplete_line
mov r10b, [rdi + rax]
add rax, 1
cmp r10b, 0x0a ; '\n'
jne scanline__loop
ret
readline__incomplete_line:
mov rdi, 0
ret
readline__overflow:
mov rax, -1024
scanline__incomplete_line:
mov rax, 0
ret