diff options
Diffstat (limited to 'ellipse2.asm')
| -rw-r--r-- | ellipse2.asm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/ellipse2.asm b/ellipse2.asm new file mode 100644 index 0000000..c58f544 --- /dev/null +++ b/ellipse2.asm @@ -0,0 +1,74 @@ +global _start + +struc ellipse + major: resd 1 + minor: resd 1 + area: resd 1 + circumference: resd 1 + eccentricity: resd 1 +endstruc + +section .data +e: + istruc ellipse + at major, dd 0 + at minor, dd 0 + at area, dd 0 + at circumference, dd 0 + at eccentricity, dd 0 + iend + +section .rodata noexec nowrite align=4 +pi: dd 3.141592653589793238462 + +section .text +_start: + finit + + mov ebx, 100 + +; .repeat: + lea edi, [rbx + 0] + call print_uint32 + ; dec ebx + ; jge .repeat + + xor edi, edi + mov eax, 231 + syscall + + ; mov rax, 60 + ; mov rdi, 0 + + ; syscall + +; void print_uint32(uint32_t edi) +; +; https://stackoverflow.com/questions/13166064/how-do-i-print-an-integer-in-assembly-level-programming-without-printf-from-the +print_uint32: + mov eax, edi + + mov ecx, 0xa + push rcx + mov rsi, rsp + sub rsp, 16 + +.to_ascii_digit: + xor edx, edx + div ecx + + add edx, '0' + dec rsi + mov [rsi], dl + + test eax, eax + jnz .to_ascii_digit + + mov eax, 1 + mov edi, 1 + lea edx, [rsp + 16 + 1] + sub edx, esi + syscall + + add rsp, 24 + ret |