Can you shrink it further?
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 11 08:01:42 PDT 2016
On Tuesday, 11 October 2016 at 14:49:28 UTC, Matthias Bentrup
wrote:
>
> This is the result I'd like to get, but I can't find a way to
> write it without inline assembly :(
>
> void popFrontAsmIntel(ref char[] s) @trusted pure nothrow {
> immutable c = s[0];
> if (c < 0x80) {
> s = s[1 .. $];
> } else {
> uint l = void;
> asm pure nothrow @nogc {
> mov EAX, 1;
> mov BL, 0xf8-1;
> sub BL, c;
> cmp BL, 0xf8-0xc0;
> adc EAX, 0;
> cmp BL, 0xf8-0xe0;
> adc EAX, 0;
> cmp BL, 0xf8-0xf0;
> adc EAX, 0;
> mov l, EAX;
> }
> s = s[l <= $ ? l : $ .. $];
> }
> }
This takes 180us.
Baseline takes 124us.
More information about the Digitalmars-d
mailing list