Labels

Monday 7 November 2016

Write X86/64 Assembly language program (ALP) to add array of N hexadecimal numbers stored in the memory. Accept input from the user.

section .data
msg db "Enter how many numbers you want to enter",10
len: equ $-msg
msg1 db "Enter the 64-bit number",10
len1: equ $-msg1

section .bss
var1 resb 2
var2 resb 17
var3 resq 1
mem resb 1
section .text
global _start
_start:
mov rax,01h
mov rdi,01h
mov rsi,msg
mov rdx,len
syscall

mov rax,00h
mov rdi,00h
mov rsi,var1
mov rdx,2
syscall

cmp byte [var1],39h
jng z
sub byte [var1],07h
z:
sub byte [var1],30h

up:
mov rax,01h
mov rdi,01h
mov rsi,msg1
mov rdx,len1
syscall

mov rax,00h
mov rdi,00h
mov rsi,var2
mov rdx,17
syscall

dec al

mov rsi,var2
mov ch,al
mov cl,04

xor rbx,rbx
Y:
shl rbx,cl
mov al,[rsi]
cmp al,39h
jng X
sub al,07h
X:
sub al,30h

add bl,al
inc rsi
dec ch
jnz Y

add [var3],rbx
dec byte [var1]
jnz up

xor rbx,rbx
mov rbx,[var3]
mov rsi,var2
mov ch,16
mov cl,04h
up1:
rol rbx,cl
mov al,bl
and al,0fh
cmp al,09h
jng sk
add al,07h
sk:add al,30h
mov [rsi],al
inc rsi
dec ch
jnz up1

mov rax,01h
mov rdi,01h
mov rsi,var2
mov rdx,16
uppp:
cmp byte[rsi],30h
jne xxx
inc rsi
dec rdx
jnz uppp



xxx:
syscall

mov rax,3Ch
mov rdi,00
syscall

No comments:

Post a Comment