summaryrefslogtreecommitdiff
path: root/CSAPP/tmul_asm.s
blob: 288a36a9d9dd04c413504289d11cd6aa8cf65fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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