summaryrefslogtreecommitdiff
path: root/CSAPP/tmul_asm.s
diff options
context:
space:
mode:
Diffstat (limited to 'CSAPP/tmul_asm.s')
-rw-r--r--CSAPP/tmul_asm.s79
1 files changed, 79 insertions, 0 deletions
diff --git a/CSAPP/tmul_asm.s b/CSAPP/tmul_asm.s
new file mode 100644
index 0000000..288a36a
--- /dev/null
+++ b/CSAPP/tmul_asm.s
@@ -0,0 +1,79 @@
+ .file "tmul_asm.c"
+ .text
+ .globl tmul_bug
+ .type tmul_bug, @function
+tmul_bug:
+.LFB0:
+ .cfi_startproc
+ imulq %rdi, %rsi
+ movq %rsi, (%rdx)
+#APP
+# 5 "tmul_asm.c" 1
+ setae %al
+# 0 "" 2
+#NO_APP
+ movl $0, %eax
+ ret
+ .cfi_endproc
+.LFE0:
+ .size tmul_bug, .-tmul_bug
+ .globl tmul_ok
+ .type tmul_ok, @function
+tmul_ok:
+.LFB1:
+ .cfi_startproc
+ pushq %rbx
+ .cfi_def_cfa_offset 16
+ .cfi_offset 3, -16
+ imulq %rdi, %rsi
+ movq %rsi, (%rdx)
+#APP
+# 13 "tmul_asm.c" 1
+ setae %bl # Set low-order byte
+ movzbl %bl, %eax # Zero extend to be res
+# 0 "" 2
+#NO_APP
+ popq %rbx
+ .cfi_def_cfa_offset 8
+ ret
+ .cfi_endproc
+.LFE1:
+ .size tmul_ok, .-tmul_ok
+ .globl tmul_ok2
+ .type tmul_ok2, @function
+tmul_ok2:
+.LFB2:
+ .cfi_startproc
+ imulq %rdi, %rsi
+ movq %rsi, (%rdx)
+#APP
+# 27 "tmul_asm.c" 1
+ setae %al # Set result
+# 0 "" 2
+#NO_APP
+ movzbl %al, %eax
+ ret
+ .cfi_endproc
+.LFE2:
+ .size tmul_ok2, .-tmul_ok2
+ .globl umult_ok
+ .type umult_ok, @function
+umult_ok:
+.LFB3:
+ .cfi_startproc
+ movq %rdx, %rcx
+#APP
+# 41 "tmul_asm.c" 1
+ movq %rdi,%rax #Get x
+ mulq %rsi # Unsigned long mult x*y
+ movq %rax,(%rcx) #Store low-order 8bytes at dest
+ setae %dil #Set result
+# 0 "" 2
+#NO_APP
+ movzbl %dil, %eax
+ ret
+ .cfi_endproc
+.LFE3:
+ .size umult_ok, .-umult_ok
+ .ident "GCC: (GNU) 5.3.1 20160406 (Red Hat 5.3.1-6)"
+ .section .note.GNU-stack,"",@progbits