Live data from Hacker News

A Foray into Go Assembly Programming

blog.sgmansfield.com

11–20 of 21 posts

Re: A Foray into Go Assembly Programming

#11
post #7

Here's a good talk about the Go assembler backend: https://www.youtube.com/watch?v=KINIAgRpkDA Spoiler: they're nearly to the point (maybe now they've achieved it fully) of autogenerating a new language backend from ISA documentation PDFs! Bring that up next time someone complains about Go not using LLVM.

Does this make targeting new ISA's trivial?

Re: A Foray into Go Assembly Programming

#12
If writing assembly code to run in the Go environment, and you're changing pointers, you have to write garbage-collector aware code.[1][2] Go has concurrent garbage collection, which means there are some unusual constraints on code that manipulates pointers.

This is an area where proofs of correctness are considered necessary, because intuition fails. See [3]

[1] https://blog.golang.org/go15gc [2] https://golang.org/src/runtime/mbarrier.go [3] https://github.com/golang/proposal/blob/master/design/17503-...

Re: A Foray into Go Assembly Programming

#14
post #7

Here's a good talk about the Go assembler backend: https://www.youtube.com/watch?v=KINIAgRpkDA Spoiler: they're nearly to the point (maybe now they've achieved it fully) of autogenerating a new language backend from ISA documentation PDFs! Bring that up next time someone complains about Go not using LLVM.

Does this make targeting new ISA's trivial?

Not really, writing a good enough formal ISA spec is quite hard. More so if the architecture is quirky.

Re: A Foray into Go Assembly Programming

#15

> In this case, a divide by 3 is equivalent to multiplying by 0x55555556 and then taking the top half of the output. What the fuck. That's amazing!

In that case, fixed point arithmetic might blow your mind. :)

https://en.wikipedia.org/wiki/Fixed-point_arithmetic

Re: A Foray into Go Assembly Programming

#16

> In this case, a divide by 3 is equivalent to multiplying by 0x55555556 and then taking the top half of the output. What the fuck. That's amazing!

In more general terms, take a look at Montgomery multiplication[1] which is where this trick originates. It's a common technique used by compilers to optimise away divisions.

[1] https://en.wikipedia.org/wiki/Montgomery_modular_multiplicat...

Re: A Foray into Go Assembly Programming

#19
post #17

"I literally copy-paste the middot every time. Who has a middot key?" I did too, until I found. http://middot.net/

As that site indicates, in X.org with the defaults, '·' is easily typed with 'Compose . -', 'Compose . ^' or 'Compose ^ .' (this should also work from the console in Debian, at least, which uses xkb bindings throughout).

I love the Compose key, and don't think I'll ever use a desktop without it.

Post reply on HN