0% found this document useful (0 votes)
5 views3 pages

practical 3

This document is an assembly language program that prompts the user to enter a string and calculates its length. It utilizes system calls for input and output, and includes functions for taking input and converting hexadecimal to decimal. The program concludes by displaying the entered string and its length before exiting.

Uploaded by

Divya Ghadge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

practical 3

This document is an assembly language program that prompts the user to enter a string and calculates its length. It utilizes system calls for input and output, and includes functions for taking input and converting hexadecimal to decimal. The program concludes by displaying the entered string and its length before exiting.

Uploaded by

Divya Ghadge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

%macro IO 4

mov rax, %1

mov rdi, %2

mov rsi, %3

mov rdx, %4

syscall

%endmacro

section .data

m1 db "Enter the string : ",

l1 equ $ - m1

m2 db "Length is : "

l2 equ $ - m2

m3 db "Entered string is : "

l3 equ $ - m3

m4 db 10, "String length is: "

l4 equ $ - m4

m5 db "",10

l5 equ $ - m5

section .bss

input resb 50

iLen equ $ - input

count resb 1

_output resb 20

section .text
global _start

_start:

IO 1, 1, m1, l1

call takeInput

IO 1, 1, m3, l3

IO 1, 1, input, iLen

IO 1, 1, m4, l4

dec byte[count]

movzx rax, byte [count]

call hex_to_dec

IO 1, 1, _output, 16

IO 1, 1, m4, l4

dec byte[count]

movzx rax, byte [count]

call hex_to_dec

IO 1, 1, _output, 16

IO 1, 1, m5, l5

call exit

ret

takeInput:

IO 0, 0, input, iLen
mov [count], rax

ret

hex_to_dec:

mov rsi,_output+15

mov rcx,2

letter2:

xor rdx,rdx

mov rbx,10

div rbx

cmp dl,09h

jbe add30

add30:

add dl,30h

mov [rsi],dl

dec rsi

dec rcx

jnz letter2

ret

exit:

mov rax, 60

xor edi, edi

syscall

Output:
Enter the string : Entered string is :
String length is: 55

[Execution complete with exit code 0]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy