;ALP for addition of 2 digit numbers section .data msg db 'Enter two digit Number::',0xa msg_len equ $-msg res db 10,'Addition of two digit numbers is:' res_len equ $-res section .bss num resb 03 num1 resb 01 result resb 04 section .text %macro print 2 mov rax,1 ; Function 1 - write mov rdi,1 ; To stdout mov rsi,%1 ; String address mov rdx,%2 ; String size syscall ; invoke operating system to WRITE %endmacro %macro read 2 mov rax,0 ; Function 0 - Read mov rdi,0 ; from stdin mov rsi,%1 ; buffer address mov rdx,%2 ; buffer size syscall ; invoke operating system to READ %endmacro global _start _start: xor rax,rax xor rbx,rbx xor rcx,rcx xor rdx,rdx mov byte[result],0 mov byte[num],0 mov byte[num1],0 print msg, msg_len read num,3 call convert mov [num1],bl print msg, msg_len read num,3 call convert xor rcx,rcx xor rax,rax mov rax,[num1] add rax, rbx mov [result],rax print res, res_len mov rbx,[result] call display mov rax,60 mov rdi,0 syscall convert: ;; ASCII to Hex conversion xor rbx,rbx xor rcx,rcx xor rax,rax mov rcx,02 mov rsi,num up1: rol bl,04 mov al,[rsi] cmp al,39h jbe p1 sub al,07h jmp p2 p1: sub al,30h p2: add bl,al inc rsi loop up1 ret display: ;; Hex to ASCII conversion mov rcx,4 mov rdi,result dup1: rol bx,4 mov al,bl and al,0fh cmp al,09h jbe p3 add al,07h ;jmp p4 p3: add al,30h p4:mov [rdi],al inc rdi loop dup1 print result,4 ret
To embed this program on your website, copy the following code and paste it into your website's HTML: