Files
llgo/_demo/c/asmfullcall/asmfullcall_linux.go

31 lines
536 B
Go
Raw Normal View History

//go:build linux && amd64
2025-08-21 11:46:56 +08:00
2025-08-21 11:04:03 +08:00
package main
2025-08-21 11:46:56 +08:00
import "unsafe"
2025-08-21 11:04:03 +08:00
func verify() {
2025-08-21 11:46:56 +08:00
// 0 output & 0 input
asmFull("nop", nil)
// 0 output & 1 input with memory address
addr := uintptr(unsafe.Pointer(&testVar))
asmFull("movq {value}, ({addr})", map[string]any{
"addr": addr,
"value": 43,
})
check(43, testVar)
// 1 output & 1 input
res1 := asmFull("movq {value}, {}", map[string]any{
"value": 41,
})
check(41, int(res1))
res2 := asmFull("leaq ({a},{b}), {}", map[string]any{
2025-08-21 11:46:56 +08:00
"a": 25,
"b": 17,
})
check(42, int(res2))
2025-08-21 11:04:03 +08:00
}