@hackage inline-asm0.3.1.0
Inline some Assembly in ur Haskell!
Installation
Dependencies (9)
- base >=4.7 && <5
- bytestring
- containers
- either
- ghc-prim
- megaparsec Show all…
Dependents (0)
inline-asm
When inline C is too safe.
Did you try inline-c, but it's not enough? You need more? Nothing seems to satisfy?
inline-asm to the rescue!
For now the usage is pretty straightforward: use defineAsmFun to define the
corresponding function, like
defineAsmFun "timesTwo" [t| Word -> Word |] "add %rbx, %rbx"
and then use the function timesTwo as any other function of type Word -> Word:
main = print $ timesTwo 21
There is also an alternative notation allowing named arguments to avoid remembering which arguments are passed in which registers:
defineAsmFun "swap2p1"
[asmTy| (a : Int) (b : Int) | (_ : Int) (_ : Int)]
[asm|
xchg ${a}, ${b}
add $1, ${b}
|]