diff options
author | Ayke van Laethem <[email protected]> | 2018-10-15 19:37:09 +0200 |
---|---|---|
committer | Ayke van Laethem <[email protected]> | 2018-10-15 19:37:09 +0200 |
commit | 392bba8394ece9e8b90ee2d6e82590b1492bc62d (patch) | |
tree | 8ed23edd34d89cd52c64bd24287bf38636950b7e /src/device | |
parent | 52199f4a14c20cda8c2c33227b5a1d5b593c2934 (diff) | |
download | tinygo-392bba8394ece9e8b90ee2d6e82590b1492bc62d.tar.gz tinygo-392bba8394ece9e8b90ee2d6e82590b1492bc62d.zip |
compiler: add support for parameters to inline assembly
Diffstat (limited to 'src/device')
-rw-r--r-- | src/device/arm/arm.go | 21 | ||||
-rw-r--r-- | src/device/avr/avr.go | 17 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/device/arm/arm.go b/src/device/arm/arm.go index 7f6858fb0..d351348be 100644 --- a/src/device/arm/arm.go +++ b/src/device/arm/arm.go @@ -33,12 +33,25 @@ import ( "unsafe" ) -//go:volatile -type RegValue uint32 +// 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) -type __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{}) -func Asm(s __asm) +//go:volatile +type RegValue uint32 const ( SCS_BASE = 0xE000E000 diff --git a/src/device/avr/avr.go b/src/device/avr/avr.go index ba4347d20..7fa6bf955 100644 --- a/src/device/avr/avr.go +++ b/src/device/avr/avr.go @@ -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{}) |