I took input in array. Then I tried to print the even numbers in the array. I got output as expected but I am getting extra numbers after printing the result. Like suppose my array is 1,2,3 output is
200000000000...
and continues.
My code:
include emu8086.inc
org 100h
define_scan_num
define_print_num
define_print_num_uns
.model small
.stack 100h
.data
a dw ?
b dw 50 dup(?)
z dw ?
.code
main proc
mov ax, @data
mov ds,ax
call scan_num
printn ""
mov a,cx
mov bx,1
for1:
push cx
call scan_num
printn ""
mov b[bx],cx
add bx,2
pop cx
loop for1
mov bx,1
mov cx,a
for2:
mov ax, b[bx]
mov dx,0
mov z,2
div z
cmp dx,0
je even
jne odd
loop for2
jmp skip
even:
mov ax,b[bx]
call print_num
printn ""
add bx,2
jmp for2
odd:
add bx,2
jmp for2
skip:
ret
main endp
end main