标签:sci jmp fse star cte off wait char hex
10换2
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DATA SEGMENT
MES1 DB ‘The ascii code of decimal code are:$‘
BUF DB 30H,30H,30H,31H,32H
DB 10H DUP(0)
DDATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DDATA
START: MOV AX,DDATA
MOV DS,AX
MOV SI,OFFSET BUF
MOV BX,000AH
MOV CX,0004H
MOV AH,00H
MOV AL,[SI]
SUB AL,30H
A1: IMUL BX
ADD AL,[SI+01]
SUB AL,30H
INC SI
LOOP A1
MOV [SI],AX
MOV DX,OFFSET MES1
MOV AH,09H
INT 21H
INC SI ;显示高字节
CALL SHOW
DEC SI ;显示低字节
CALL SHOW
WAIT1: MOV AH,1 ;判断是否有按键按下
INT 16H
JZ WAIT1 ;无按键则跳回继续等待,有则退出
MOV AX,4C00H
INT 21H
SHOW PROC NEAR
MOV AL,DS:[SI]
AND AL,0F0H ;取高4位
SHR AL,4
CMP AL,0AH ;是否是A以上的数
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,DS:[SI]
AND AL,0FH ;取低4位
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
RET
ENDP
CODE ENDS
END START
;A3-2.asm
;将十进制数的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 ;取高4位
SHR AL,4
CMP AL,0AH ;是否是A以上的数
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,DS:[SI]
AND AL,0FH ;取低4位
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
RET
ENDP
CODE ENDS
END START
;A3-3.asm
;将十六进制的ASCII码转换为十进制数
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DDATA SEGMENT
MES1 DB ‘The ascii code of hex are:$‘
BUF DB 0CH,00H
DB 10H DUP(0)
DDATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DDATA
START: MOV AX,DDATA
MOV DS,AX
MOV SI,OFFSET BUF
MOV DX,[SI]
MOV BX,SI
ADD BX,2
ADD SI,7
A1: DEC SI
MOV AX,DX
MOV DX,0000H
MOV CX,000AH
DIV CX
XCHG AX,DX
ADD AL,30H
MOV [SI],AL
CMP DX,0000H
JNE A1
A2: CMP SI,BX
JZ A3
DEC SI
MOV AL,30H
MOV [SI],AL
JMP A2
A3: MOV CX,5
MOV SI,OFFSET BUF
ADD SI,2
MOV DX,OFFSET MES1
MOV AH,09H
INT 21H
A4: CALL SHOW
MOV DL,20H
MOV AH,02H
INT 21H
INC SI
LOOP A4
WAIT1: MOV AH,1 ;判断是否有按键按下
INT 16H
JZ WAIT1 ;无按键则跳回继续等待,有则退出
MOV AX,4C00H
INT 21H
SHOW PROC NEAR
MOV AL,DS:[SI]
AND AL,0F0H ;取高4位
SHR AL,4
CMP AL,0AH ;是否是A以上的数
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,DS:[SI]
AND AL,0FH ;取低4位
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
RET
ENDP
CODE ENDS
END START
;A3-4.asm
;BCD码转换为二进制码
STACK1 SEGMENT STACK
DW 256 DUP(?)
STACK1 ENDS
DDATA SEGMENT
MES1 DB ‘The BCD code of binary are:$‘
BUF DB 01H,07H,03H,04H,05H,01H,06H,08H
DB 10H DUP(0)
DDATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DDATA
START: MOV AX,DDATA
MOV DS,AX
MOV CX,0004H
MOV DI,OFFSET BUF
A1: MOV AL,[DI]
ADD AL,AL
MOV BL,AL
ADD AL,AL
ADD AL,AL
ADD AL,BL
INC DI
MOV AH,00H
ADD AL,[DI]
MOV [DI+07H],AX
INC DI
LOOP A1
MOV DX,OFFSET MES1
MOV AH,09H
INT 21H
MOV CX,04H
MOV DI,OFFSET BUF
ADD DI,08H
A2: MOV AX,[DI]
CALL SHWORD
MOV DL,20H
MOV AH,02H
INT 21H
INC DI
INC DI
LOOP A2
WAIT1: MOV AH,1 ;判断是否有按键按下
INT 16H
JZ WAIT1 ;无按键则跳回继续等待,有则退出
MOV AX,4C00H
INT 21H
SHWORD PROC NEAR
MOV BL,AH
CALL SHOW
MOV BL,AL
CALL SHOW
RET
ENDP
SHOW PROC NEAR
PUSH AX
PUSH DX
MOV AL,BL
AND AL,0F0H ;取高4位
SHR AL,4
CMP AL,0AH ;是否是A以上的数
JB C2
ADD AL,07H
C2: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
MOV AL,BL
AND AL,0FH ;取低4位
CMP AL,0AH
JB C3
ADD AL,07H
C3: ADD AL,30H
MOV DL,AL ;show character
MOV AH,02H
INT 21H
POP DX
POP AX
RET
ENDP
CODE ENDS
END START
标签:sci jmp fse star cte off wait char hex
原文地址:http://www.cnblogs.com/s1104119631/p/7748456.html