section .data ; Data section to declare constants, messages m1 db 10,"Enter the number:" ; message declaration with define byte(db) 10 for new line l1 equ $- m1 ; length of the message (l1) m2 db 10,"You have entered:" ; message declaration with define byte(db) 10 for new line l2 equ $- m1 ; length of the message (l2) section .bss temp resb 2 section .text ; main program section global _start _start: ;------------------------ print message code ------------------------------------------------------------------- mov rax, 1 ; system call for write mov rdi, 1 ; file handle 1 is stdout mov rsi, m1 ; address of string to output mov rdx, l1 ; number of bytes syscall ; invoke operating system to do the write ;------------------------ accept the number ------------------------------------------------------------------- mov rax, 0 ; system call for read mov rdi, 0 ; file handle 1 is stdin mov rsi, temp ; address of string to output mov rdx, 2 ; number of bytes syscall ; invoke operating system to do the write ;------------------------ print 2nd message ------------------------------------------------------------ mov rax, 1 ; system call for write mov rdi, 1 ; file handle 1 is stdout mov rsi, m2 ; address of string to output (You have entered msg) mov rdx, l2 ; number of bytes of m2 syscall ; invoke operating system to do the write ;------------------------ print message code ------------------------------------------------------------ mov rax, 1 ; system call for write mov rdi, 1 ; file handle 1 is stdout mov rsi, temp ; address of string to output shows value available in temp variable mov rdx, 2 ; number of bytes (temp variable length) syscall ; invoke operating system to do the write ;----------------------------- exit code mov rax, 60 ; system call for exit mov rdi, 0 ; exit code 0 syscall ; invoke operating system to exitsyscall
To embed this program on your website, copy the following code and paste it into your website's HTML: