i have been trying very simple nasm programs...
i originally wanted to accept and display an array of numbers...but i am currently stuck at the accepting count stage..
i accept the count and want to convert it from ascii to hex...
%macro print 2
mov rax,1
mov rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endmacro
%macro accept 2
mov rax,0
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endmacro
SECTION .data
msg : db "How many numbers you want add : "
len : equ $-msg
msg1 : db "Enter number : ", 10
len1 : equ $-msg1
SECTION .bss
input: resb 14
count: resb 4
temp: resb 17
SECTION .text
global _start
_start:
print msg,len
accept temp,04 ;accept the number of inputs to be taken
call convert
print msg,len
mov rax,60
mov rdx,0
syscall
convert: ;converts ascii to hex
mov rax,00h
mov rbx,00h
mov dx,2
mov rsi,temp
l1:
print msg,len ;i put this print statement to check if the loop is being entered
rol rbx,04
mov al,[rsi]
cmp al,39h
jbe sub30
cmp al,'a'
jb sub7
sub al,20h
sub7:
sub al,07h
sub30:
sub al,30h
add rbx,rax
inc rsi
dec dx
jnz l1
ret
this is the code...!!..its actually giving me the segmentation error.i put the print statement in the loop, it is an infifnite loop..!
help please..!
thanks,
avajos..