Google

Sep 24, 2008

assembly language program to reverse a given string

Following is the assembly language program to reverse a given string.

MOV AX @ DATA ; AX IS INITIALIZED WITH DATA
MOV DS AX ; AX IS MOVED INTO DS
MOV CX 0005H ; CX IS INITIALIZED TO 5
LEA SI A1 ; SI IS HAVING LEAD E.A OF A1
LEA DI A2; DI IS HAVING LEAD E.A OF A2
ADD SI 0004
AGAIN: MOV AL[SI]
MOV [DI]AL ; AL IS MOVED INTO DI
DEC SI
INC DI
LOOP AGAIN
INT 3 ; INTERRUPT
END

Using the above code if an Input for instance ' ad-cole': 0006 is given then the output will be shown as
DS: 0011: 16
10A0: 0010 : 65, 64 , 63 , 62 , 61 05 e d c b a

You might be also interested in:

:: Find Square Root of a hexadecimal number in assembly language
:: common intreview questions on 8086
:: Assembly Language Source Codes

No comments: