我试图打印A-Z
代码MOV CX,[34H]
中的为什么CX相当于26?当我使用该代码时,它给了我A-Z的输出
TITLE SAMPLE PROGRAM USING CMP AND JMP
.MODEL SMALL
.STACK 0100H
.DATA
.CODE
START:
MOV AX,@DATA
MOV DS,AX
MOV AH,02H
MOV CX,[34H]
MOV DL,41H
START_LOOP:
INT 21H
INC DL
DEC CX
JZ EXIT
LOOP START_LOOP
EXIT: MOV AX,4C00H
INT 21H
END START
答案 0 :(得分:1)
[34H] 是地址,指针。 您通过地址34h获取价值。不知何故,有26个。
答案 1 :(得分:0)
以下是您的代码修复:
.MODEL SMALL
.STACK 0100H
.DATA
.CODE START:
MOV AX,@DATA
MOV DS,AX
MOV AH,02H
MOV CX,26
MOV DL,41H
START_LOOP:
INT 21H
PUSH DX ◄■■■ PRESERVE CURRENT LETTER.
MOV DL,20h ◄■■■ DL, NOT DH
INT 21H
POP DX ◄■■■ RESTORE CURRENT LETTER.
INC DL
LOOP START_LOOP
EXIT:
MOV AX,4C00H
INT 21H
修改:AaBbCc ......
.MODEL SMALL
.STACK 0100H
.DATA
upper db 'A' ◄■■■ VARIABLES TO CONTROL
lower db 'a' ◄■■■ UPPER AND LOWERCASE LETTER.
.CODE START:
MOV AX,@DATA
MOV DS,AX
MOV AH,02H
MOV CX,26
START_LOOP:
MOV DL,upper
INT 21H ◄■■■ DISPLAY UPPERCASE LETTER.
MOV DL,lower
INT 21H ◄■■■ DISPLAY LOWERCASE LETTER.
INC upper ◄■■■ NEXT UPPERCASE LETTER.
INC lower ◄■■■ NEXT LOWERCASE LETTER.
LOOP START_LOOP
EXIT:
MOV AX,4C00H
INT 21H