Monday, March 1, 2021

Write an X86/64 ALP to accept five 64 bit Hexadecimal numbers from user and store them in an array and display the accepted numbers.

 msg1 db "Enter 5 64-bit numbers ",10,13

len1 equ $-msg1


msg2 db "Entered 5 64-bit numbers are ",10,13

len2 equ $-msg2


section .bss

array resb 120

count resb 1


section .text

global _start

_start:


;logic to read 5 64-bit numbers


mov bh,05        ; count is in bh

mov rbx,00      ; array index


up:  mov rax,00

        mov rdi,00

        mov rsi,array

        add rsi,rbx

        mov rdx,17

        syscall

        add rbx,17

        dec byte[count]  ; dec count

        jnz up                  ; check count is 0 or not using zero flag i;



mov byte[count],05       ; count is in bh

mov rbx,00                     ;array index


up1: mov rax,01

        mov rdi,01

        mov rsi,array

        add rsi,rbx

        mov rdx,17

        syscall

        add rbx,17

        dec byte[count]      ; dec count

        jnz up1                    ; check count is 0 or not using zero flag i;



;exit syscall

mov rax, 60

mov rdi,00

syscall

1 comment: