jhallen / cpm

Run CP/M commands in Linux/Cygwin with this Z80 / BDOS / ADM-3A emulator.
Other
108 stars 26 forks source link

Fix bug in overflow flag evaluation for sub ops #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello,

I've fixed a bug related to the computation of the overflow flag in substraction/comparaison operations. Before the fix, the same rule was applied to both addition and substraction whereas, in a substraction op, we need to take into account that the second operand is negated.

Here is a small example:

        org 100h

        ld a,0
        ld b,1
        ld de, mnotset
        sub b
        jp po,notset
        ld de, mset
notset
        ld c,9
        call 5

        jp 0

mset    db 'P/V is set -> bug', 0dh, 0ah, '$'
mnotset db 'P/V is not set -> ok', 0dh, 0ah, '$'