Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .data
- msg db 10,13,"Enter 5 numbers: $"
- arr1 db 5 dup(0)
- msg1 db 10,13,"Enter a number: $"
- newline db 10,13,"$"
- count db 5
- i db 5
- j db 4
- print macro str
- lea dx,str
- mov ah,09h
- int 21h
- endm
- .code
- mov ax,@data
- mov ds,ax
- print msg
- lea si,arr1
- x:
- print msg1
- call accept
- mov [si],bl
- inc si
- dec count
- jnz x
- dec si
- mov cl,5
- mov count,cl
- xx:
- call display
- dec si
- dec count
- jnz xx
- mov al,5
- mov i,al
- ex1:lea si,arr1
- mov al,4
- mov j,al
- ex:call comparenexchange
- inc si
- dec j
- jnz ex
- dec i
- jnz ex1
- mov ah,4ch
- int 21h
- proc accept near:
- mov ah,01h
- int 21h
- mov cl,4
- shl al,cl
- mov bl,al
- mov ah,01h
- int 21h
- cmp al,39h
- jbe s
- sub al,7h
- s:
- sub al,30h
- add bl,al
- ret
- proc display near:
- print newline
- mov al,[si]
- and al,0f0h
- mov cl,4
- shr al,cl
- mov dl,al
- add dl,30h
- cmp dl,39h
- jle xxx:
- add dl,7h
- xxx:
- mov ah,02h
- int 21h
- mov al,[si]
- and al,0fh
- mov dl,al
- add dl,30h
- cmp dl,39h
- jle xxxx:
- add dl,7h
- xxxx:
- mov ah,02h
- int 21h
- ret
- proc comparenexchange near:
- mov al,[si]
- inc si
- mov bl,[si]
- cmp al,bl
- jbe exchange:
- call xchange
- exchange:
- dec si
- ret
- proc xchange near:
- dec si
- mov al,[si]
- inc si
- mov bl,[si]
- mov [si],al
- dec si
- mov [si],bl
- inc si
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement