Files
assembly-calculator/calculator.s
synt-xerror 2c98e72c86 first commit
2026-01-23 19:50:32 -03:00

71 lines
1.3 KiB
ArmAsm

; -- Assembly Calculator ---------------------------------------
;
; This project is a practice for my low-level programming study
; --------------------------------------------------------------
; x86_64 linux syscalls table
;
; 0: read (needs fd, where to save and length)
; 1: write (needs fd, string and string length)
; 60: exit (needs status code)
global _start
section .bss
fnum resb 128
snum resb 128
; "variables" read-only
section .rodata
title db "Assembly Calculator v1.0 by /synt-xerror", 0xA
titlel equ $ - title
fir db 0xA, "Enter the first number: "
firl equ $ - fir
sec db "Enter the second number: "
secl equ $ - sec
section .text
_start:
; print title
mov rax, 1
mov rdi, 1
mov rsi, title
mov rdx, titlel
syscall
; ask to enter first number
mov rax, 1
mov rdi, 1
mov rsi, fir
mov rdx, firl
syscall
; input to enter the first number
mov rax, 0
mov rdi, 0
mov rsi, fnum
mov rdx, 128
syscall
; ask to enter second number
mov rax, 1
mov rdi, 1
mov rsi, sec
mov rdx, secl
syscall
; input to enter the second number
mov rax, 0
mov rdi, 0
mov rsi, snum
mov rdx, 128
syscall
; exit
mov rax, 60
mov rdi, 0
syscall