1 ; multi-segment executable file template. 2 3 data segment 4 STRING DB 'SPACE EXPLORERS INC' 5 PRLINE DB 'SPACE EXPLORERS INCE' 6 LAST DB ' ' 7 same DB 'MATCH$' 8 nsame DB 'NO MATCH$' 9 ends10 11 stack segment12 dw 128 dup(0)13 ends14 15 code segment16 start:17 ; set segment registers:18 mov ax, data19 mov ds, ax20 mov es, ax21 22 ; add your code here 23 mov cx,PRLINE-STRING ;先判断长度,长度不相等直接不匹配24 cmp cx,LAST-PRLINE25 jnz NEQUAL26 27 lea si,STRING ;长度相等则逐个匹配28 mov di,offset PRLINE29 cld30 rep cmpsb31 jz EQUAL32 jnz NEQUAL33 34 EQUAL: ;输出结果35 lea dx,same 36 jmp NEXT 37 NEQUAL:38 lea dx,nsame39 NEXT:40 mov ah, 941 int 21h ; output string at ds:dx42 43 ; wait for any key.... 44 mov ah, 145 int 21h46 47 mov ax, 4c00h ; exit to operating system.48 int 21h 49 ends50 51 end start ; set entry point and stop the assembler.