Program for String manipulations for 8086
1. Length of the string
Aim:
To write an assembly language program to find the length of the given string.
Tools:
PC installed with TASM.
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AL, ’$’ MOV CX, 00H MOV SI, OFFSET STR1 BACK : CMP AL, [SI] JE GO INC CL INC SI JMP BACK GO : MOV LENGTH, CL HLT CODE ENDS DATA SEGMENT STR1 DB ‘STUDENT BOX OFFICE$’ LENGTH DB ? DATA ENDS END
Flow Chart:
Result:
Input:
STR (DS : 0000H) = STUDENT BOX OFFICE
Output:
LENGTH = 18
2. Display the string
Aim:
To write an assembly language program to display the given string.(DOS PROGRAMMING)
Software required:
TASM TURBO ASSEMBLER
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV AH, 09H MOV DX,OFFSET MSG INT 21H MOV AH, 4CH INT 21H CODE ENDS DATA SEGMENT MSG DB 0DH, 0AH, "WELCOME TO MICROPROCESSORS LAB", 0DH, 0AH, "$" DATA ENDS END
Result:
WELCOME TO MICROPROCESSORS LAB
3. Reverse the string
Aim:
To write an assembly language program to reverse the given string.
Sofware required:
TASM TURBO ASSEMBLER
Program:
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV CL, COUNT MOV SI, OFFSET STR1 MOV DI, COUNT - 1 BACK:MOV AL, [SI] XCHG [DI], AL MOV [SI], AL INC SI DEC DI DEC CL JNZ BACK HLT CODE ENDS DATA SEGMENT STR1 DB ‘MPMC$’ COUNT EQU 04H STR2 DB DUP (0) DATA ENDS END
Flow Chart:
Result:
Input:
STR1 (DS:0000H) =
Output:
STR1 (DS:0004H) =
-
UpdatedOct 25, 2014
-
Views49,976
Programs for 16 bit arithmetic operations for 8086 (using various addressing modes)
Program for String manipulations for 8086
Program for sorting an array for 8086
Program for searching for a number or character in a string for 8086
Program for digital clock design using 8086.
Programming using arithmetic, logical and bit manipulation instructions of 8051