Reputation: 1699
I'm learning how to write assembly with Go, and I'm not very familiar with assembly. I'm trying to understand how to read from a model-specific register, and I'm running into errors.
// main.go
package main
import (
"fmt"
)
func readmsr(register int64) int64
func main() {
fmt.Println(readmsr(0xC0000080))
}
// intrinsics_amd64.s
// readmsr(register int64) int64
TEXT ·readmsr(SB), $0-24
RDMSR register+0(FP), AX
MOVQ AX, ret+16(FP)
RET
When I try to compile the code, I get these errors:
go build -v .
_/gopath/go/workspace/temp
# _/gopath/go/workspace/temp
asm: invalid instruction: 00000 (/gopath/go/workspace/temp/instrinsics_amd64.s:3) RDMSR register+8(FP), AX
asm: assembly failed
Looking the op codes in the x86asm package, it looks like RDMSR
is a supported instruction, at least from what I can tell.
I am not very familiar with assembly, so I'm unsure if what I am doing wrong is wrong in assembly or wrong in Go. Can you please help me understand what I'm doing wrong and why it's wrong?
Upvotes: 0
Views: 168