; write an alp to accept to five 64 bit hexadecimal number from user and store them in an array and display accepted number

global _start
_start:
section .txt
%macro disp 2
mov rax,1
mov rdi,1
mov rsi,%1
mov rdx,%2
syscall
%endm

%macro accept 2
mov rax,0
mov rdi,0
mov rsi,%1
mov rdx,%2
syscall
%endm

disp msg1,len1
mov rsi,array
l4:
push rsi
accept num,16
mov rdi,temp
mov rdi,temp+07
mov rsi,num
mov rcx,08
l3:
mov al,[num]
cmp al,39h
jbe l1
sub al,07h
l1:
sub al,30h
rol al,04
mov bl,al
inc rsi
mov al,[rsi]
cmp al,39h
jbe l2
sub al,07h
l2:
sub al,30h
add al,bl
mov [rdi],al
dec rdi
inc rsi
loop l3
pop rsi
mov rax,[temp]
mov [rsi],rax
add rsi,08
dec byte[cnt]
jnz l4
disp msg2,len2
mov rsi,array
l5:
mov rax,[rsi]
call display
disp msg3,len3
add rsi,08
dec byte[cnt1]
jnz l5

mov rax,60
mov rdi,0
syscall

display:
mov rsi,disparr+15;
mov rcx,16;
a2:
mov rdx,0;
mov rbx,10h;
div rbx;
cmp dl,09h;
jbe a1;
add dl,07h;
a1:
add dl,30h;
mov [rsi],dl;
dec rsi
dec rcx;
jnz a2

mov rax,1;
mov rdi,1;
mov rsi,disparr;
mov rdx,16
syscall

ret
section .data
msg1 db "Enter 5 numbers",0ah
len1 equ $-msg1
msg2 db "Array element are:",0ah
len2 equ $-msg2
msg3 db " ",0ah
len3 equ $-msg3

cnt db 05
cnt1 db 05
array dq 0000000000000000h,0000000000000000h,0000000000000000h,0000000000000000h,0000000000000000h
temp dq 0000000000000000h,0000000000000000h,0000000000000000h,0000000000000000h,0000000000000000h

section .bss
disparr resb 32
num resb 10

Embed on website

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