Binaries for both Input and Output
The hit-count for "offset" was reduced to 459, using strstr() - case
However, all bytes being pulled so it's not an issue.
I_stream.asm
;
; build: asmc -pe I_stream.asm
;
.x64
.model flat, fastcall
option win64:3
option dllimport:<msvcrt>
exit proto :qword
printf proto :ptr, :vararg
fprintf proto :ptr, :ptr, :vararg
fopen proto :ptr, :ptr
fclose proto :ptr
fgets proto :ptr, :dword, :ptr
perror proto :ptr
strstr proto :ptr, :ptr
option dllimport:<kernel32>
GetTickCount proto
option dllimport:NONE
.code
main proc
local buffer[256]:byte
.if fopen("source.txt", "rt")
mov rsi,rax
xor rdi,rdi
lea r12,buffer
mov rbx,GetTickCount()
.while fgets(r12, 256, rsi)
.if strstr(r12, "offset")
inc rdi
.endif
.endw
fclose(rsi)
sub GetTickCount(),rbx
printf("Hits(%d), TickCount(%d)\n", rdi, rax)
.else
perror("source.txt")
.endif
exit(0)
main endp
END main
I0_stream.asm
;
; build: asmc -pe IO_stream.asm
;
.x64
.model flat, fastcall
option win64:3
option dllimport:<msvcrt>
exit proto :qword
printf proto :ptr, :vararg
fprintf proto :ptr, :ptr, :vararg
fopen proto :ptr, :ptr
fclose proto :ptr
fgets proto :ptr, :dword, :ptr
perror proto :ptr
option dllimport:<kernel32>
GetTickCount proto
option dllimport:NONE
.code
main proc
local buffer[256]:byte
.if fopen("source.txt", "rt")
mov rsi,rax
.if fopen("result.txt", "wt+")
mov rdi,rax
mov r13,GetTickCount()
xor rbx,rbx
lea r12,buffer
.while fgets(r12, 256, rsi)
inc rbx
fprintf(rdi, "%d %s", rbx, r12)
.endw
fclose(rdi)
fclose(rsi)
sub GetTickCount(),r13
printf("TickCount(%d)\n", rax)
.else
fclose(rsi)
perror("result.txt")
.endif
.else
perror("source.txt")
.endif
exit(0)
main endp
END main
EDIT: buffer 128 to 256...