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
+17 -4
View File
@@ -33,13 +33,26 @@ import (
"unsafe"
)
// Run the given assembly code. The code will be marked as having side effects,
// as it doesn't produce output and thus would normally be eliminated by the
// optimizer.
func Asm(asm string)
// Run the given inline assembly. The code will be marked as having side
// effects, as it would otherwise be optimized away. The inline assembly string
// recognizes template values in the form {name}, like so:
//
// arm.AsmFull(
// "str {value}, {result}",
// map[string]interface{}{
// "value": 1
// "result": &dest,
// })
func AsmFull(asm string, regs map[string]interface{})
//go:volatile
type RegValue uint32
type __asm string
func Asm(s __asm)
const (
SCS_BASE = 0xE000E000
NVIC_BASE = SCS_BASE + 0x0100
+13 -4
View File
@@ -1,9 +1,18 @@
package avr
// Magic type recognozed by the compiler to mark this string as inline assembly.
type __asm string
// Run the given assembly code. The code will be marked as having side effects,
// as it doesn't produce output and thus would normally be eliminated by the
// optimizer.
func Asm(asm __asm)
func Asm(asm string)
// Run the given inline assembly. The code will be marked as having side
// effects, as it would otherwise be optimized away. The inline assembly string
// recognizes template values in the form {name}, like so:
//
// avr.AsmFull(
// "str {value}, {result}",
// map[string]interface{}{
// "value": 1
// "result": &dest,
// })
func AsmFull(asm string, regs map[string]interface{})