Advertisement
Sauka1337

Untitled

Mar 27th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. org 100h
  2.  
  3. jmp start
  4.  
  5. mess1 db 'Even elements sum: $'
  6. mess2 db 'Odd elements sum: $'
  7. strClose db 'Press any key to exit$'
  8. nextLine db '', 13, 10, '$'
  9. spaceLine db ' ', '$'
  10. array db 9, 2, 7, 63, 55, 8, 6, 3, 10, 4, 21, 30, 45, 99, 50, 111
  11. size = $ - array ; ðàçìåð ìàññèâà
  12.  
  13. start:
  14. mov ah, 9
  15. mov dx, mess1
  16. int 21h
  17.  
  18. mov si, array ; SI = óêàçàòåëü íà ìàññèâ
  19. mov cx, size ; CX = äëèíà ìàññèâà/öèêëà
  20. xor ax, ax ; î÷èùàåì ÀÕ (ñþäà áóäåì ÷èòàòü)
  21. xor bx, bx ; î÷èùàåì ÂÕ (çäåñü áóäåò ñóììà)
  22. xor dx, dx
  23.  
  24. cycle1:
  25. lodsb ; áåð¸ì â AL î÷åðåäíîé áàéò èç SI
  26.  
  27. test ax, 1
  28. jz isEven
  29.  
  30. add dx, ax
  31.  
  32. loop cycle1
  33.  
  34. prep:
  35. ; push bx
  36.  
  37. mov ax, bx
  38. mov bx, 10
  39. call hex2asc
  40.  
  41. push dx
  42.  
  43. mov ah, $09
  44. mov dx, nextLine
  45. int 21h
  46.  
  47. mov ah, $09
  48. mov dx, mess2
  49. int 21h
  50.  
  51. pop dx
  52.  
  53. mov ax, dx
  54. mov bx, 10
  55. call hex2asc
  56.  
  57. exit:
  58. mov ah, $09
  59. mov dx, nextLine
  60. int 21h
  61.  
  62. mov ah, $09
  63. mov dx, strClose
  64. int 21h
  65.  
  66. mov ah, $08
  67. int 21h
  68. ret ; íà âûõîä!
  69.  
  70.  
  71. isEven:
  72.  
  73. add bx, ax
  74.  
  75. loop cycle1 ; ìîòàåì öèêë ÑÕ-ðàç
  76. jmp prep
  77.  
  78.  
  79. hex2asc: ; Ôóíêöèÿ ïåðåâîäèò ÷èñëà â ñèìâîëû
  80. pusha ; Âõîä: ÀÕ = ÷èñëî, BX = ñèñòåìà ñ÷èñëåíèÿ
  81. xor cx, cx ; Âûõîä: íà ýêðàíå
  82. isDiv:
  83. xor dx, dx
  84. div bx
  85. push dx
  86. inc cx
  87. or ax, ax
  88. jnz isDiv
  89. isOut:
  90. pop ax
  91. cmp al, 9
  92. jle noHex
  93. add al, 7
  94. noHex:
  95. add al, 30h
  96. int 29h
  97. loop isOut
  98. popa
  99.  
  100. ret
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement