0

Hi,
Why this program in not working ?
It doesn't print anything .

Page 60, 132
TITLE Reverse characters(EXE)
;----------------------------------------------------------------------------------------
	.MODEL SMALL
	.STACK 64
;----------------------------------------------------------------------------------------
	.DATA
STR    DB    'txeT desreveR$'
;----------------------------------------------------------------------------------------
	.CODE
REVERSE PROC FAR
	MOV AX, @data
	MOV DS, AX
	MOV ES, AX
	
	LEA BX, STR
	MOV SI, BX
	MOV CX, 13
A10:
	INC SI
	DEC CX
	JNZ A10
	
DO_REVERSE:
	CMP BX, SI
	JAE DONE
	MOV AL, [BX]
	MOV AH, [SI]
	MOV [SI], AL
	MOV [BX], AH
	INC BX
	DEC SI
	JMP DO_REVERSE
	
DONE:
	MOV AH, 09H
	LEA DX, STR
	INT 21H
	
	MOV AX, 4C00H
	INT 21H
REVERSE ENDP
	END REVERSE
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by NotNull
0

I added DEC SI to line 23, and your code now works.

BITS 16
ORG 100h

JMP DEADSTACG
STRZ DB 'txeT desreveR$'
DEADSTACG:
LEA BX, [STRZ]
MOV SI, BX
MOV CX, 13
A10:
INC SI
DEC CX
JNZ A10
dec si ; well there you go...
DO_REVERSE:
CMP BX, SI
JAE DONE
MOV AL, [BX]
MOV AH, [SI]
MOV [SI], AL
MOV [BX], AH
INC BX
DEC SI
JMP DO_REVERSE
DONE:
MOV AH, 09H
LEA DX, [STRZ]
INT 21H
MOV AX, 4C00H
INT 21H
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.