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

1 This ALP Reads and Stores An Input String in Different Data Segments and Outputs Its Reverse

1. The document describes a program that reads in a string from the user, stores it in one data segment, and copies it to a second data segment in reverse order. 2. It prints a message prompting the user for input, accepts the input string, and copies it to the reversed storage segment by swapping characters from the beginning and end. 3. Finally, it prints messages indicating the reversed string output and displays the reversed string.

Uploaded by

Gauri Tyagi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

1 This ALP Reads and Stores An Input String in Different Data Segments and Outputs Its Reverse

1. The document describes a program that reads in a string from the user, stores it in one data segment, and copies it to a second data segment in reverse order. 2. It prints a message prompting the user for input, accepts the input string, and copies it to the reversed storage segment by swapping characters from the beginning and end. 3. Finally, it prints messages indicating the reversed string output and displays the reversed string.

Uploaded by

Gauri Tyagi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1

Microprocessor and Interfacing


CSE2006
Digital Assignment -1

Reg No: 15BCE0126 Slot: A2


Name: Gauri Tyagi

.MODEL
.STACK 64
.DATA

ASSUME DS: DAT1


DAT1 SEGMENT
READ DB 10,?,10 DUP ('')
MSG1 DB 'ENTER STRING:$'
MSG2 DB 'REVERSED STRING:$'
DAT1 ENDS

ASSUME DS: DAT2


DAT2 SEGMENT
STORE DB 10,?,10 DUP ('')
DAT2 ENDS

.CODE
START:
;MOV AX,@DATA ;point to data segment
;MOV DS,AX

MOV DX,SEG MSG1 ;print msg1 (int21h/9h)


MOV DS,DX
MOV DX,OFFSET MSG1
MOV AH,09H
INT 21H

MOV DX,OFFSET READ ;accept input string (int21h/ah)


MOV AH,0AH
INT 21H

LEA BX,READ ;point to beginning of strings


MOV SI,BX
LEA BX,STORE
MOV DI,BX

NEXT_BYTE: CMP [SI],'$'


JE END_FOUND ;traverse till end marker

MOV BL,[SI] ;copy read in dat1 to store in dat2


MOV [DI],BL

INC SI ;increment source and destination


INC DI

JMP NEXT_BYTE

END_FOUND: DEC SI
DEC DI
LEA BX,STORE

REVERSE: CMP BX,DI


JAE PRINT

MOV AL,[BX] ;swap character from beginning and end


MOV AH,[DI]

MOV [DI],AL
MOV [BX],AH

INC BX
DEC DI

JMP REVERSE

PRINT: MOV DX,SEG MSG2


MOV DS,DX ;print msg2 (int21h/9h)
MOV DX,OFFSET MSG2
MOV AH,09H
INT 21H

LEA DX,STORE
MOV AH,09H ;print reversed (int21h/9h)
INT 21H
HLT

RET

1 This ALP reads and stores an input string in different data segments and outputs its reverse.

You might also like