compiler: add support for parameters to inline assembly

This commit is contained in:
Ayke van Laethem
2018-10-15 19:37:09 +02:00
parent 52199f4a14
commit 392bba8394
4 changed files with 123 additions and 17 deletions
+19 -2
View File
@@ -113,8 +113,25 @@ The device-specific packages like ``device/avr`` and ``device/arm`` provide
arm.Asm("wfi")
There is no support yet for inline assembly that takes (register) parameters or
returns a value.
You can also pass parameters to the inline assembly::
var result int32
arm.AsmFull(`
lsls {value}, #1
str {value}, {result}
`, map[string]interface{}{
"value": 42,
"result": &result,
})
println("result:", result)
In general, types are autodetected. That is, integer types are passed as raw
registers and pointer types are passed as memory locations. This means you can't
easily do pointer arithmetic. To do that, convert a pointer value to a
``uintptr``.
Inline assembly support is expected to change in the future and may change in a
backwards-incompatible manner.
Harvard architectures (AVR)