Skip to content

SBC HL,rr writes its result to A instead of HL #12

Description

@xusheng6

In Z80IL.py, OP.SBC computes the subtraction at the operand size but always stores to A as one byte:

tmp = il.sub_borrow(size, lhs, rhs, il.flag("c"), flags="*")
tmp = il.set_reg(1, "A", tmp)

So ed 42 (SBC HL,BC) lifts as A = sbb.w{*}(HL, BC, flag:c) and the 16-bit result never reaches HL.

16-bit compare/subtract is common, so this silently drops pointer arithmetic — 39 sites in one test binary. Example: AND A / SBC HL,BC / LD A,(HL).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions