I'm new with assembly language and I'm having a problem with reversing a string.
For example:
original string: "ABCD"
after reversal: "DCBA"
I also want to put the reversed string into the same variable name that I used, and not using a new one. I thought about using a stack and here's a code that I wrote but I can't figure out where's my error:
IDEAL
MODEL small
STACK 1000h
DATASEG
first db 'ABCD', 0
CODESEG
start:
mov ax, @data
mov ds, ax
mov si, 0
mov di, 0
loop_start:
mov ax, [first+si]
inc si
test ax, ax
jz done1ax
push ax
jmp loop_start
done1ax:
pop ax
mov [first+di], ax
inc di
cmp di, si
JL done1ax
mov dl, 10
mov ah, 2
int 21h
ret
END start