%macro scall 4
    mov rax,%1
    mov rdi,%2
    mov rsi,%3
    mov rdx,%4
    syscall
%endmacro

section .bss
    num resb 20
    array resb 200
    char_ans resb 16

section .data
    m1 db 10,"Enter a 2 digit number:"
    l1 equ $-m1

    m2 db 10,13,"The entered number is: "
    l2 equ $-m2

    m3 db "",10d,13d
    l3 equ $-m3

section .text
    global _start

_start:
;-------------accept array size-----------------
    scall 1,1,m1,l1
    scall 0,0,num,3
    call accept_proc
    mov rbp,array
    mov [rbp],bx

;-------------display array elements-----------------
    scall 1,1,m2,l2
    mov ax,bx
    call display_proc

;--------------exit------------------
    mov rax , 60
    mov rdi , 0
    syscall


;-----------------accept procedure------------------
accept_proc:
    mov rsi,num
    mov rbx,0
    mov rax,0
    mov rcx,2
back:
    rol rbx,04
    mov al,[rsi]
    cmp al,39h
    jbe next
    sub al,07h
next:
    sub al,30h
    add bx,ax
    inc rsi
    dec rcx
    jnz back
ret

;-----------------display procedure------------------
display_proc:
    mov rbp,char_ans
    mov rcx,2
up3:
    rol al,04h
    mov dl,al
    and dl,0Fh
    cmp dl,09h
    jbe next1
    add dl,07h
next1:
    add dl,30h
    mov [rbp],dl
    inc rbp
    dec rcx
    jnz up3
    scall 1,1,char_ans,3
    scall 1,1,m3,l3
ret

Embed on website

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