MP Practical No: 02 

 
AIM:  Write an X86/64 ALP to accept a string and to display its length.
OBJECTIVES:  
To understand assembly language programming instruction set. 

 To understand different assembler directives with example.  

 To apply instruction set for implementing X86/64 bit assembly language programs
 
ENVIRONMENT:  
 Operating System: 64-bit Open source Linux or its derivative.  

 Programming Tools: Preferably using Linux equivalent or MASM/TASM/NASM/FASM.  

 Text Editor: geditor
 
LIST OF INTERRRUPTS USED: NA
LIST OF ASSEMBLER DIRECTIVES USED: EQU, PROC, GLOBAL, DB,
LIST OF MACROS USED: DISPMSG
LIST OF PROCEDURES USED: DISPLAY  
ALGORITHM:
INPUT: String
OUTPUT: Length of String in hex
STEP 1: Start.
STEP 2: Initialize data section.
STEP 3: Display msg1 on monitor
STEP 4: accept string from user and store it in Rsi Register (Its length gets stored in Rax register by default).
STEP 5: Display the result using “display” procedure. Load length of string in data register.
STEP 6. Take counter as 16 int cnt variable
STEP 7: move address of “result” variable into rdi.
STEP 8: Rotate left rbx register by 4 bit.
STEP 9: Move bl into al.
STEP 10: And al with 0fh
STEP 11: Compare al with 09h
STEP 12: If greater add 37h into al
STEP 13: else add 30h into al
STEP 14: Move al into memory location pointed by rdi
STEP 14: Increment rdi
STEP 15: Loop the statement till counter value becomes zero
STEP 16: Call macro dispmsg and pass result variable and length to it. It will print length of string.
STEP 17: Return from procedure
STEP 18: Stop
 
CONCLUSION:In this practical session, we learn how to display any number on monitor. (Conversion of hex to ASCII number in ALP program).

Comments

Popular posts from this blog

Microprocessor Question Bank For End SEM Exam: SE SEM II Computer Engineering Pattern 2019

Microprocessor Laboratory Practical List Pattern 2029(SE SEM II)

MP Practical No: 01