Sunday, 12 July 2015

Print A String In Reverse Order Using Stack In Assembly Language Solution.

/*Print A String In Reverse Order Using Stack In Assembly Language Solution.*/

/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/


Solution:

.MODEL SMALL
.STACK 100H
.DATA
    STR DB 0AH,0DH,'OUTPUT: $'
.CODE

MAIN PROC
 
    MOV AX,@DATA
    MOV DS,AX
 
    MOV CL,0
    INPUT:
        MOV AH,1
        INT 21H
        CMP AL,0DH
        JE END_
     
        PUSH AX
        INC CL
        JMP INPUT
    END_:
 
    MOV AH,9
    LEA DX,STR
    INT 21H
 
    OUTPUT:
        CMP CL,0
        JE FINISH
        DEC CL
        MOV AH,2
        POP DX
        INT 21H
        JMP OUTPUT
    FINISH:
 
    MOV AH,4CH
    INT 21H
     
    MAIN ENDP
END MAIN

No comments:

Post a Comment