I have to get from user up to 8 letter to string, and print the string in reverse.
There is my code :
STA SEGMENT STACK
DB 100H DUP (0)
STA ENDS
DATA SEGMENT
MSG1 DB 'ENTER STRING (Maximum is 8) : $'
MSG2 DB 'REVERS IS : $'
ISTR DB 10,?,10 DUP('$')
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STA
MAIN:
MOV AX, DATA
MOV DS, AX
LEA DX, MSG1
MOV AH, 09H
INT 21H
MOV DX, 0
;INPUT
MOV DX, OFFSET ISTR
MOV AH, 0AH
INT 21H
MOV SI, OFFSET ISTR
MOV CX, [SI+1]
ADD SI, 2
MOV DX, 0
MOV BX, CX
TOSTACK:
MOV DX, [SI]
PUSH DX
INC SI
LOOP TOSTACK
MOV DL, 10
MOV AH, 02H
INT 21H
LEA DX, MSG2
MOV AH, 09H
INT 21H
MOV DX, 0
MOV CX, BX
MOV SI, 2
FROMSTACK:
POP DX
MOV AH, 02H
INT 21H
INC SI
LOOP FROMSTACK
MOV AX, 4C00H
INT 21H
CODE ENDS
END MAIN
My code Print the reversing string BUT WITH TRASH FROM MEMORY
And I can write 10 numbers and then cant press enter.
or I can enter 9~(123456789) numbers and press enter the its will reverse 987654321.
And I need maximum 8 or minimum 1.