Advertisement
anticlown

Assembler.Lab.3

Apr 4th, 2023 (edited)
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. org 100h
  2. jmp EnterPoint
  3.  
  4. Message_1:
  5. db 'New Array: $'
  6. Message_2:
  7. db 10, 'Number of negative numbers: $'
  8. TaskInfo:
  9. db "This program receives sequence of numbers and then replaces negatives ones with zeros. Also it counts how many times elements where replaced.", 10, 'Array:-1,-2,3,-4,5,6,-7,8,-9 ', 10, '$'
  10. Array db 9, -1,-2,3,-4,5,6,-7,8,-9
  11. Counter db 0
  12.  
  13. EnterPoint:
  14. mov ah, $09
  15. mov dx, TaskInfo
  16. int 21h
  17.  
  18. mov ah, $09
  19. mov dx, Message_1
  20. int 21h
  21.  
  22. mov bl, [Array]
  23.  
  24. call CycleStart
  25.  
  26. mov bl, [Array]
  27.  
  28.  
  29. call PrintArray
  30.  
  31. mov ah, $09
  32. mov dx, Message_2
  33. int 21h
  34.  
  35. call PrintCounter
  36.  
  37. mov ax, 0C01h
  38. int 21h
  39. ret
  40.  
  41.  
  42. CycleStart:
  43. mov cl, bl
  44. mov si, Array + 1
  45. ChangeLoop:
  46. mov dl, [si]
  47. cmp dl, 0
  48. jl Change
  49. inc si
  50. loop ChangeLoop
  51. jmp CheckCounter
  52. Change:
  53. mov byte [si], 0
  54. inc si
  55. inc [Counter]
  56. loop ChangeLoop
  57.  
  58. CheckCounter:
  59. dec bl
  60. jnz CycleStart
  61.  
  62. ret
  63.  
  64. PrintArray:
  65. mov cl, bl
  66. mov si, Array + 1
  67. LoopPrintArray:
  68. mov dx, [si]
  69. and dx, 00FFh
  70. add dl, '0'
  71. mov ah, 02h
  72. int 21h
  73.  
  74. mov dl, ' '
  75. mov ah, 02h
  76. int 21h
  77. inc si
  78. loop LoopPrintArray
  79.  
  80. ret
  81. PrintCounter:
  82. mov dx, word[Counter]
  83. and dx, 00FFh
  84. add dl, '0'
  85. mov ah, 02h
  86. int 21h
  87. ret
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement