28 lines
722 B
Go
28 lines
722 B
Go
package main
|
|
|
|
import _ "unsafe"
|
|
|
|
//go:linkname asmFull llgo.asm
|
|
func asmFull(instruction string, regs map[string]any) uintptr
|
|
|
|
func main() {
|
|
// no input,no return value
|
|
asmFull("nop", nil)
|
|
// input only,no return value
|
|
asmFull("# test value {value}", map[string]any{"value": 42})
|
|
// input with return value
|
|
res1 := asmFull("mov {}, {value}", map[string]any{
|
|
"value": 42,
|
|
})
|
|
println("Result:", res1)
|
|
// note(zzy): multiple inputs with return value
|
|
// only for test register & constraint,not have actual meaning
|
|
// the ir compare cannot crossplatform currently
|
|
// so just use a comment to test it
|
|
res2 := asmFull("# calc {x} + {y} -> {}", map[string]any{
|
|
"x": 25,
|
|
"y": 17,
|
|
})
|
|
println("Result:", res2)
|
|
}
|