8. 已知数组A包含20个互不相等的字型整数,数组B包含30个互不相等的字型整数,试编制一程序把既在A中又在B中出现的数存放于数组C中。
这题跟上一道题很类似,只是这道题是相等loadc bufb比完了nexta
DATAS SEGMENT
BUFA DW 0000H,0011H,0022H,0033H,0044H,0055H,0066H,0077H,0088H,0099H;这里不加逗号
DW 7777H,7777H,7777H,7777H,7777H,7777H,7777H,7777H,7777H,7777H
BUFB DW 0000H,0011H,0022H,0033H,0044H,0055H,0066H,0077H,0088H,0099H
DW 1011H,1022H,1033H,1044H,1055H,1066H,1077H,1088H,1099H,1000H
DW 2011H,2022H,2033H,2044H,2055H,2066H,2077H,2088H,2099H,2000H
BUFC DW 20 DUP(0);
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
MOV ES,AX
MOV BX,0
MOV SI,0
MOV DI,0
COMPARE:
MOV AX,BUFA[SI]
MOV CX,BUFB[SI]
CMP AX,CX
JE LOADC
JMP BNEXT
BNEXT:
ADD DI,2
CMP DI,60
JE ANEXT
JMP COMPARE
ANEXT:
ADD SI,2
CMP SI,40
JE END0
MOV DI,0
JMP COMPARE
LOADC:
MOV BUFC[BX],AX
ADD BX,2
JMP ANEXT
END0:
;此处输入代码段代码
MOV AH,4CH
INT 21H
CODES ENDS
END START