|
Plastic Jesus posted:Suggestions? Does any of this make any sense at all? If you say you're looking into asm as well, the x86 asm code has instructions specifically for finding bytes in strings. You should look at REP SCANSB for your task, something like this maybe: mov edi, _string ;your string mov ecx, [string_length] ;your string's length mov al, 0 repnz scansb ;the magic, scan for 0 jnz not_found mov [pointer_to_result], edi jmp exit_point not_found: movd [pointer_to_result], 0 exit_point: I'm pretty sure nothing a compiler outputs is as efficient as the processor's string scaning instructions. I'm not really experinced in inlining the asm in various compilers though, the syntax is very different between Intel and that AT&T syntax GCC uses.
|
# ¿ Mar 22, 2008 10:47 |
|
|
# ¿ Apr 29, 2024 17:22 |
|
Plastic Jesus posted:I thought about this, but the byte of interest will be part of an integer (and in a register already), not a string of characters. Ok, i misunderstood i thought you were just trying to find the zeros in an array of bytes (your "puc" pointer). If your integer is in a register the best i can think of is to use shift to right, and compare the byte-sized "low" registor to 0. ;integer in eax ... mov ecx, 4 test_loop: cmp al, 0 jz found_zero shr eax, 8 loop test_loop found_zero: ... ;position of byte (1-4) in ecx As for the strlen question, sorry i never checked.
|
# ¿ Mar 22, 2008 21:37 |
|
I'm using read( write( to transfer data through a blocking stream socket in C, on Linux. Both client and server. What i want to know is will the reads on the client and writes on the server match in size (as long as it is within the maximum receive buffer size ?). Or will the data come fragmented based on packet size, network issues and such and i'd have to rebuild it at the other end ?
|
# ¿ Apr 30, 2014 07:52 |