summaryrefslogtreecommitdiff
path: root/CSAPP/tmul.s
diff options
context:
space:
mode:
Diffstat (limited to 'CSAPP/tmul.s')
-rw-r--r--CSAPP/tmul.s43
1 files changed, 43 insertions, 0 deletions
diff --git a/CSAPP/tmul.s b/CSAPP/tmul.s
new file mode 100644
index 0000000..52cee75
--- /dev/null
+++ b/CSAPP/tmul.s
@@ -0,0 +1,43 @@
+ .file "tmul.c"
+ .text
+ .globl tmul_ok_asm
+ .type tmul_ok_asm, @function
+tmul_ok_asm:
+.LFB0:
+ .cfi_startproc
+ imulq %rdi, %rsi
+ movq %rsi, (%rdx)
+# Code deleted
+# testq %rsi, %rsi
+# setg %al
+# Code inserted
+ setae %al
+# End of code inserted
+ movzbl %al, %eax
+ ret
+ .cfi_endproc
+.LFE0:
+ .size tmul_ok_asm, .-tmul_ok_asm
+ .globl umul_ok_asm
+ .type umul_ok_asm, @function
+umul_ok_asm:
+.LFB1:
+ .cfi_startproc
+ movq %rdx, %rcx #Save copy of dest
+ movq %rsi, %rax #copy y to %rax
+ mulq %rdi #unsigned multiplication
+ movq %rax, (%rcx) #copy result (low 64-bit) to dest
+ setae %al #Set low-order byt according to mulq
+# Code removed
+# imulq %rdi, %rsi
+# movq %rsi, (%rdx)
+# testq %rsi, %rsi
+# setne %al
+# End of code removed
+ movzbl %al, %eax
+ ret
+ .cfi_endproc
+.LFE1:
+ .size umul_ok_asm, .-umul_ok_asm
+ .ident "GCC: (GNU) 5.3.1 20160406 (Red Hat 5.3.1-6)"
+ .section .note.GNU-stack,"",@progbits