文件名称:汇编打字游戏
文件大小:2KB
文件格式:ASM
更新时间:2017-05-26 11:20:15
汇编
CODE SEGMENT ASSUME DS:DATA, CS:CODE, SS:STACK START: MOV AX, DATA MOV DS, AX MOV CX, 10 MOV SI, 0 LP: LEA DX, N CALL PRINT MOV DX, [STR+SI] CALL PRINT LEA DX, N CALL PRINT LEA DX, MSG CALL PRINT SCANF BUF LEA DX, N CALL PRINT MOV DX, [STR+SI] LEA DI, BUF+2 CALL strcmp CMP BX, 0 JNE EQUIL LEA DX, NO CALL PRINT JMP CONTINUE EQUIL: LEA DX, YES CALL PRINT CONTINUE: ADD SI, 2 LEA DX, N CALL PRINT LOOP LP MOV AH, 4CH INT 21H PRINT PROC NEAR ; 相当于 C 语言的 printf PUSH AX MOV AH, 09H INT 21H POP AX RET PRINT ENDP strcmp PROC NEAR ; 相当于 C 语言的 strcmp() PUSH AX PUSH CX PUSH DX PUSH SI PUSH DI XOR CX, CX MOV BX, 1 MOV SI, DX MOV AH, BYTE PTR [DI] CMP AH, '$' JE EXIT LP2: MOV AH, BYTE PTR [DI] INC DI CMP AH, '$' JZ RETURN MOV AL, BYTE PTR [SI] INC SI CMP AL, AH JNZ LP2 JZ EXIT RETURN: XOR BX, BX JMP EXIT