;各位高手,我想删除元素3,然后把3后的2屏幕输出,但是老是感觉3没被从DATA_LIST中实际删除
DATAS SEGMENT PARA
STRING DB 'Hello World$'
FIVE DB 5
DATA_LIST DW 1,3,2,5,4
MAX DW ?
MIN DW ?
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
print macro string
lea dx,string
mov ah,09h
int 21h
endm
CODES SEGMENT PARA
ASSUME CS:CODES,DS:DATAS,SS:STACKS,ES:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV ES,AX
LEA DI,DATA_LIST
MOV AX,3
CALL DEL_UL
DEL_UL PROC NEAR
CLD
PUSH DI
MOV CX,ES:[DI];请问,这里(CX)=1,输出为3,但3被删除了,改成(cx)=5时,输出为2较合理,为什么?
ADD DI,2
REPNE SCASW
JE DELETE
POP DI
JMP SHORT EXIT
DELETE:JCXZ DEC_CNT
NEXT_EL:MOV BX,ES:[DI]
SUB DI,2
MOV ES:[DI],BX
ADD DI,2
LOOP NEXT_EL
DEC_CNT:POP DI
DEC WORD PTR ES:[DI]
DEL_UL ENDP
EXIT:
ADD DI,2
MOV DX,ES:[DI]
ADD DL,30H
MOV AH,2
INT 21H
LEA DX,STRING
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START
------解决方案--------------------------------------------------------
什么叫感觉没有??你要调试证明啊。
------解决方案--------------------------------------------------------
参照一下,自己分析下吧
- Assembly code
;各位高手,我想删除元素3,然后把3后的2屏幕输出,但是老是感觉3没被从DATA_LIST中实际删除DATAS SEGMENT PARA STRING DB 'Hello World$' FIVE DB 5 DATA_LIST DW 1,3,2,5,4 MAX DW ? MIN DW ?DATAS ENDSSTACKS SEGMENT ;此处输入堆栈段代码STACKS ENDSprint macro stringlea dx,stringmov ah,09hint 21hendmCODES SEGMENT PARA ASSUME CS:CODES,DS:DATAS,SS:STACKS,ES:DATASSTART: MOV AX,DATAS MOV DS,AX MOV ES,AX LEA DI,DATA_LIST MOV AX,3 CALL DEL_UL DEL_UL PROC NEAR CLD PUSH DI ;MOV CX,ES:[DI];请问,这里(CX)=1,输出为3,但3被删除了,改成(cx)=5时,输出为2较合理,为什么? ;ADD DI,2 XOR CX,CX MOV CL,FIVE REPNE SCASW JE DELETE POP DI JMP SHORT EXITDELETE:JCXZ DEC_CNTNEXT_EL:MOV BX,ES:[DI] ;SUB DI,2 ;MOV ES:[DI],BX MOV ES:[DI-2],BX ADD DI,2 LOOP NEXT_ELDEC_CNT:POP DI DEC WORD PTR ES:[DI]DEL_UL ENDPEXIT: ADD DI,2 MOV DX,ES:[DI] ADD DL,30H MOV AH,2 INT 21H LEA DX,STRING MOV AH,9 INT 21H MOV AH,4CH INT 21H CODES ENDS END START