admin 管理员组

文章数量: 887021


2024年1月26日发(作者:opacity visibility display)

;

;将十进制数的ASCII码转换为BCD码

STACK1 SEGMENT STACK

DW 256 DUP(?)

STACK1 ENDS

DDATA SEGMENT

MES1 DB 'The BCD code of decimal are:$'

BUF DB 31H,32H,33H,34H,35H

DB 10H DUP(0)

DDATA ENDS

CODE SEGMENT

ASSUME CS:CODE,DS:DDATA

START: MOV AX,DDATA

MOV DS,AX

MOV CX,0005H

MOV DI,OFFSET BUF

A1: MOV BL,0FFH

MOV AL,[DI]

CMP AL,3AH ;比较AL中的数是否是0~9的ASCII码

JNB A2

SUB AL,30H

JB A2

MOV BL,AL

A2: MOV AL,BL

MOV [DI+05H],AL

INC DI

LOOP A1

MOV SI,DI

MOV CX,05H

MOV DX,OFFSET MES1

MOV AH,09H

INT 21H

A3: CALL SHOW

MOV DL,20H

MOV AH,02H

INT 21H

INC SI

LOOP A3

WAIT1: MOV AH,1 ;判断是否有按键按下

INT 16H

JZ WAIT1 ;无按键则跳回继续等待,有则退出

MOV AX,4C00H

INT 21H

SHOW PROC NEAR

MOV AL,DS:[SI]

AND AL,0F0H

SHR AL,4

CMP AL,0AH

JB C2

ADD AL,07H

C2: ADD AL,30H

MOV DL,AL

MOV AH,02H

INT 21H

MOV AL,DS:[SI]

AND AL,0FH

CMP AL,0AH

JB C3

ADD AL,07H

C3: ADD AL,30H

MOV DL,AL

MOV AH,02H

INT 21H

RET

ENDP

CODE ENDS

END START

;取高4位

;是否是A以上的数

;show character

;取低4位

;show character


本文标签: 按键 等待 继续 是否 判断