Advertisement
Guest User

Untitled

a guest
May 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. .model small
  2. stack 256h
  3. .data
  4. enter_str db 'Enter string:$'
  5. invite db '> $'
  6. max_str db 'Maximum number: $'
  7. min_str db 'Minimum number: $'
  8. string db 255, ?, 255 dup(?)
  9. error db 'No numbers in string$'
  10. new_line db 10,13,'$'
  11. max db 0
  12. min db 10
  13.  
  14. .code
  15. write macro string
  16. push ax
  17. push dx
  18. mov ah,09h
  19. mov dx,offset string
  20. int 21h
  21. pop dx
  22. pop ax
  23. endm
  24.  
  25. start:
  26. mov ax,@data
  27. mov ds,ax
  28.  
  29. write enter_str
  30. write new_line
  31.  
  32. mov dx,offset string
  33. mov ah,0Ah
  34. int 21h
  35.  
  36. mov bx,2
  37. xor ch,ch
  38. mov cl,string[1]
  39. cmp cx,0
  40. je er
  41.  
  42. find_max_min:
  43. mov al,string[bx]
  44. cmp al,'0'
  45. jl continue_2
  46. cmp al,'9'
  47. jg continue_2
  48. sub al,'0'
  49.  
  50. cmp al,max
  51. jl continue
  52. mov max,al
  53. continue:
  54.  
  55. cmp al,min
  56. jg continue_2
  57. mov min,al
  58. continue_2:
  59. inc bx
  60. loop find_max_min
  61.  
  62. er:
  63.  
  64. cmp min,10
  65. jne print_nums
  66. write new_line
  67. write error
  68. jmp quit
  69.  
  70. print_nums:
  71.  
  72. write new_line
  73. write max_str
  74. mov ah,02h
  75. mov dl,max
  76. add dl,'0'
  77. int 21h
  78. write new_line
  79. write min_str
  80. mov ah,02h
  81. mov dl,min
  82. add dl,'0'
  83. int 21h
  84.  
  85. quit:
  86. push ax
  87. mov ah,10h
  88. int 16h
  89. pop ax
  90. mov al,0
  91. mov ah,4Ch
  92. int 21h
  93. End start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement