PeachPy: Assembly Code Generation in High-Level Python
github.com
github.com
I'm certainly seeing a lot of cool projects that make assembly more accessible, not to mention a lot of good guides on the web. As for myself, I've recently made Python ctypes bindings for GNU Lightning, which lets you write architecture agnostic RISC assembly, then JIT to native code on x86, ARM, etc. See https://github.com/cslarsen/lyn/
It's pretty light-weight and JITs fast. The point is that it's very fun and addictive to do assembly from a language like Python.
What you think about LLVM as cross-platform assembly?
Because you skip the boring boilerplate, and go straight to the fun parts!
One of the hardest problems of CS... naming!
How does PeachPY handle loops? I'm looking for examples, but will it generate a label for me and then let me specify the contents only?
Edit: https://github.com/Maratyszcza/PeachPy/blob/master/examples/... !
(Add a bit more, give it some static typing and soon we'll be coding C in Python)
counter = GeneralPurposeRegister64()
MOV(counter, 64)
with Loop() as loop:
...
DEC(counter)
JNZ(loop.begin)KolibriOS http://kolibrios.org/en/
Anything by 2ton and w/ their library https://2ton.com.au/Products/
Gibson's guide on Win32 Assembly w/ links https://www.grc.com/smgassembly.htm
Hyde's AoA and High-level Assembly are cool http://www.plantation-productions.com/Webster/
Or for the elite: 8-bit GUI desktop http://www.symbos.de/
Also, gave me ideas on how to bootstrap a subversion-resistant system. You start with assembler, build a HLA-like tool from that, easily build a 3GL + straight-to-HLA compiler with that, and then use that to build rest (including optimizations). My concept was inspired by Wirth and Jurg's bitslice -> M-code ASM -> Modula 2 -> OS work in Lilith project. Alternatively, you can go MenuetOS or KolibriOS w/ HLA for above benefits. Use full HLA for rapid addition/testing of new features with raw ASM for optimizing the fast paths. Thoughts on either?
http://www.cs.cornell.edu/talc/
http://research.microsoft.com/en-us/um/people/nick/coqasm.pd...
Are you trolling? Assembler hasn't gone anywhere nor will it ever.
[1] http://research.microsoft.com/en-us/um/people/nick/coqasm.pd...
- The old version of PeachPy (on BitBucket and PyPI) supports ARM, but can't directly generate machine code.
- The new version of PeachPy (on GitHub) can directly encode instructions into machine code, but currently only supports x86-64. The files in peachpy.arm module are merely non-working remnants of the old code.
Assembly: mov 0x1,reg2 # put 1 in register 2
Machine Code: 0xAC12 # Move an immediate value into register 2
Assembly: mov *reg2,reg1 # put contents of address in reg2 in reg1
Machine Code: 0xBF201 # Move an indirect value, offset 0, address in reg2 to reg1
It's a much more straightforward transformation than the one from C->ASM though.
Edit: This link might make more sense... the difference is mainly between the mnemonic and the encoding: http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
You'll also notice there are explicit instructions for immediate ops, but no two assembly schemes seem to share the same level of abstraction.