Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,024 of 4,675    |
|    Terje Mathisen to Robert Prins    |
|    Re: Translating blocks of memory contain    |
|    12 Oct 17 10:57:56    |
      From: terje.mathisen@nospicedham.tmsw.no              Robert Prins wrote:       > My strings currently have a length of 47 bytes or less, and as you       > know, I'm coding in Pascal, so not zero-terminated, but with a       > one-byte length preceding the (short)string. I'm using code I copied       > from one of the above URL's, pretty much unaltered,       >       > xor eax, eax       >       > mov esi, utf8 movzx edx, byte ptr [esi] test edx, edx jmp @04       >       > @01: mov cl, [edx + esi]              > shl cl, 1              > js @02              > jc @03       >       > @02: inc eax       >              That's sneaky, you are skipping the increment only when the top bit is       set and not the second, the only problem is the number of branches              > @03: dec edx       >       > @04: jnz @01       >       > It's probably fast enough, given that the program takes 0.28 seconds       > to do what it needs to do, slurp in an 11,430 line 1.2 Mb CSV file,       > and spit out 97,501 lines in seven file with results, totalling       > around 7.3Mb.              The rest of your code is going to dominate, that's pretty clear!              What about code like this, since you already have the count in EDX when       you start:               mov eax,edx              ...                      mov cl,[esi+edx]        sub cl,80h        cmp cl,40h        sbb eax,0              I.e. only if the input char is in the 80-bf range will you get a carry       from the CMP and that carry is subtracted from the original count.              No branches to predict and the same number of instructions.              Terje              --       - |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca