INC DI LOOP AGAIN
EXIT: MOV AH,4CH INT 21H CODE ENDS END START 11
18. 答: 19. 答: CODE SEGMENT ASSUME CS:CODE START:
MOV AX,5678H MOV DX,1234H NOT AX NOT DX ADD AX,1 ADC DX,0 EXIT:
MOV AH,4CH INT 21H CODE ENDS END START
;本程序未考虑溢出的情况。 DATA SEGMENT A1 DW 5050H
A2 DW ? ;存A1的反码 A3 DW ? ;存A1的补码 DATA ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA START:
MOV AX,DATA MOV DS,AX MOV AX,A1 NOT AX MOV A2,AX INC AX MOV A3,AX EXIT:
MOV AH,4CH INT 21H CODE ENDS END START
13
12
20. 答: 21. 答:
DATA SEGMENT ;AT 5000H ORG 3481H DAT DB 12H DB ?,?,? DATA ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA START:
MOV AX,DATA MOV DS,AX MOV AL,DAT NEG AL
MOV DAT+1,AL MOV AL,DAT
XOR AL,00001111B MOV DAT+2,AL MOV AL,DAT
OR AL,11110000B MOV DAT+3,AL EXIT:
MOV AH,4CH INT 21H CODE ENDS END START COUNT=1000 DATA SEGMENT ORG 1000H
DAT DB 10 DUP (12H,-5,-3,0,-128,56H,98H,4,128,200) ORG 2000H MINDAT DB ? DATA ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA START:
MOV AX,DATA MOV DS,AX LEA SI,DAT MOV CX,COUNT DEC CX
MOV AL,[SI] NEXT: INC SI
14
CMP AL,[SI] JLE ISMIN MOV AL,[SI] ISMIN: LOOP NEXT MOV MINDAT,AL EXIT:
MOV AH,4CH INT 21H CODE ENDS END START 13
22. 答: DATA SEGMENT
STRING1 DB 'hELLO!' COUNT1=$-STRING1 STRING2 DB 'hEL1O!' COUNT2=$-STRING2 IM DB 'MATCH$' NM DB 'NOT MATCH$' DATA ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA START:
MOV AX,DATA MOV DS,AX
LEA SI,STRING1 LEA DI,STRING2 MOV CX,COUNT1 MOV BX,COUNT2 CMP CX,BX
JNZ DISPNOTMATCH NEXT:
MOV AL,[SI] MOV AH,[DI] CMP AL,AH
JNZ DISPNOTMATCH INC SI INC DI LOOP NEXT ISMATCH:
MOV DX,OFFSET IM MOV AH,9 INT 21H
15
JMP EXIT
DISPNOTMATCH: MOV DX,OFFSET NM MOV AH,9 INT 21H EXIT:
MOV AH,4CH INT 21H CODE ENDS END START 14
23. 答: 24. 答: DSEG SEGMENT DATA DB 5,6,7,8 DW ?
DATA2 DB 1,10,100,20 DSEG ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DSEG START:
MOV AX,DSEG MOV DS,AX MOV DX,0 MOV CX,4 LEA SI,DATA LEA DI,DATA2 NEXT:
MOV AL,[DI] MOV BL,[SI] CALL DOMUL ADD DX,AX INC DI INC SI LOOP NEXT
MOV WORD PTR DATA+4,DX EXIT:
MOV AH,4CH INT 21H DOMUL PROC MUL BL RET
DOMUL ENDP CODE ENDS
16