sign extend rax into rbx before calling idiv, the replaces the rbx zeroing
This commit is contained in:
@@ -357,7 +357,7 @@ public class GenASM implements Visitor<Void> {
|
|||||||
if (isFloatOperation) {
|
if (isFloatOperation) {
|
||||||
this.ex.write(" divsd %xmm1, %xmm0\n");
|
this.ex.write(" divsd %xmm1, %xmm0\n");
|
||||||
} else {
|
} else {
|
||||||
this.ex.write(" xor %rdx, %rdx\n"); // clear upper part of division
|
this.ex.write(" cqto\n"); // sign extend rax into rdx since we're dealing with signed values
|
||||||
this.ex.write(" idiv %rbx\n"); // %rax/%rbx, quotient now in %rax
|
this.ex.write(" idiv %rbx\n"); // %rax/%rbx, quotient now in %rax
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -370,7 +370,7 @@ public class GenASM implements Visitor<Void> {
|
|||||||
e.rhs.welcome(this);
|
e.rhs.welcome(this);
|
||||||
this.ex.write(" movq %rax, %rbx\n");
|
this.ex.write(" movq %rax, %rbx\n");
|
||||||
this.ex.write(" popq %rax\n");
|
this.ex.write(" popq %rax\n");
|
||||||
this.ex.write(" xor %rdx, %rdx\n"); // clear upper part of division
|
this.ex.write(" cqto\n"); // sign extend rax into rdx since we're dealing with signed values
|
||||||
this.ex.write(" idiv %rbx\n"); // %rax/%rbx, remainder now in %rdx
|
this.ex.write(" idiv %rbx\n"); // %rax/%rbx, remainder now in %rdx
|
||||||
this.ex.write(" movq %rdx, %rax\n");
|
this.ex.write(" movq %rdx, %rax\n");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user