Skip to content

Commit

Permalink
Merge pull request #3 from xyjixyjixyji/master
Browse files Browse the repository at this point in the history
popcnt and div
  • Loading branch information
sisshiki1969 authored Oct 23, 2024
2 parents 4176670 + 5925cd9 commit 17a1833
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions monoasm_macro/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ pub fn compile(inst: Inst) -> TokenStream {
}
}

Inst::Div(op) => {
// DIV r/m64: RAX <- RAX / r/m64
match op {
// DIV r/m64
// REX.W F7 /6
op => quote! { jit.enc_rexw_digit(&[0xf7], #op, 6, Imm::None); },
}
}

Inst::Movsd(op1, op2) => match (op1, op2) {
(XmOperand::Xmm(op1), op2) => quote! {
jit.emitb(0xf2);
Expand Down Expand Up @@ -327,6 +336,12 @@ pub fn compile(inst: Inst) -> TokenStream {
jit.enc_rexw_mr(&[0x0f, 0xbd], #op1, #op2);
)
}
Inst::Popcntq(op1, op2) => {
quote!(
jit.emitb(0xf3);
jit.enc_rexw_mr(&[0x0f, 0xb8], #op1, #op2);
)
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions monoasm_macro/src/inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub enum Inst {

Imul(RmiOperand, RmiOperand),
Idiv(RmOperand),
Div(RmOperand),

Lea(RmOperand, RmOperand),

Expand Down Expand Up @@ -117,6 +118,7 @@ pub enum Inst {

Lzcntq(Register, RmOperand),
Tzcntq(Register, RmOperand),
Popcntq(Register, RmOperand),

Int3,
}
Expand Down Expand Up @@ -291,6 +293,7 @@ impl Parse for Inst {
"negq" => parse_1op!(Negq),
"imul" => parse_2op!(Imul),
"idiv" => parse_1op!(Idiv),
"div" => parse_1op!(Div),

"testq" => parse_2op!(Testq),
"testb" => parse_2op!(Testb),
Expand Down Expand Up @@ -386,6 +389,7 @@ impl Parse for Inst {

"lzcntq" => parse_2op!(Lzcntq),
"tzcntq" => parse_2op!(Tzcntq),
"popcntq" => parse_2op!(Popcntq),

"dq" => {
if input.peek(LitFloat) {
Expand Down

0 comments on commit 17a1833

Please sign in to comment.