;This program reverses a string in C format.
;The string is pointed to by the DI register
;
mov di, 2000h ;beg of string
;find end of string
mov bp, di ;make copy of pointer to beg
mov si, di ;move si to end
lp: cmp byte ptr 0 [si], 0 ;eos
je eos
inc si
jmp lp
eos: dec si ;si points to last char
biglp: cmp di, si ;any more char to rev>??
jae printit
mov al, byte ptr 0 [si] ;switch chars
mov ah, byte ptr 0 [di]
mov byte ptr 0 [di], al
mov byte ptr 0 [si], ah
inc di
dec si
jmp biglp
printit: cmp byte ptr 0 [bp], 0 ;end of string?
je stopit
mov al, byte ptr 0 [bp]
mov ah, 0eh ;write teletype
mov bh, 0 ;video page
int 10h
inc bp
jmp printit
stopit: int 20h
end