summaryrefslogtreecommitdiff
path: root/CSAPP/tmul.s
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2025-07-10 22:55:07 +0200
committerCarlos Maiolino <[email protected]>2025-07-10 22:56:55 +0200
commitd98f46ce647846b0aa30b2e16a30fd4e152a1bf5 (patch)
tree267474fcc77cf20b428f6f4c7f768ca09f4cfe0e /CSAPP/tmul.s
parent869e68986aa8f69af6e7842260a68d1e5c6f796f (diff)
Add new code
Signed-off-by: Carlos Maiolino <[email protected]>
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