汇编语言上机考试三星题8

和上一道题是子母题

已知数组A包含20个互不相等的字型整数,数组B包含30个互不相等的字型整数,试编制一程序把既在A中又在B中出现的数存放于数组C中。


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 SI,0

MOV DI,0

MOV BX,0

COMPARE:

MOV AX,BUFA[SI]

MOV CX,BUFB[DI]

CMP AX,CX

JNE BNEXT

JE LOADC

BNEXT:

ADD DI,2

CMP DI,60

JB COMPARE

JMP ANEXT

LOADC:

MOV BUFC[BX],AX

ADD BX,2

ADD SI,2

CMP SI,40

JE END0

MOV DI,0

JMP COMPARE

ANEXT:

ADD SI,2

CMP SI,40

JE END0

MOV DI,0

JMP COMPARE

END0:

    ;此处输入代码段代码

    MOV AH,4CH

    INT 21H

CODES ENDS

    END START

你可能感兴趣的:(汇编语言上机考试三星题8)