HNHacker News
TopNewBestAskShowJobs

npendleton

21 karma · joined December 17, 2017

submissionscomments
npendleton··on A leap year check in three instructions
Hah, great point!
npendleton··on A leap year check in three instructions
This is so cool!

Terrible nitpick, but this is actually 3 operations, not instructions. On x86 you get 4:

  is_leap_year_fast:
        imul    eax, edi, 1073750999
        and     eax, -1073614833
        cmp     eax, 126977
        setb    al
        ret
On ARM you get a bit more due to instruction encoding:

  is_leap_year_fast:
        ldr     r1, .LCPI0_0
        mul     r0, r0, r1
        ldr     r1, .LCPI0_1
        and     r1, r0, r1
        mov     r0, #0
        cmp     r1, #126976
        movwls  r0, #1
        bx      lr
  .LCPI0_0:
        .long   1073750999
  .LCPI0_1:
        .long   3221352463
Compiler explorer reference: https://godbolt.org/z/7ajYqbT9z
npendleton··on Converting a Git repo from tabs to spaces (2016)
Whoa, it looks like my old patch is getting fixed up properly now! We might be getting this feature https://lore.kernel.org/git/20250501214057.371711-4-gitster@...
npendleton··on ESP32-C2 (ESP8684) Upgrade: More Memory, Storage, and Performance
I agree! Unfortunately the best information appears to be in the individual series datasheets, however I did find this page to be helpful: https://products.espressif.com/#/product-selector
npendleton··on GitHub Git Mirror Down
Update, it's back! 2024-04-11T18:02Z
npendleton··on GitHub Git Mirror Down
The GitHub mirror for git is currently 404'ing (2024-04-11T17:55Z). Here it is yesterday: https://web.archive.org/web/20240410011924/https://github.co...
npendleton··on Knit: Making a Better Make
Might be worth a look at remake, it can help a ton when debugging complex Make setups: https://github.com/rocky/remake
npendleton··on Profiling Newlib-Nano's Memcpy
Post author here, you're correct! thanks for spotting it, I'll fix it now.
npendleton··on Cheap FPGA Development Boards
https://groupgets.com/manufacturers/good-stuff-department/pr... Open source by the talented Greg Davill
npendleton··on NuttX – A POSIX-compliant RTOS for embedded platforms
Thanks Gregory, that's really good info! Appreciate you taking the time to reply (and for all your work on this software, too!).
npendleton··on NuttX – A POSIX-compliant RTOS for embedded platforms
A few bits of trivia for anyone considering NuttX:

  - uses a pure software interrupt and redirects to your ISR's, so you incur additional overhead for all interrupts in your system
  - ships with a homegrown c stdlib, which has several functional/security bugs (ex: vscanf will overflow if you use format specifiers other than [l]i/u), and neglects to provide gcc attributes for arg checking for the printf family functions
  - build system issues $(MAKE) calls in every folder you're building, which makes it terrifically slow (especially noticeable on incremental builds)
  - architecture makes it difficult to write custom drivers without building them into the kernel (eg if you want to use the kernel as a module in your project)
npendleton··on Reverse Engineering Instruments’ File Format
binwalk is a good tool to use for this, especially early analysis: https://github.com/ReFirmLabs/binwalk
npendleton··on All You Need to Know About UML Diagrams
My favorite flavor, plantuml, available with a cheesy (but very convenient) cli wrapper via npm- https://www.npmjs.com/package/node-plantuml The --unicode mode is particularly delightful