Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/released_programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ Year: 2013

Source: Yes

Link: [http://www.boriel.com/forum/post4353.html#p4353](http://www.boriel.com/forum/post4353.html#p4353)
Link: [https://www.boriel.com/forum/showthread.php?tid=529&pid=3334#pid3334](https://www.boriel.com/forum/showthread.php?tid=529&pid=3334#pid3334)

![P3efilebrowser.png](./img/games/p3efilebrowser.png)

Expand All @@ -1075,7 +1075,7 @@ Year: 2014

Source: Yes

Link: [http://www.boriel.com/forum/gallery/show-off-your-creativity-t578-45.html#p5341](http://www.boriel.com/forum/gallery/show-off-your-creativity-t578-45.html#p5341)
Link: [https://www.boriel.com/forum/showthread.php?tid=299&pid=4142#pid4142](https://www.boriel.com/forum/showthread.php?tid=299&pid=4142#pid4142)

![MultiIOboard.png](./img/games/multiioboard.png)

Expand All @@ -1090,7 +1090,7 @@ Year: 2015

Source: No

Link: [http://www.boriel.com/forum/gallery/the-spectrum-client-t972.html](http://www.boriel.com/forum/gallery/the-spectrum-client-t972.html)
Link: [https://www.boriel.com/forum/showthread.php?tid=644](https://www.boriel.com/forum/showthread.php?tid=644)

![TheSpectrumClient.png](./img/games/thespectrumclient.png)

Expand Down
2 changes: 2 additions & 0 deletions src/arch/zx48k/optimizer/cpustate.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,12 +687,14 @@ def execute(self, asm_code):

if i == 'neg':
if self.getv('a') is None:
self.set('a', None)
self.set_flag(None)
return

val = -self.getv('a')
self.set('a', val)
self.Z = int(not val)
self.C = int(not self.Z)
val &= 0xFF
self.S = val >> 7
return
Expand Down
36 changes: 35 additions & 1 deletion tests/arch/zx48k/optimizer/test_cpustate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def _eval(self, code):
def regs(self):
return self.cpu_state.regs

@property
def mem(self):
return self.cpu_state.mem

def test_cpu_state_ld_a_unknown(self):
code = """
ld a, (_N)
Expand Down Expand Up @@ -349,7 +353,7 @@ def test_ex_de_hl(self):
self.assertEqual(self.regs['d'], str(0x12))
self.assertEqual(self.regs['e'], str(0x34))

def test_ex_de_hl_unkown(self):
def test_ex_de_hl_unknown(self):
code = """
ld hl, (x)
ld de, (y)
Expand All @@ -362,3 +366,33 @@ def test_ex_de_hl_unkown(self):
self.assertEqual(self.regs['l'], helpers.LO16_val(self.cpu_state.mem['y']))
self.assertEqual(self.regs['d'], helpers.HI16_val(self.cpu_state.mem['x']))
self.assertEqual(self.regs['e'], helpers.LO16_val(self.cpu_state.mem['x']))

def test_neg_nz(self):
code = """
xor a
ld a, 1
neg
"""
self._eval(code)
self.assertEqual(self.regs['a'], str(0xFF))
self.assertEqual(self.cpu_state.C, 1)
self.assertEqual(self.cpu_state.Z, 0)

def test_neg_z(self):
code = """
xor a
cp 1
neg
"""
self._eval(code)
self.assertEqual(self.regs['a'], str(0))
self.assertEqual(self.cpu_state.C, 0)
self.assertEqual(self.cpu_state.Z, 1)

def test_ix_neg(self):
code = """
ld a, (ix-1)
neg
"""
self._eval(code)
self.assertNotEqual(self.regs['a'], self.mem['ix-1'])