section .data
msg db 10 "Enter string"
msg_len equ $-msg
smsg db 10 "Length is: "
smsg_len equ $-smsg
section .bss
char_ans resb 2
string resb 50
string_len equ $-string
count resb 1
;----------------------------------
%macro print 2
mov rax, 1
mov rdi, 1
mov rsi, %1
mov rdx, %2
syscall
%endmacro
%macro read 2
mov rax, 0
mov rdi, 0
mov rsi, %1
mov rdx, %2
syscall
%endmacro
%macro exit 0
mov rax, 60
mov rsi, 0
syscall
%endmacro
;----------------------------------
section .text
global _start
_start:
print msg, msg_len
read string, string_len
mov [count], rax
print smsg, smsg_len
mov rax, [count]
call display
exit
display:
mov rbx, 16
mov rcx, 2
mov rsi, char_ans+1
cnt:
mov rdx, 0
div rbx
cmp dl, 09h
jbe add30
add dl,37h
add30:
add dl, 30h
mov [rsi], dl
dec rsi
dec rcx
jnz cnt
print char_ans, 2
ret
i think it should be like
section .text
global _start
_start:
print msg, msg_len
read string, string_len
mov rax, rdx ;VALUE OF RDX MOVED TO RAX SINCE string_leN STORED IN rdx
mov [count], rax
print smsg, smsg_len
mov rax, [count]
call display
exit