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

Allow signed immediates to be matched by IsIMMX functions #182

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions operand/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,30 @@ func IsIMM2U(op Op) bool {

// IsIMM8 returns true is op is an 8-bit immediate.
func IsIMM8(op Op) bool {
_, ok := op.(U8)
return ok
_, uok := op.(U8)
_, iok := op.(I8)
return uok || iok
}

// IsIMM16 returns true is op is a 16-bit immediate.
func IsIMM16(op Op) bool {
_, ok := op.(U16)
return ok
_, uok := op.(U16)
_, iok := op.(I16)
return uok || iok
}

// IsIMM32 returns true is op is a 32-bit immediate.
func IsIMM32(op Op) bool {
_, ok := op.(U32)
return ok
_, uok := op.(U32)
_, iok := op.(I32)
return uok || iok
}

// IsIMM64 returns true is op is a 64-bit immediate.
func IsIMM64(op Op) bool {
_, ok := op.(U64)
return ok
_, uok := op.(U64)
_, iok := op.(I64)
return uok || iok
}

// IsAL returns true if op is the AL register.
Expand Down
6 changes: 6 additions & 0 deletions operand/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ func TestChecks(t *testing.T) {

{IsIMM64, Imm((1 << 64) - 1), true},

// Signed Immediates
{IsIMM8, I8(-1), true},
{IsIMM16, I16(-1), true},
{IsIMM32, I32(-1), true},
{IsIMM64, I64(-1), true},

// Specific registers
{IsAL, reg.AL, true},
{IsAL, reg.CL, false},
Expand Down