%macro scall 4
mov rax,%1
mov rdi,%2
mov rsi,%3
mov rdx,%4
syscall
%endmacro
section .data
m1 db 10d,"Enter a string : ", 10d,13d
l1 equ $-m1
m2 db 10d,"String you entered is : "
l2 equ $-m2
m3 db "String length : "
l3 equ $-m4
section .bss
string resb 20
char_ans resb 50
section .text
global _start
_start:
scall 1,1,m1,l1
scall 0,0,string,20
scall 1,1,m2,l2
scall 1,1,string,20
scall 1,1,m3,l3
mov rsi,string
mov rcx, 0
loop:
mov al,[rsi]
cmp al,0Ah
je next
inc cx
inc rsi
jmp loop
next:
mov ax,cx
cmp ax,09h
jbe label1
add ax,07h
label1:
add ax,30h
mov rbp,char_ans
mov [rbp],ax
scall 1,1,char_ans,2
mov rax,60
mov rdi,0
syscall
To embed this project on your website, copy the following code and paste it into your website's HTML: