section .data	
	msg db "The sum is:", 10 ;10 is for new line   
	msgLen  equ $-msg ; calculates length of msg    
	num1 db  34H
	num2 db  46H 
	num3 db  38H
section .bss
	sum resb 1  ; holds the sum of the 3 numbers 
	temp resb 1			
 section .text
global _start ; start of the program 
_start:
         mov rax,1         	; next 4 lines are for displaying msg 
         mov rdi,1 
         mov rsi,msg 
         mov rdx, msgLen  
         syscall		 	     ;systemcall,  without this the above 4 lines are invalid               
mov al,byte[num1]         ; moves num1 to al 
add al,byte[num2]          ; adds num2 to al 
add al,byte[num3]          ; adds um 3 to al 
mov byte[sum],al   

mov bp,2                      ; counter, because we want the loop to run thrice 
up:rol al,4                     ; inverting the hex code code values. Eg: 7A will become A7 
      mov bl,al                
      and al,0Fh              ; anything anded with 0FH masks the first value and returns the last                           value, eg: A7 anded with 0FH gives 07
      cmp al,09               ; we are comparing if the value is less than 09 so that we know we have to add 37H or 30H, This is for ASCII conversion 
      jbe down              ; jbe means just below or equal, if it is just below or equal jump directly to down and add 30H else add 37H
     add al,07h
    down:Add al, 30h
      Mov byte[temp],al 
       mov rax,1         	  ; For displaying the first Digit of the answer 
      mov rdi,1  
      mov rsi,temp          
      mov rdx, 1  
       syscall	
      mov al,bl               ; inverting the position for round 2 of loop execution 
     dec bp                   ; decrementing bp by 1 
     jnz up                    ; if bp not 0 jump to up 
mov rax,60                ; exit codes 
mov rdi,0      
syscall

Embed on website

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