;方法2
;将首地址为MEM的100个字的数组中所有为0的项删除
;并将后续项向前压缩,最后将数组剩余部分补上0DATA SEGMENT
MEM DW 1,2,0,3,0,0,4,5,0,0
COUNT DW ($-MEM)/2
DATA ENDS
STACK SEGMENT PARA STACK
DW 128 DUP(?)
TOP LABEL WORD
STACK ENDS
CODE SEGMENT
ASSUME SS:STACK,CS:CODE,DS:DATA
MAIN PROC FAR
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
LEA SP,TOP
MOV CX,COUNT
LEA SI,MEM
SUB SI,2 ;先减2再加2相互抵消