diff options
Diffstat (limited to 'linux/314divide.subx')
-rw-r--r-- | linux/314divide.subx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/linux/314divide.subx b/linux/314divide.subx new file mode 100644 index 00000000..c0b85526 --- /dev/null +++ b/linux/314divide.subx @@ -0,0 +1,17 @@ +== code + +integer-divide: # a: int, b: int -> quotient/eax: int, remainder/edx: int + # . prologue + 55/push-ebp + 89/<- %ebp 4/r32/esp + # eax = a + 8b/-> *(ebp+8) 0/r32/eax + # edx = all 0s or all 1s + 99/sign-extend-eax-into-edx + # quotient, remainder = divide eax by b + f7 7/subop/divide-eax-edx-by *(ebp+0xc) +$integer-divide:end: + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return |