BIT opcode not lifted correctly

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by locating the Python handler for decoded.op == OP.BIT and the il.and_expr call shown in the issue. Compare the lifted flags with Z80 BIT semantics, then verify that the resulting IL sets Z from the tested bit while setting H and clearing N.

Written by the indexing model from the issue text.

Description

need to set H, unset N, and set Z based on the bit, can probably just change the op that is appended:

    elif decoded.op == OP.BIT:
        assert oper_type == OPER_TYPE.IMM
        assert oper_val >= 0 and oper_val <= 7
        mask = il.const(1, 1<<oper_val)
        operand = operand_to_il(operb_type, operb_val, il, 1)
-         il.append(il.and_expr(1, operand, mask, flags='*'))
+         il.append(il.and_expr(1, operand, mask, flags='z'))

and then manually set the other 2 flags

image

Dominant language
Python
Stars
12
Forks
5
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Vector35/Z80

All issues in Vector35/Z80

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.