global _start
_start:
%macro disp 2
mov rax,1
mov rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endm

%macro accept 2
mov rax,0
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endm
disp msg1,len1
accept num,length1
call convert
mov [num1],al
disp msg2,len2
accept num,length1
call convert
mov [num2],al
mov ax,[num1]
mov bx,[num2]
mov cx,0000h
a2:
shr bx,01
jnc a1
add [res],ax
a1:
shl ax,01
cmp ax,00h
jz a3
cmp bx,00h
jnz a2
a3:
disp msg3,len3
mov ax,[res]
call display
mov rax,60
mov rdi,0
syscall

convert:
mov rsi,num
mov al,[rsi]
cmp al,39h
jbe l1
sub al,07h
l1:
sub al,30h
rol al,04
mov bl,al
inc rsi
mov al,[rsi]
cmp al,39h
jbe l2
sub al,07h
l2:
sub al,30h
add al,bl
ret

display:
mov rsi,disparr+3;
mov rcx,04;
q2:
mov rdx,0;
mov rbx,10h;
div rbx;
cmp dl,09h;
jbe q1;
add dl,07h;
q1:
add dl,30h;
mov [rsi],dl;
dec rsi
dec rcx;
jnz q2

mov rax,1;
mov rdi,1;
mov rsi,disparr;
mov rdx,04
syscall

ret

section .data
msg1 db "Enter first number"
len1 equ $-msg1
msg2 db "Enter second number"
len2 equ $-msg2
msg3 db "result:"
len3 equ $-msg3
msg4 db " "
len4 equ $-msg4

section .bss
num1 resb 10
num resb 10
num2 resb 10
res resb 10
length1 resb 02
disparr resb 32

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: