Skip to content

Commit a8c1194

Browse files
committed
Implemented CMP
1 parent d6db83e commit a8c1194

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

dispatch.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ var opcodes = [][]opcode{
5454
[]opcode{ /* 0x8... */ },
5555
[]opcode{ /* 0x9... */ },
5656
[]opcode{ /* 0xA... */ },
57-
[]opcode{ /* 0xB... */ },
57+
[]opcode{ /* 0xB... */
58+
{0xB000, 0xF100, opCmp},
59+
},
5860
[]opcode{ /* 0xC... */
5961
{0xC100, 0xF1F0, opAbcd},
6062
},

opb.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package m68k
2+
3+
// opCmp implements CMP (pg. 4-75)
4+
func opCmp(c *Processor) (t *stepTrace) {
5+
t = &stepTrace{
6+
addr: c.PC,
7+
op: "cmp",
8+
n: 1,
9+
sz: c.op & 0x1c >> 6,
10+
}
11+
c.PC += 2
12+
13+
ea := decodeEA(c.op)
14+
reg := c.op & 0x0E00 >> 9
15+
16+
var a, b Int
17+
a = NewInt(c.D[reg], int(t.sz))
18+
b, t.src, t.err = c.readInt(ea, t.sz)
19+
20+
a = a.Sub(b)
21+
c.SR &= 0xFFFFFFF0
22+
c.SR |= a.Status()
23+
return
24+
}

0 commit comments

Comments
 (0)