From dbb11cdcde7d90cab20cc552218e1811781a92ae Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 5 Jun 2017 19:59:23 +0200 Subject: Make lint happy --- parse.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'parse.go') diff --git a/parse.go b/parse.go index da363f0..1a768c6 100644 --- a/parse.go +++ b/parse.go @@ -6,6 +6,7 @@ import ( "os" ) +// ReadBin file func ReadBin(fname string) ([]uint16, error) { fd, err := os.Open(fname) if err != nil { @@ -24,6 +25,7 @@ func ReadBin(fname string) ([]uint16, error) { return body, nil } +// Decode instruction func Decode(v uint16) Instruction { switch { case v&(1<<15) != 0: @@ -40,34 +42,40 @@ func Decode(v uint16) Instruction { return nil } +// Instruction interface type Instruction interface { isInstruction() } +// Lit is a literal type Lit uint16 func newLit(v uint16) Lit { return Lit(v &^ uint16(1<<15)) } func (v Lit) String() string { return fmt.Sprintf("LIT %0.4X", uint16(v)) } func (v Lit) isInstruction() {} +// Jump is an unconditional branch type Jump uint16 func newJump(v uint16) Jump { return Jump(v &^ uint16(7<<13)) } func (v Jump) String() string { return fmt.Sprintf("UBRANCH %0.4X", uint16(v<<1)) } func (v Jump) isInstruction() {} +// Cond is a conditional branch type Cond uint16 func newCond(v uint16) Cond { return Cond(v &^ uint16(7<<13)) } func (v Cond) String() string { return fmt.Sprintf("0BRANCH %0.4X", uint16(v<<1)) } func (v Cond) isInstruction() {} +// Call procedure type Call uint16 func newCall(v uint16) Call { return Call(v &^ uint16(7<<13)) } func (v Call) String() string { return fmt.Sprintf("CALL %0.4X", uint16(v<<1)) } func (v Call) isInstruction() {} +// ALU instruction type ALU struct { Opcode uint16 RtoPC bool @@ -104,25 +112,25 @@ var opcodes = []string{ "N>T", "T-1", "R", "[T]", "N<