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

Immediate operand type is seemingly unimplemented #7911

Open
MabryTyson opened this issue Mar 15, 2025 · 1 comment
Open

Immediate operand type is seemingly unimplemented #7911

MabryTyson opened this issue Mar 15, 2025 · 1 comment

Comments

@MabryTyson
Copy link

Describe the bug
I wanted to find instructions with all inputs as Immediate values, using the ghidra.program.model.lang.OperandType.isImmediate(int) method for each operand's type. When it didn't work as expected, I searched the sources for where OperandType.IMMEDIATE was used to set the OperandType and can't find any such use. I would expect it to be used in SleighInstructionPrototype.java.

OperandType.SCALAR is implemented and seems to be set for (some) operands that use the "const" space, but doesn't seem to cover all operands for reasons I don't understand.

I wish the documentation explained what the different types are and how they are determined. If isImmediate is not expected to be usable, perhaps the references to it and OperandType.IMMEDIATE should be removed from the documentation.

I am working with an unsupported cpu, but the example below is for a cpu distributed with Ghidra.

To Reproduce
Steps to reproduce the behavior:

  1. Import the file http://www.easy68k.com/paulrsm/6502/A2ROM.BIN (Apple II ROMs), 6502 code with offset 0xD000.
  2. Get instruction info at 0xD10C (instruction 0x69 0x1f: ADC #0x1f)
    Operand: #0x1f
    Labeled: #0x1f
    Type: DYN
    Scalar: 
    Address:
    Register:
    Op-Objects: const:0x1f
    Operand Mask: 00000000 11111111
    Masked Value: 00000000 00011111

Expected behavior
The OperandType should be Immediate (vs Dynamic).

Note that for a X86-64 cpu, the second operand of AND BH, 0x8 is typed as a Scalar. I don't know why the difference between Dynamic and Scalar for the two operands, both in "const" space.

Attachments
None

Environment:

  • OS: macOS 15.2
  • Java Version: 21.0.5
  • Ghidra Version: 11.3.1
  • Ghidra Origin: official GitHub distro

Additional context
None

@MabryTyson
Copy link
Author

IMMEDIATE is probably not the only operand type to have issues. For instance "QUADWORD" is only found in OperandType.java. (I looked at it because it is documented as "Bit set if the operand is a 8 byte value", which is confusing if a processor has a 4-byte word.)

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

1 participant