Tuesday, May 3, 2011

Sort the characters in a string

Share Orkut
print macro msg lea dx,msg mov ah,09h int 21h endm .model small .stack 100h .data msg1 db 10,13,'Enter the string $' msg2 db 10,13,'Sorted String $' str1 db 50 dup('$') len1 db 0 .code mov ax,@data mov ds,ax print msg1 mov ah,3fh lea dx,str1 mov bx,00 int 21h sub ax,02 mov len1,al mov dl,len1 dec dl j1:lea si,str1 xor cx,cx mov cl,dl j3:mov al,[si] cmp al,1[si] jc j2 mov ah,1[si] mov 1[si],al mov [si],ah j2:inc si loop j3 dec dl cmp dl,00 jnz j1 print msg2 print str1 mov ah,4ch int 21h end

No comments:

Post a Comment