Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. .model small
  2. .stack 100h
  3. .data
  4. a dt ?
  5. b dt ?
  6. c dt ?
  7. str1 db 13,"Enter a = ",'$'
  8. str2 db 13,"b = ",'$'
  9. str3 db 13,"c = ",'$'
  10. length dw 0
  11. after_poin dw 0
  12. fminus dw 0
  13.  
  14. .code
  15.  
  16. read_fun PROC
  17. mov ax, 0
  18. mov length, ax
  19. mov after_poin, ax
  20. mov fminus, ax
  21.  
  22. cin:
  23. mov ah, 08h
  24. int 21h
  25.  
  26. cmp al, '0'
  27. jl next ;<
  28. cmp al, '9'
  29. jg next ;>
  30. inc length
  31.  
  32. mov ax, '0'
  33. sub al, ax
  34. push al
  35.  
  36. mov ax, 0
  37. cmp after_poin, ax
  38. je read ;=
  39. inc after_poin
  40.  
  41. read:
  42.  
  43.  
  44. next:
  45. cmp al, '-'
  46. je minus
  47. cmp al, 8
  48. je bsckspace
  49. cmp al, '.'
  50. je p
  51.  
  52.  
  53. bsckspace:
  54. mov ax, 1
  55. cmp length, ax
  56. je delete_minus
  57.  
  58. mov ax, 0
  59. cmp length, ax
  60. jg out
  61.  
  62. mov ax, 1
  63. cmp after_poin, ax
  64. je del_poin
  65.  
  66. del_poin:
  67. mov ax, 0
  68. mov after_poin, ax
  69.  
  70. delete_minus:
  71. mov ax, 0
  72. mov fminus, ax
  73.  
  74. out:
  75. pop al
  76. p:
  77. mov ax, 0
  78. cmp fminus, ax
  79. jge check ; >=
  80.  
  81. mov ax, 2
  82. cmp length, ax
  83. jge write_point
  84.  
  85. mov ax, 0
  86. cmp after_poin, ax
  87. jne cin ;!=
  88. inc after_poin
  89.  
  90. mov ah, 02h
  91. mov dl, '.'
  92. int 21h
  93.  
  94. jmp cin
  95.  
  96. check:
  97. mov ax, 1
  98. cmp length, ax
  99. je write_point
  100. jmp cin
  101.  
  102. write_point:
  103. inc after_poin
  104. inc length
  105. mov ah, 02h
  106. mov dl, '.'
  107. int 21h
  108.  
  109. jmp cin
  110.  
  111. minus:
  112. mov ax, 0
  113. cmp fminus, ax
  114. jmp cin
  115. mov ax, 1
  116. mov fminus, ax
  117.  
  118.  
  119. mov ah, 02h
  120. mov dl, '-'
  121. int 21h
  122.  
  123. jmp cin
  124.  
  125. ret
  126. read_fun endp
  127.  
  128. count_x PROC
  129.  
  130. ret
  131. count_x endp
  132.  
  133. output PROC
  134.  
  135. ret
  136. output endp
  137.  
  138. start:
  139. mov ax, @data
  140. mov ds, ax
  141. mov es, ax
  142.  
  143. mov ah, 09h
  144. mov dx, offset str1
  145. int 21h
  146.  
  147.  
  148. call read_fun
  149.  
  150.  
  151. mov ax, 4c00h
  152. int 21h
  153. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement