Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- jmp start
- array db 1, -2, -4, 5, -5, -3, 9, 20
- size = $ - array
- mess1 db 'Sum of positive elements = $'
- mess2 db 'Count of negative elements = $'
- nextLine db '', 13, 10, '$'
- start:
- mov ah, 9
- mov dx, mess2
- int 21h
- mov si, array ; SI = óêàçàòåëü íà ìàññèâ
- mov cx, size ; CX = äëèíà ìàññèâà/öèêëà
- xor ax, ax ; î÷èùàåì ÀÕ (ñþäà áóäåì ÷èòàòü)
- xor dx, dx ;Äëÿ êîë-âà ìèíóñîâûõ
- xor bx, bx ; î÷èùàåì ÂÕ (çäåñü áóäåò ñóììà)
- mov dl, 1
- Cycle:
- lodsb
- test al, al
- jns M1
- inc bx
- loop Cycle
- M1:
- add dx, ax
- loop Cycle ;Èäåì íà ñëåäóþùóþ èòåðàöèþ
- mov ax, bx ; âûâîäèì ñóììó íà ýêðàí
- mov bx, 10 ; ñèñòåìà ñ÷èñëåíèÿ 10-òè÷íàÿ
- call hex2asc ; çîâ¸ì ôóíêöèþ âûâîäà ÷èñåë íà ýêðàí!
- dec dx
- mov bx, dx
- mov ah, $09
- mov dx, nextLine
- int 21h
- mov ah, $09
- mov dx, mess1
- int 21h
- mov ax, bx ; âûâîäèì ñóììó íà ýêðàí
- mov bx, 10 ; ñèñòåìà ñ÷èñëåíèÿ 10-òè÷íàÿ
- call hex2asc ; çîâ¸ì ôóíêöèþ âûâîäà ÷èñåë íà ýêðàí!
- Exit:
- mov ah, $08 ; AH=8 - ôóíêöèÿ DOS äëÿ ÷òåíèÿ ñèìâîëà áåç ýõà
- int 21h ; Âûçûâàåì ïðåðûâàíèå DOS
- ret ; Âîçâðàùàåìñÿ èç ïðîöåäóðû
- 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