but I don't know how to make arr2 to start at 20h
One way to make your second array start at address 20h, is to fill the gap between the end of the first array and the start of the second array.
The calculation looks like:
db (TargetAddress - CurrentAddress) dup 0
The target address of course is 20h, the current address is given by the special symbol $.
db 20h-$ dup (0)
save the amount of positive numbers in dh.
If you're only interested in the positive numbers, then it doesn't help to inc size on every iteration of the loop. Just increment the counter if the value that you copy to the second array is positive.
Also, why did you initialize the size variable to one? Starting it at zero makes more sense.
I need to write a program which copy only the positive numbers in address 0-10h
.DATA
arr1 db 0h, -1h, 2h, 3h, -4h, 5h, 6h, -7h, 8h, 9h, 10h
db 20h-$ dup (0)
arr2 db 11 dup (?)
size db 0
.CODE
main:
mov ax, @DATA
mov ds, ax ;You forgot this instruction!
xor bx, bx
xor si, si
copyloop:
mov al, arr1[si]
test al, al
js NotInterested ;Skip negative number
mov arr2[bx], al ;Copy positive number
inc bx
inc size
NotInterested:
inc si
cmp si, 11 ;Repeat for the 11 elements in first array
jb copyloop
mov dh, size ;Result to DH
mov ax, 4C00h ;Preferred way to end program on emu8086
int 21h
This solution can easily do without the size variable.
The count is already available from the value in BX that was used to index the second array.
.DATA
arr1 db 0h, -1h, 2h, 3h, -4h, 5h, 6h, -7h, 8h, 9h, 10h
db 20h-$ dup (0)
arr2 db 11 dup (?)
.CODE
main:
mov ax, @DATA
mov ds, ax ;You forgot this instruction!
xor bx, bx
xor si, si
copyloop:
mov al, arr1[si]
test al, al
js NotInterested ;Skip negative number
mov arr2[bx], al ;Copy positive number
inc bx
NotInterested:
inc si
cmp si, 11 ;Repeat for the 11 elements in first array
jb copyloop
mov dh, bl ;Result to DH
mov ax, 4C00h ;Preferred way to end program on emu8086
int 21h
ORG 0h, then address 20h is ... 20h bytes after that. Use padding or code to fill the gap.