Bug might be here, as RCX was not incremented:; pData->p++;
lea r11, [rcx+01h]
mov [r8+08h], r11
; inc rcx ; add this to fix that bug
public ReadLine
.code
;ReadLine:
;char * ReadLine(char * restrict dst, int max, DATA * restrict pData)
;rcx dst rdx max r8 pData
ReadLine proc
push rbx
mov rax, rcx ; dst
mov rcx, [r8+08h] ; pData->p
mov r9, [r8+10h] ; pData->end
; if (pData->p >= pData->end)
cmp rcx, r9
; return 0;
jnb @52
; int i = 0;
xor r10d, r10d
; while((i < (max-1)) && (pData->p < pData->end)) {
jmp @3A
; dst[i] = *pData->p;
@16: movsxd r11, r10d
mov bl, [rcx]
mov [rax+r11*1], bl
; pData->p++;
lea r11, [rcx+01h]
mov [r8+08h], r11
; inc rcx ; add this to fix that bug
; if (dst[i++] == '\n')
add r10d, 01h
lea r11d, [r10d-01h]
movsxd r11, r11d
cmp byte ptr [rax+r11*1], 0Ah
jz @49
@3A: lea r11d, [edx-01h]
; (i < (max-1))
cmp r10d, r11d
jnl @49
; (pData->p < pData->end)
cmp rcx, r9
jb @16
; break;
; }
; dst[i] = '\0';
@49: movsxd rdx, r10d
mov byte ptr [rax+rdx*1], 0
jmp @54
@52: xor eax, eax
; return dst;
@54: pop rbx
ret
ReadLine endp
end