Write a program in assembly language for reversing a four byte string – IGNOU MCA Assignment 2016 – 17

By | October 7, 2016

MASTER OF COMPUTER APPLICATIONS

Course Code : MCSL-017
Course Title : C and Assembly Language Programming (Lab Course)
Assignment Number : MCA(1)/L-017/Assignment/16-17
Maximum Marks : 50
Weightage : 25%

 

Write a program in assembly language for reversing a four byte string - IGNOU MCA Assignment 2016 – 17

Code:- 

DATA SEGMENT
STR1 DB “RITU$”
STR2 DB 7 DUP (‘$’)
MSG1 DB 10,13,’STORED STRING IN MEMORY IS : $’
MSG2 DB 10,13,’REVERSE STRING IS : $’
DATA ENDS

DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1

DISPLAY STR1

LEA SI,STR2
LEA DI,STR1
ADD DI,3

MOV CX,4
REVERSE:
MOV AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP REVERSE

DISPLAY MSG2

DISPLAY STR2

MOV AH,4CH
INT 21H
CODE ENDS

DATA SEGMENT
STR1 DB "RITU$"
STR2 DB 7 DUP ('$')
MSG1 DB 10,13,'STORED STRING IN MEMORY IS : $'
MSG2 DB 10,13,'REVERSE STRING IS : $'
DATA ENDS
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
DISPLAY MSG1
DISPLAY STR1
LEA SI,STR2
LEA DI,STR1
ADD DI,3
MOV CX,4
REVERSE:
MOV AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP REVERSE
DISPLAY MSG2
DISPLAY STR2
MOV AH,4CH
INT 21H
CODE ENDS

 

Screen Shots :-

Asm_program_Rev_Str_4_Memory

Output After Execution :-

Asm_program_Rev_Str_4_Memory_Output