summaryrefslogtreecommitdiff
path: root/x86_64/arithmetic.s
diff options
context:
space:
mode:
Diffstat (limited to 'x86_64/arithmetic.s')
-rw-r--r--x86_64/arithmetic.s22
1 files changed, 22 insertions, 0 deletions
diff --git a/x86_64/arithmetic.s b/x86_64/arithmetic.s
new file mode 100644
index 0000000..34216f1
--- /dev/null
+++ b/x86_64/arithmetic.s
@@ -0,0 +1,22 @@
+# Simple program exercising CPU's arithmetic instructions
+
+.globl _start
+
+.section .text
+
+_start:
+ movq $3, %rdi
+ movq %rdi, %rax
+ mulq %rdi
+ movq $2, %rdi
+ addq %rdi, %rax
+ movq $4, %rdi
+ mulq %rdi
+
+ movq $10, %rax
+ movq $3, %rdi
+ divq %rdi # Remainder goes to %rdx
+ movq %rax, %rdi
+
+ mov $60, %rax
+ syscall