• 全部
• 问答

# 如何删除数组中的值????

jacky_shen 2004-07-14 01:45:08
TITLE 1017

DATA SEGMENT
COUNT DW 0
CNT DW ?
TMP DW ?
DATA ENDS

EXTR SEGMENT
LIST DW 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
EXTR ENDS

CODE SEGMENT
ASSUME DS:DATA
ASSUME CS:CODE
ASSUME ES:EXTR

REMOVE PROC
PUSH CX
PUSH DI
DO:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO
POP DI
POP CX
RET
REMOVE ENDP

START:
MOV AX, DATA
MOV DS, AX
MOV AX, EXTR
MOV ES, AX

MOV CX, ES:LIST
MOV CNT, CX
MOV AX, 2
MOV DI, ES:OFFSET LIST[2]
SUB DI, 2

TEST AX, 0FFFFH
JZ EXIT
A:
CMP AX, ES:[DI]
LOOPNE A

PUSH CX
PUSH DI
DO:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO
POP DI
POP CX

LOOP A

EXIT:
MOV AH, 4CH
INT 21H

CODE ENDS
END START

AX存放一个数值(2)，LIST是一个数组。

...全文
103 点赞 收藏 3

3 条回复

SDFDSAC 2004-07-17

csdsjkk()是正确的

SDFDSAC 2004-07-16
DATA SEGMENT
COUNT DW 0
CNT DW ?
TMP DW ?
DATA ENDS

EXTR SEGMENT
LIST DW 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
EXTR ENDS

CODE SEGMENT
ASSUME DS:DATA
ASSUME CS:CODE
ASSUME ES:EXTR

REMOVE PROC
PUSH CX
PUSH DI
DO:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO
POP DI
POP CX
RET
REMOVE ENDP

START:
MOV AX, DATA
MOV DS, AX
MOV AX, EXTR
MOV ES, AX

MOV CX, ES:LIST
MOV CNT, CX
MOV AX, 2
MOV DI, OFFSET LIST[2] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB DI, 2

TEST AX, 0FFFFH
JZ EXIT
A:
CMP AX, ES:[DI]
LOOPNE A

jne exit ;;;

push ax ;;;

PUSH CX
PUSH DI
DO1:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO1
POP DI
POP CX

pop ax ;;;

LOOP A

EXIT:
MOV AH, 4CH
INT 21H

CODE ENDS
END START

csdsjkk 2004-07-14
DATA SEGMENT
COUNT DW 0
CNT DW ?
TMP DW ?
DATA ENDS

EXTR SEGMENT
LIST DW 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
EXTR ENDS

CODE SEGMENT
ASSUME DS:DATA
ASSUME CS:CODE
ASSUME ES:EXTR

REMOVE PROC
PUSH CX
PUSH DI
DO:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO
POP DI
POP CX
RET
REMOVE ENDP

START:
MOV AX, DATA
MOV DS, AX
MOV AX, EXTR
MOV ES, AX

MOV CX, ES:LIST
MOV CNT, CX
MOV AX, 2
MOV DI, ES:OFFSET LIST[2]
SUB DI, 2

TEST AX, 0FFFFH
JZ EXIT
A:
CMP AX, ES:[DI]
LOOPNE A

jne exit ;;;

push ax ;;;

PUSH CX
PUSH DI
DO1:
MOV BX, DI
MOV AX, ES:[DI]
MOV ES:[BX], AX
LOOP DO1
POP DI
POP CX

pop ax ;;;

LOOP A

EXIT:
MOV AH, 4CH
INT 21H

CODE ENDS
END START

2.0w+

2004-07-14 01:45