汇编题目 急求答案 在线等
3.已知在以ARRAY为首地址的数据区中存放5个带符号字数据:ARRAYDW1,-2,-1,3,4编程将ARRAY分成两个数组:正数数组P_ARY和负数数组N_ARY,并...
3.已知在以ARRAY为首地址的数据区中存放5个带符号字数据:
ARRAY DW 1,-2,-1,3,4
编程将ARRAY分成两个数组:正数数组P_ARY和负数数组N_ARY,并分别显示正数项个数和负数项个数。
要代码 展开
ARRAY DW 1,-2,-1,3,4
编程将ARRAY分成两个数组:正数数组P_ARY和负数数组N_ARY,并分别显示正数项个数和负数项个数。
要代码 展开
1个回答
展开全部
data segment
ARRAY DW 1,-2,-1,3,4
P_ARY DW 5(?)
N_ARY DW 5(?)
count DW 0
data ends
code segment
main proc far
assume cs:code,ds:data
start:
mov ax, ds
push ax
mov ax,0
push ax
mov cx,5
mov di,offset ARRAY
mov si,offset N_ARY
lea bx,P_ARY
again:
mov ax,[di]
cmp ax,0
ja positive
inc si
mov [si],ax
jmp next
positive:
inc bx
mov [bx],ax
next:
inc di
loop again
sub di,offset N_ARY
mov N_ARY,di
sub si,offset P_ARY
mov P_ARY,si
ret
main endp
code ends
end start
ARRAY DW 1,-2,-1,3,4
P_ARY DW 5(?)
N_ARY DW 5(?)
count DW 0
data ends
code segment
main proc far
assume cs:code,ds:data
start:
mov ax, ds
push ax
mov ax,0
push ax
mov cx,5
mov di,offset ARRAY
mov si,offset N_ARY
lea bx,P_ARY
again:
mov ax,[di]
cmp ax,0
ja positive
inc si
mov [si],ax
jmp next
positive:
inc bx
mov [bx],ax
next:
inc di
loop again
sub di,offset N_ARY
mov N_ARY,di
sub si,offset P_ARY
mov P_ARY,si
ret
main endp
code ends
end start
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询