49703100.doc - 32 - ߣUser
MOV AX, A [SI] ȡAеһ
LOOP2: CMP B [DI], AX Bе
JNE NO
MOV C [BX], AX ȴC ADD BX, 2
NO: ADD DI, 2
LOOP LOOP2 ADD SI, 2 POP CX LOOP LOOP1 RET
MAIN ENDP CSEG ENDS ϶ --------------------------------------------------------------------------
END START
5.20 ABCԪзֱ0֮ʹDԪУ
һΪ0ԪҲ0д˳ 𣺳£
DSEG SEGMENT A DW ? B DW ? C DW ? D DW 0 DSEG ENDS
-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR
ASSUME CS: CSEG, DS: DSEG
START: PUSH DS ÷DOS
SUB AX, AX PUSH AX
MOV AX, DSEG MOV DS, AX DSֵ
BEGIN: CMP A, 0
JE NEXT CMP B, 0 JE NEXT CMP C, 0 JE NEXT MOV AX, A ADD AX, B ADD AX, C MOV D, AX JMP SHORT EXIT
NEXT: MOV A, 0
MOV B, 0 MOV C, 0
EXIT: RET MAIN ENDP CSEG ENDS ϶ --------------------------------------------------------------------------
END START 5.21 ԱдһҪȽARRAYе16λݱȽϽնʾ
Ϣ
(1) ʾ0 (2) жʾ1
49703100.doc - 33 - ߣUser
(3) ʾ2 𣺳£
DSEG SEGMENT ARRAY DW 3 DUP (?) DSEG ENDS
-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR
ASSUME CS: CSEG, DS: DSEG
START: PUSH DS ÷DOS
SUB AX, AX PUSH AX
MOV AX, DSEG MOV DS, AX DSֵ
BEGIN: LEA SI, ARRAY
MOV DX, 0 (DX)ڴĽ MOV AX, [SI] MOV BX, [SI+2] CMP AX, BX Ƚϵһ͵ڶǷ JNE NEXT1 INC DX
NEXT1: CMP [SI+4], AX Ƚϵһ͵Ƿ
JNE NEXT2 INC DX
NEXT2: CMP [SI+4], BX Ƚϵڶ͵Ƿ
JNE NUM INC DX
NUM: CMP DX, 3
JL DISP DEC DX
DISP: ADD DL, 30H תΪASCII
MOV AH, 2 ʾһַ INT 21H RET
MAIN ENDP CSEG ENDS ϶ --------------------------------------------------------------------------
END START
5.22 Ӽһϵַ(Իس)ĸַ֡ʾ
ļ 𣺳£
DSEG SEGMENT
ALPHABET DB ?ĸַΪ, ?$ NUMBER DB ?ַΪ, ?$ OTHER DB ?ַΪ, ?$ CRLF DB 0DH, 0AH, ?$ DSEG ENDS
-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR
ASSUME CS: CSEG, DS: DSEG
START: PUSH DS ÷DOS
SUB AX, AX PUSH AX
MOV AX, DSEG MOV DS, AX DSֵ
49703100.doc - 34 - ߣUser
BEGIN:
INPUT:
OTHER: NEXT1:
NEXT2:
NEXT3:
NEXT4:
NEXT5:
MOV BX, 0 MOV SI, 0 MOV DI, 0 MOV AH, 1 INT 21H CMP AL, 0DH JE DISP CMP AL, 30H JAE NEXT1 INC DI JMP SHORT INPUT CMP AL, 39H JA NEXT2 INC SI JMP SHORT INPUT CMP AL, 41H JAE NEXT3 JMP SHORT OTHER CMP AL, 5AH JA NEXT4 INC BX JMP SHORT INPUT CMP AL, 61H JAE NEXT5 JMP SHORT OTHER CMP AL, 7AH JA SHORT OTHER INC BX JMP SHORT INPUT
ĸַ
ַ ַ һַ ǻس <0 ַ
>9
ַ
<ĸA
ַ >ĸZ ĸַA~Z
<ĸa
ַ >ĸz ַ ĸַa~z
LEA DX, ALPHABET CALL DISPLAY LEA DX, NUMBER MOV BX, SI CALL DISPLAY LEA DX, OTHER MOV BX, DI CALL DISPLAY RET
MAIN ENDP
-------------------------------------------------------------------------- DISPLAY PROC NEAR
MOV AH, 09H ʾַܵ INT 21H
CALL BINIHEX BXжתΪ16ʾӳ LEA DX, CRLF MOV AH, 09H ʾس INT 21H RET
DISPLAY ENDP
-------------------------------------------------------------------------- BINIHEX PROC NEAR BXжתΪ16ʾӳ
MOV CH, 4
ROTATE: MOV CL, 4
ROL BX, CL MOV DL, BL
DISP:
49703100.doc - 35 - ߣUser
AND DL, 0FH ADD DL, 30H CMP DL, 3AH A~F JL PRINT_IT ADD DL, 07H
PRINT_IT: MOV AH, 02H ʾһַ
INT 21H DEC CH JNZ ROTATE RET
BINIHEX ENDP CSEG ENDS ϶ --------------------------------------------------------------------------
END START
5.23 ѶABԱдйܣ
(1) һAУżBУ (2) оΪ1ԭ (3) оΪżı䡣 𣺳£
DSEG SEGMENT A DW B DW DSEG ENDS
-------------------------------------------------------------------------- CSEG SEGMENT MAIN PROC FAR
ASSUME CS: CSEG, DS: DSEG
START: PUSH DS ÷DOS
SUB AX, AX PUSH AX
MOV AX, DSEG MOV DS, AX DSֵ
BEGIN: MOV AX, A
MOV BX, B XOR AX, BX
TEST AX, 0001H ABͬΪż JZ CLASS ABΪżת TEST BX, 0001H JZ EXIT BΪżת XCHG BX, A AΪżA MOV B, BX żB JMP EXIT
CLASS: TEST BX, 0001H ABΪ
JZ EXIT ABͬΪżת INC B INC A
EXIT: RET MAIN ENDP CSEG ENDS ϶ --------------------------------------------------------------------------
END START
5.24 ѱƺ5ǵĶεַƫƵַݶεԾSINGLISTС
һݴӼĸ1~5תȥִеijһ 𣺳£
DSEG SEGMENT