0% found this document useful (0 votes)
3 views

Assignment_1_MIC

The document contains an assembly language program that accepts five 64-bit hexadecimal numbers from the user, stores them in an array, and displays the accepted numbers. It includes sections for data, text, and input/output operations, utilizing system calls for interaction. The program also handles errors and converts ASCII input to hexadecimal format.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment_1_MIC

The document contains an assembly language program that accepts five 64-bit hexadecimal numbers from the user, stores them in an array, and displays the accepted numbers. It includes sections for data, text, and input/output operations, utilizing system calls for interaction. The program also handles errors and converts ASCII input to hexadecimal format.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment 1 :

section .data
hello: db 'Hello harsh..!',10
helloLen: equ $-hello

section .text
global _start

_start:
mov eax,4
mov ebx,1
mov ecx,hello
mov edx,helloLen
int 80h
mov eax,1
mov ebx,0
int 80h

Output :
Q. 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.

%macro IO 4 m3 db "" ,10


mov rax,%1 l3 equ $-m3
mov rdi,%2 m4 db "”,10
mov rsi,%3 l4 equ $-m4
mov rdx,%4 m5 db 10,"Exiting now" ,10
syscall l5 equ $-m5
%endmacro m6 db "incorrect input error" ,10
section .data l6 equ $-m6
m1 db "Enter the five 64 bit m7 db 10
numbers:" ,10
debug db "debug "
l1 equ $-m1
debug_l equ $-debug
m2 db "The five 64 bit numbers
time equ 5
are:" ,10
size equ 8
l2 equ $-m2
IO 1,1,m3,l3
IO 1,1,m4,l4
section .bss mov byte[count],time
arr resb 300 mov rbp,arr
_input resb 20 IO 1,1,m1,l1
_output resb 20 input:
count resb 1 IO 0,0,_input,17
IO 1,1,debug,debug_l
section .text IO 1,1,_input,17
global _start call ascii_to_hex
_start: mov [rbp],rbx
add rbp,size letter:
dec byte[count] rol rbx,4
jnz input mov al,[rsi]
mov byte[count],time cmp al,47h
mov rbp,arr jge error
jmp display cmp al,39h
display: jbe skip
mov rax,[rbp] sub al,07h
call hex_to_ascii skip:
IO 1,1,m7,1 sub al,30h
IO 1,1,_output,16 add rbx,rax
add rbp,size inc rsi
dec byte[count] dec rcx
jnz display jnz letter
jmp exit ret
exit: hex_to_ascii:
IO 1,1,m5,l5 mov rsi,_output+15
mov rax,60 mov rcx,16
mov rdi,0 letter2:
syscall xor rdx,rdx
error: mov rbx,16
IO 1,1,m6,l6 div rbx
jmp exit cmp dl,09h
ascii_to_hex: jbe add30
mov rsi,_input add dl,07h
mov rcx,16 add30:
xor rbx,rbx add dl,30h
xor rax,rax mov [rsi],dl
dec rsi
dec rcx
jnz letter2
ret

Output :

You might also like