Advertisement
Sauka1337

Untitled

Apr 8th, 2024
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. org 100h
  2.  
  3. jmp start
  4.  
  5. mess1 db 'String with replaced elements: $'
  6.  
  7.  
  8. strClose db 'Press any key to exit$'
  9. nextLine db '', 13, 10, '$'
  10. spaceLine db ' ', '$'
  11.  
  12. string db '1 2 3 4 5 6 2 7 8 2'
  13. replaceNum db '2'
  14.  
  15. size = $ - string ; ðàçìåð ìàññèâà
  16.  
  17. start:
  18. mov ah, 9
  19. mov dx, mess1
  20. int 21h
  21.  
  22. mov di, string ; DI = óêàçàòåëü íà ìàññèâ
  23. mov cx, size ; CX = äëèíà ìàññèâà/öèêëà
  24. dec cx
  25.  
  26. xor ax, ax ; î÷èùàåì ÀÕ (ñþäà áóäåì ÷èòàòü)
  27. xor bx, bx ; î÷èùàåì ÂÕ (çäåñü áóäåò ñóììà)
  28.  
  29. mov al, [replaceNum]
  30.  
  31.  
  32. cycle:
  33. scasb ; ñðàâíèâàåì ñ AL î÷åðåäíîé áàéò èç DI
  34. push ax
  35.  
  36. jz found
  37. mov bx, [di-1]
  38.  
  39. continue:
  40.  
  41. mov ah, 02h
  42. mov dl, bl
  43. int 21h
  44.  
  45. ; mov ah, $09
  46. ; mov dx, spaceLine
  47. ; int 21h
  48.  
  49. pop ax
  50.  
  51. loop cycle
  52.  
  53. prep:
  54. mov ah, $09
  55. mov dx, nextLine
  56. int 21h
  57.  
  58. jmp exit
  59.  
  60.  
  61. found:
  62. mov bx, '0'
  63.  
  64. jmp continue
  65.  
  66. exit:
  67. mov ah, $09
  68. mov dx, nextLine
  69. int 21h
  70.  
  71. mov ah, $09
  72. mov dx, strClose
  73. int 21h
  74.  
  75. mov ah, $08
  76. int 21h
  77. ret ; íà âûõîä!
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement