Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- jmp start
- mess1 db 'Even elements sum: $'
- mess2 db 'Odd elements sum: $'
- strClose db 'Press any key to exit$'
- nextLine db '', 13, 10, '$'
- spaceLine db ' ', '$'
- array db 9, 2, 7, 63, 55, 8, 6, 3, 10, 4, 21, 30, 45, 99, 50, 111
- size = $ - array ; ðàçìåð ìàññèâà
- start:
- mov ah, 9
- mov dx, mess1
- int 21h
- mov si, array ; SI = óêàçàòåëü íà ìàññèâ
- mov cx, size ; CX = äëèíà ìàññèâà/öèêëà
- xor ax, ax ; î÷èùàåì ÀÕ (ñþäà áóäåì ÷èòàòü)
- xor bx, bx ; î÷èùàåì ÂÕ (çäåñü áóäåò ñóììà)
- xor dx, dx
- cycle1:
- lodsb ; áåð¸ì â AL î÷åðåäíîé áàéò èç SI
- test ax, 1
- jz isEven
- add dx, ax
- loop cycle1
- prep:
- ; push bx
- mov ax, bx
- mov bx, 10
- call hex2asc
- push dx
- mov ah, $09
- mov dx, nextLine
- int 21h
- mov ah, $09
- mov dx, mess2
- int 21h
- pop dx
- mov ax, dx
- mov bx, 10
- call hex2asc
- exit:
- mov ah, $09
- mov dx, nextLine
- int 21h
- mov ah, $09
- mov dx, strClose
- int 21h
- mov ah, $08
- int 21h
- ret ; íà âûõîä!
- isEven:
- add bx, ax
- loop cycle1 ; ìîòàåì öèêë ÑÕ-ðàç
- jmp prep
- hex2asc: ; Ôóíêöèÿ ïåðåâîäèò ÷èñëà â ñèìâîëû
- pusha ; Âõîä: ÀÕ = ÷èñëî, BX = ñèñòåìà ñ÷èñëåíèÿ
- xor cx, cx ; Âûõîä: íà ýêðàíå
- isDiv:
- xor dx, dx
- div bx
- push dx
- inc cx
- or ax, ax
- jnz isDiv
- isOut:
- pop ax
- cmp al, 9
- jle noHex
- add al, 7
- noHex:
- add al, 30h
- int 29h
- loop isOut
- popa
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement