Guest User

Untitled

a guest
Feb 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. //Developed by Evingtone
  2.  
  3. section .text
  4.  
  5. startnew:
  6.  
  7. mov ecx,newline
  8. mov edx,1
  9. mov eax,4
  10. mov ebx,1
  11. int 0x80
  12. ret
  13.  
  14. convert:
  15. mov ecx,[inp]
  16. mov bl,10
  17. mov al,cl
  18. sub al,30h
  19.  
  20. cmp ch,10
  21. je converted
  22. mul bl
  23. sub ch,30h
  24. add al,ch
  25. converted:
  26. mov byte[inp],al
  27. ret
  28.  
  29. takeinput:
  30. mov ecx,msgele
  31. mov edx,lmsgele
  32. mov eax,4
  33. mov ebx,1
  34. int 0x80
  35.  
  36. tinput:
  37.  
  38. mov ecx,inp
  39. mov edx,3
  40. mov eax,3
  41. mov ebx,0
  42. int 0x80
  43.  
  44.  
  45. call convert
  46.  
  47. ret
  48.  
  49. global _start
  50. _start:
  51.  
  52. mov ecx,noele
  53. mov edx,lnoele
  54. mov eax,4
  55. mov ebx,1
  56. int 0x80
  57.  
  58. call tinput
  59.  
  60. mov al,byte[inp]
  61. mov byte[n],al
  62.  
  63. mov ebx,0
  64. mov bl,[n]
  65. mov edx,0
  66. taking:
  67. push dx
  68. call takeinput
  69. mov al,byte[inp]
  70. mov edx,0
  71. pop dx
  72. mov byte[input+edx],al
  73. add dx,1
  74. mov bl,[n]
  75. cmp dl,bl
  76. jne taking
  77.  
  78. mov edx,0
  79. sort:
  80. mov bl,byte[input+eax]
  81. mov cl,byte[input+eax+1]
  82. cmp bl,cl
  83. jl dontswap
  84. mov byte[input+eax+1],bl
  85. mov byte[input+eax],cl
  86. dontswap:
  87. add eax,1
  88. mov bl,byte[n]
  89. sub bl,1
  90. cmp al,bl
  91. jne sort
  92. mov eax,0
  93. add edx,1
  94. mov bl,byte[n]
  95. add bl,1
  96. cmp dl,bl
  97. jne sort
  98.  
  99. call startnew
  100.  
  101. mov ecx,sortmsg
  102. mov edx,lsortmsg
  103. mov eax,4
  104. mov ebx,1
  105. int 0x80
  106.  
  107. mov edx,0
  108. mov esi,0
  109.  
  110. output:
  111.  
  112. push 29h
  113. mov ebx,0
  114. mov bl,byte[input+esi]
  115. mov ax,bx
  116. mov ebx,0
  117. mov bl,10
  118. break:
  119. mov edx,0
  120. div bx
  121. add dl,30h
  122. push dx
  123. cmp al,0
  124. jne break
  125.  
  126. mov edx,0
  127. pop dx
  128.  
  129. prints:
  130.  
  131. mov byte[printdata],dl
  132.  
  133. mov ecx,printdata
  134. mov edx,1
  135. mov eax,4
  136. mov ebx,1
  137. int 0x80
  138.  
  139. mov edx,0
  140. pop dx
  141. cmp dl,29h
  142. jne prints
  143.  
  144. mov ecx,space
  145. mov edx,1
  146. mov eax,4
  147. mov ebx,1
  148. int 0x80
  149.  
  150.  
  151. add esi,1
  152. mov ebx,0
  153. mov bl,byte[n]
  154. cmp esi,ebx
  155. jne output
  156.  
  157. call startnew
  158. call startnew
  159.  
  160. mov eax,1
  161. mov ebx,0
  162. int 0x80
  163.  
  164. section .bss
  165. input resb 100
  166.  
  167. section .data
  168. inp dd 30h
  169. temp db 30h
  170. space db 32
  171. newline db 10
  172. n db 30h
  173. printdata db 30h
  174. noele db "ENTER THE NO:OF ELEMENTS ",32
  175. lnoele equ $-noele
  176. msgele db "ENTER THE ELEMENT ",32
  177. lmsgele equ $-msgele
  178. sortmsg db "SORTED LIST",10
  179. lsortmsg equ $-sortmsg
Add Comment
Please, Sign In to add comment