HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
414owen
blog-code
Assembly2023–2023
414owen / blog-code

blog-code

Discover this repository through its Hacker News conversations.

2Distinct people
2Mentions
0Explicit recommenders
9GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A public description has not been verified.

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by hour2 dated mentions

Observed mentions: 2023-07-06 22:01:48 UTC to 2023-07-06 22:31:16 UTC.

0122023-07-06 22:00:00 UTC to 2023-07-06 23:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 commentsJul 6, 22:00

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC. One observed period does not establish a trend.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Jul 6, 22:002023-07-06 22:00:00 UTC2023-07-06 23:00:00 UTC202

What Hacker News says

2 sources
> I assume that their test input (which isn't described in the post, and is also not in their GitHub repo) consists of random strings consisting almost entirely of s and p characters. test code is here: https://github.com/414owen/blog-code/blob/master/02-the-same... it randomly selects between 's' or 'p'. The characters can't be anything other than 's', 'p', or the terminating null. Knowing that particular fact about our input gives us this ...clever... optimization: int run_switches(const char* s) { int result = 0; while (*s) result += (1 | *s++) - 'r'; return result; } which compiles to: run_switches: movzx eax, BYTE PTR [rdi] xor edx, edx test al, al je .L1 .L3: or eax, 1 inc rdi
Read the rest
movsx eax, al lea edx, [rdx-114+rax] movzx eax, BYTE PTR [rdi] test al, al jne .L3 .L1: mov eax, edx ret This is too clever by half, of course, but it perfectly illustrates your point about exploiting properties of the data.
In {n} times faster than C
> because without FDO (or PGO) the compiler has no idea how likely each branch is to be taken So, the maximum amount of times you can hit '\0' is once in the string, because then the function returns, but you can hit the other characters many times, which seems to be information a compiler has access to without PGO. PGO does help, of course, and on my machine gives me 2.80s, which is better than the code at the end of the `Rearranging blocks` section :) > I assume that their test input (which isn't described in the post, and is also not in their GitHub repo) It's described under `Benchmarking setup`, and is in the repository here: https://github.com/414owen/blog-code/blob/master/01-six-time... Side note: There's a part two to this post (linked at the bottom) where I make the C code as fast as I possibly can, and it beats all the assembly
Read the rest
in this post. I never said writing assembly is (necessarily) a good idea, I just find optimizing it, and deciphering compiler output, an interesting challenge, and a good learning opportunity.
In {n} times faster than C

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.