Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2. .model small
  3. .stack 100h
  4. .data
  5. str db 80 dup
  6. .code
  7. mov ax,@data
  8. mov ds,ax
  9. main proc
  10.     mov si,0
  11.     mov di,0
  12.     mov ah,1
  13.     int 21h
  14.     mov str[si],al
  15.     input:
  16.         mov ah,1
  17.         int 21h  
  18.         inc si
  19.         cmp al,0dh
  20.         je newline
  21.         mov di,0
  22.         jmp compare
  23.        
  24.        
  25.     compare:
  26.         cmp str[di],al
  27.         jg swap
  28.         cmp di,si
  29.         je new
  30.        
  31.    
  32.      swap:
  33.         mov bl,str[di]
  34.         mov str[di],al
  35.         mov al,bl
  36.         inc di
  37.         jmp compare
  38.      
  39.      new:
  40.         mov str[si],al
  41.         jmp input
  42.      
  43.      newline:
  44.         mov di,0
  45.         mov ah,2
  46.         mov dl,0dh
  47.         int 21h
  48.         mov dl,0ah
  49.         int 21h
  50.     output:
  51.         mov dl,str[di]
  52.         int 21h
  53.         inc di
  54.         cmp di,si
  55.         je end
  56.         jmp output
  57.            
  58.     end:
  59.         mov ah,4ch
  60.         int 21h
  61. main endp
  62. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement