Inline assembly

The device-specific packages like device/avr and device/arm provide Asm functions which you can use to write inline assembly:

  1. arm.Asm("wfi")

You can also pass parameters to the inline assembly:

  1. var result int32
  2. arm.AsmFull(`
  3. lsls {value}, #1
  4. str {value}, {result}
  5. `, map[string]interface{}{
  6. "value": 42,
  7. "result": &result,
  8. })
  9. 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.