Files
avo/internal/inst/types.go

62 lines
744 B
Go
Raw Normal View History

2018-11-20 11:44:44 -06:00
package inst
type Instruction struct {
2018-11-21 13:02:18 -06:00
Opcode string
Summary string
Forms []Form
2018-11-20 11:44:44 -06:00
}
type Form struct {
2018-11-23 17:14:18 -06:00
ISA []string
Operands []Operand
2018-11-23 23:48:47 -08:00
ImplicitOperands []ImplicitOperand
2018-11-20 11:44:44 -06:00
}
type Operand struct {
Type string
Action Action
}
2018-11-23 17:14:18 -06:00
type ImplicitOperand struct {
Register string
Action Action
}
2018-11-20 11:44:44 -06:00
type Action uint8
const (
R Action = 0x1
W Action = 0x2
RW Action = R | W
)
2018-11-21 13:02:18 -06:00
func ActionFromReadWrite(r, w bool) Action {
var a Action
if r {
a |= R
}
if w {
a |= W
}
return a
}
func (a Action) Read() bool {
return (a & R) != 0
}
func (a Action) Write() bool {
return (a & W) != 0
}
func (a Action) String() string {
s := ""
if a.Read() {
s += "r"
}
if a.Write() {
s += "w"
}
return s
}