Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wannacu
Copy link
Contributor

@wannacu wannacu commented Aug 9, 2023

No description provided.

MAYUSE(s1); MAYUSE(s3); MAYUSE(s4);
// PF: (((emu->x64emu_parity_tab[(res) / 32] >> ((res) % 32)) & 1) == 0)
ANDw_mask(s3, s1, 0b011011, 0b000010); // mask=0xE0
ANDw_mask(s3, s1, 0, 0b000111); // mask=0xff
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change that? mask 0xE0 or 0xFF LSR 5 give the same result (0x7à

Copy link
Contributor Author

@wannacu wannacu Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, the original code is work, but it looks strange. I thought 0xE0 is equal to trunc(0xff << 5).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ANDw_mask(s3, s1, 0b011011, 0b000010) execute LSL not LSR, I got a mistake

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ANDw_mask just do an AND wisth a constant, there is no LSR/LSL associated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ANDw_mask just do an AND wisth a constant, there is no LSR/LSL associated

I got it, the field immr means rotate.
https://gist.github.com/dinfuehr/51a01ac58c0b23e4de9aac313ed6a06a is helpful, I really shouldn't have ignored it.

Copy link
Owner

@ptitSeb ptitSeb Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Logic Imm computation is not trivial on arm64. I have some plan to write a function to decompose value if possile, bu it's not done yet.

LSRw_REG(s4, s4, s3);
MVNx_REG(s4, s4);
BFIw(xFlags, s4, F_PF, 1);
emit_pf(dyn, ninst, s3, s4, s5);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here, emit_pf was not used and PF was computed inline to avoid the use of another register. Are you sure it was wrong before?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess adding ANDw_REG(s3, s3, s2); after line 299 should fix the computation without the need of the additionnal register.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it was wrong. For example:
int64_t test_32(int r) {
int64_t flags = 0;
asm (
"mov %[_r], %%eax\n"
"test $0x74, %%eax\n"
"mov $0, %%rax\n"
"lahf\n"
"mov %%rax, %[flags]\n"
: [flags] "=m"(flags)
: [_r] "r"(r)
);
return flags;
}

int main() {
assert(0x600 == test_32(0x68));
return 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess adding ANDw_REG(s3, s3, s2); after line 299 should fix the computation without the need of the additionnal register.

Yes, if we caculate the res again, but i think add one sratch register is more clear same as emit_test16 or emit_test8

@ptitSeb ptitSeb merged commit 4474af2 into ptitSeb:main Aug 9, 2023
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

Successfully merging this pull request may close these issues.

2 participants