Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I think SBB emulation is broken. #16

Open
AndreasPK opened this issue Oct 23, 2020 · 1 comment
Open

I think SBB emulation is broken. #16

AndreasPK opened this issue Oct 23, 2020 · 1 comment

Comments

@AndreasPK
Copy link

AndreasPK commented Oct 23, 2020

By the spec it's defined as DEST ← (DEST – (SRC + CF));

But I think it's implemented as DEST ← (DEST – SRC + CF);

Reproducible with this snippet.

    MOV EAX, 10
    MOV EBX, -1 ; 
    ADD EBX, 1 ; CF = 1
    SBB EAX, 0 ; EAX = (EAX - (0 + CF)) = EAX - 1 = 9
    ; EAX should be 9, it is 11
@Kobzol
Copy link
Owner

Kobzol commented Oct 23, 2020

Hi, yes, you're right, as I learned recently, the handling of the carry flag is broken for subtraction. A proper fix will require a reimplementation of the ALU logic and number representation. I haven't gotten to it yet, but I'll try to do it once I have some more time. And of course I would welcome PRs 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants