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).

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