ASM program to count number of positive and negative numbers from a given series of numbers

Aim: – To write an assembly language program to count number of positive and negative numbers from a given series of numbers.

```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 MOV AX, DATA MOV DS, AX MOV CL, 05 XOR BL, BL XOR DL, DL LEA SI, SERIES   NEXT2: MOV AL, [SI] SHR AL, O1 JNC NEXT1 INC BL JMP NEXT3 NEXT1: INC DL NEXT3: INC SI DEC CL JNZ NEXT2 MOV POS, DL MOV NEG, BL END```

Result: The numbers of positive and negative numbers are counted from the given series.

4 Responses to “ASM program to count number of positive and negative numbers from a given series of numbers”

1. pls explain this program

2. Vishvesh

section .data
msg db ‘array32=80112233h,9011AA33h,10112233h,30112233h,40112233h,50112233h’,10
len equ \$ -msg
msg1 db ‘prog for positive and negative no by using BT’,10
msglen1 equ \$ – msg1
msg2 db ‘positive no are=’,10
msglen2 equ \$ – msg2
msg3 db ‘negative no are=’,10
msglen3 equ \$ – msg3
nxline db 10
array32 dd 80112233h,9011AA33h,10112233h,30112233h,40112233h,50112233h
n equ 6

section .bss
positive resw 3
negative resw 3
ascii_char resw 8
numcnt resw 1
%macro mac 2
mov eax,4
mov ebx,1
mov ecx,%1
mov edx,%2
int 0x80
%endmacro

section .text
global _start
_start:

mac msg,len
mac msg1,msglen1

mov word [positive],0
mov word [negative],0

mov esi, array32
mov word [numcnt],n
mov eax,0

up1:
mov ebx,[esi]
bt ebx,31
Jmp x1

inc word [negative]
Jmp x2

x1: inc word [positive]

x2:
dec word [numcnt]
jnz up1

mac msg2,msglen2
mov eax, [positive]
call hex2ascii_proc

mac msg3,msglen3
mov eax, [negative]

call hex2ascii_proc
mov eax,1
mov ebx,0
int 80H

hex2ascii_proc:
mov esi,ascii_char+7
mov ecx,08

up2:
mov edx,0
mov ebx,16
div ebx

cmp dl,09h

mov[esi],dl
dec esi
dec ecx
Jnz up2
mac ascii_char,8
mac nxline,1
ret

3. can you explain how the execution of the program posted by Vishvesh is done like a c++ program

4. Please explain program posted by vishvesh step by step and provide more programs and explain it…