1
2
3
4
5 package arm64asm
6
7 import (
8 "strings"
9 )
10
11
12
13 func GNUSyntax(inst Inst) string {
14 switch inst.Op {
15 case RET:
16 if r, ok := inst.Args[0].(Reg); ok && r == X30 {
17 return "ret"
18 }
19 case B:
20 if _, ok := inst.Args[0].(Cond); ok {
21 return strings.ToLower("b." + inst.Args[0].String() + " " + inst.Args[1].String())
22 }
23 case SYSL:
24 result := strings.ToLower(inst.String())
25 return strings.Replace(result, "c", "C", -1)
26 case DCPS1, DCPS2, DCPS3, CLREX:
27 return strings.ToLower(strings.TrimSpace(inst.String()))
28 case ISB:
29 if strings.Contains(inst.String(), "SY") {
30 result := strings.TrimSuffix(inst.String(), " SY")
31 return strings.ToLower(result)
32 }
33 }
34 return strings.ToLower(inst.String())
35 }
36
View as plain text