summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-11-19 14:40:34 -0800
committerFuwn <[email protected]>2022-11-19 14:40:34 -0800
commit90ba93a163339cbb3f58ea8bff434efd32c8ddca (patch)
tree477f889ac70adf51b0ea960ab50d71b91ab932fd
parentfeat: store oit (diff)
downloadellipse2-90ba93a163339cbb3f58ea8bff434efd32c8ddca.tar.xz
ellipse2-90ba93a163339cbb3f58ea8bff434efd32c8ddca.zip
feat: xmm register double sub
-rw-r--r--.idea/.gitignore8
-rw-r--r--.idea/codeStyles/codeStyleConfig.xml5
-rw-r--r--.idea/dictionaries6
-rw-r--r--.idea/discord.xml7
-rw-r--r--.idea/ellipse2.iml8
-rw-r--r--.idea/misc.xml8
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--[-rwxr-xr-x]ellipse2bin9016 -> 17224 bytes
-rw-r--r--ellipse2.asm88
-rw-r--r--ellipse2.obin960 -> 1984 bytes
11 files changed, 124 insertions, 20 deletions
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..a55e7a1
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+ <state>
+ <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
+ </state>
+</component> \ No newline at end of file
diff --git a/.idea/dictionaries b/.idea/dictionaries
new file mode 100644
index 0000000..16b5600
--- /dev/null
+++ b/.idea/dictionaries
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectDictionaryState">
+ <dictionary name="fuwnz" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 0000000..d8e9561
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="DiscordProjectSettings">
+ <option name="show" value="PROJECT_FILES" />
+ <option name="description" value="" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/ellipse2.iml b/.idea/ellipse2.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/ellipse2.iml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="CPP_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..461b022
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="SshConsoleOptionsProvider">
+ <option name="myEncoding" value="UTF-8" />
+ <option name="myConnectionType" value="SSH_CONFIG" />
+ <option name="myConnectionId" value="[email protected]:22 password" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..5172627
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/ellipse2.iml" filepath="$PROJECT_DIR$/.idea/ellipse2.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/ellipse2 b/ellipse2
index e0e90e3..528816e 100755..100644
--- a/ellipse2
+++ b/ellipse2
Binary files differ
diff --git a/ellipse2.asm b/ellipse2.asm
index c58f544..1f16360 100644
--- a/ellipse2.asm
+++ b/ellipse2.asm
@@ -1,31 +1,67 @@
-global _start
+extern printf
+extern puts
+
+global main
struc ellipse
- major: resd 1
- minor: resd 1
- area: resd 1
- circumference: resd 1
- eccentricity: resd 1
+ .major: resq 1
+ .minor: resq 1
+ .area: resq 1
+ .circumference: resq 1
+ .eccentricity: resq 1
endstruc
section .data
+pi: dq 3.14
+bottom: dq 0
+format: db "number: %d", 10, 0 ; g
+usage_error_message: db "usage: ellipse major minor", 10, 0
e:
istruc ellipse
- at major, dd 0
- at minor, dd 0
- at area, dd 0
- at circumference, dd 0
- at eccentricity, dd 0
+ at ellipse.major, dq 0
+ at ellipse.minor, dq 0
+ at ellipse.area, dq 0
+ at ellipse.circumference, dq 0
+ at ellipse.eccentricity, dq 0
iend
+.size: dd $ - e
+
+;section .rodata ; noexec nowrite align=4
+;pi: dq 3.141592653589793238462
-section .rodata noexec nowrite align=4
-pi: dd 3.141592653589793238462
+section .bss
section .text
-_start:
- finit
+main:
+ ; if (argv != 3)
+ cmp rdi, 3
+ jne usage_error
+
+ mov r12, rsi ; argv
+
+ ; major = argv[1]
+ mov rdi, [r12 + 8]
+ mov qword [e + ellipse.major], rdi
- mov ebx, 100
+ ; major = argv[2]
+ mov rdi, [r12 + 16]
+ mov qword [e + ellipse.minor], rdi
+
+ ; area = pi * major * minor
+; movss xmm0, [e + ellipse.major]
+; movss xmm1, [e + ellipse.minor]
+; addss xmm0, xmm1
+; mov qword [e + ellipse.area], xmm3
+
+; cvtsi2sd xmm0, [e + ellipse.major]
+; cvtsi2sd xmm1, [e + ellipse.minor]
+; addsd xmm0, xmm1
+ sub rsp, 8
+ movq xmm0, qword [e + ellipse.major]
+ mov rdi, format
+ mov rax, 1
+ call printf
+ add rsp, 8
; .repeat:
lea edi, [rbx + 0]
@@ -33,9 +69,9 @@ _start:
; dec ebx
; jge .repeat
- xor edi, edi
- mov eax, 231
- syscall
+ xor edi, edi
+ mov eax, 231 ; 0x60
+ syscall
; mov rax, 60
; mov rdi, 0
@@ -69,6 +105,18 @@ print_uint32:
lea edx, [rsp + 16 + 1]
sub edx, esi
syscall
-
+
add rsp, 24
ret
+
+ jmp done
+
+usage_error:
+ mov rdi, usage_error_message
+ call puts
+
+done:
+ mov rax, 60
+ mov rdi, 0
+
+ syscall
diff --git a/ellipse2.o b/ellipse2.o
index d18df67..0f313fe 100644
--- a/ellipse2.o
+++ b/ellipse2.o
Binary files differ