0% found this document useful (0 votes)
3 views

MPEXP05

The document contains assembly code that counts positive and negative numbers in a predefined array. It utilizes macros for printing messages and displays the counts of positive and negative numbers. The program ends by exiting the system call after displaying the results.

Uploaded by

krishnapate2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

MPEXP05

The document contains assembly code that counts positive and negative numbers in a predefined array. It utilizes macros for printing messages and displays the counts of positive and negative numbers. The program ends by exiting the system call after displaying the results.

Uploaded by

krishnapate2024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name : Krishna Dilip Pate

Batch : A3 Roll no : 67

section .data

msg1 db "Count of Positive numbers:"

len1 equ $-msg1

msg2 db "Count of negative numbers:"

len2 equ $-msg2

array db 10,12,-21,-12,-19,-34,41

%macro print 2

mov rax, 1

mov rdi, 1

mov rsi, %1

mov rdx, %2

syscall

%endmacro

section .bss

count resb 1

pcount resb 1

ncount resb 1

totalcount resb 2

section .text

global _start

_start:

mov byte [count], 7

mov byte [pcount], 0

mov byte [ncount], 0

mov rsi, array

Up:

mov al, [rsi]


js neg

inc byte [pcount]

jmp next

neg:

inc byte [ncount]

next:

inc rsi

dec byte [count]

jnz Up

print msg1, len1

mov bh, [pcount]

call disp

print msg2, len2

mov bh, [ncount]

call disp

mov rax, 60

xor rdi, rdi

syscall

disp:

mov byte [count], 2

loop_disp:

rol bh, 4

mov al, bh

and al, 0Fh

cmp al, 9

jbe add30

add al, 7

add30:

add al, 30h


mov [totalcount], al

print totalcount, 1

dec byte [count]

jnz loop_disp

ret

OUTPUT:

You might also like