...
1
16
17 package jit
18
19 import (
20 `github.com/twitchyliquid64/golang-asm/asm/arch`
21 `github.com/twitchyliquid64/golang-asm/obj`
22 )
23
24 var (
25 _AC = arch.Set("amd64")
26 )
27
28 func As(op string) obj.As {
29 if ret, ok := _AC.Instructions[op]; ok {
30 return ret
31 } else {
32 panic("invalid instruction: " + op)
33 }
34 }
35
36 func Imm(imm int64) obj.Addr {
37 return obj.Addr {
38 Type : obj.TYPE_CONST,
39 Offset : imm,
40 }
41 }
42
43 func Reg(reg string) obj.Addr {
44 if ret, ok := _AC.Register[reg]; ok {
45 return obj.Addr{Reg: ret, Type: obj.TYPE_REG}
46 } else {
47 panic("invalid register name: " + reg)
48 }
49 }
50
51 func Ptr(reg obj.Addr, offs int64) obj.Addr {
52 return obj.Addr {
53 Reg : reg.Reg,
54 Type : obj.TYPE_MEM,
55 Offset : offs,
56 }
57 }
58
59 func Sib(reg obj.Addr, idx obj.Addr, scale int16, offs int64) obj.Addr {
60 return obj.Addr {
61 Reg : reg.Reg,
62 Index : idx.Reg,
63 Scale : scale,
64 Type : obj.TYPE_MEM,
65 Offset : offs,
66 }
67 }
68
View as plain text