汇编语言 将20个数据的数组分成两组,正数数组P和负数数组N,并分别显示两个数组的个数
程序员文章站
2022-03-01 15:44:08
...
data segment
array dw 1,2,3,-4,5,-6,7,-8
data ends
ext segment
pdata dw 8 dup(?)
ndata dw 8 dup(?)
a db 30h
b db 30h
ext ends
code segment
assume cs:code,ds:data,es:ext
start:
mov ax,data
mov ds,ax
mov ax,ext
mov es,ax
lea bx,array
lea si,pdata
lea di,ndata
mov cx,8
T: mov ax,[bx]
cmp ax,0
jg P
mov es:[di],ax
add es:[a],1
add di,2
jmp L
P: mov es:[si],ax
add es:[b],1
add si,2
L:add bx,2
loop T
mov ah,2
mov dl,es:[b]
int 21h
mov dl,20h
mov ah,2
int 21h
mov ah,2
mov dl,es:[a]
int 21h
mov ax,4c00h
int 21h
code ends
end start
上一篇: git