[英]x86 assembly program output
The task is to write an x86 assembly program that checks all capital latters and prints A and O, but I don't know how to write the program. 我们的任务是编写一个x86汇编程序,检查所有资本后期并打印A和O,但我不知道如何编写程序。 I tried this: 我试过这个:
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'The Upper Case Letters from A to Z are : $'
.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX
LEA DX, PROMPT ; load and print PROMPT
MOV AH, 9
INT 21H
MOV CX, 26 ; initialize CX
MOV AH, 2 ; set output function
MOV DL, 65 ; set DL with A
@LOOP: ; loop start
INT 21H ; print character
INC DL ; increment DL to next ASCII character
DEC CX ; decrement CX
JNZ @LOOP ; jump to label @LOOP if CXis 0
MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP
END MAIN
Before you print the character you can check if the character is A
or O
, print it, INT 21H
, if so or skip over the INT 21H
: 在打印字符之前,您可以检查字符是A
还是O
,打印, INT 21H
,如果是,或跳过INT 21H
:
....
LOOP:
if( DL == 'A' )
goto PRINT;
if( DL != 'O' )
goto SKIP;
PRINT:
putc(DL);
SKIP:
...
in assembly: 在汇编中:
...
@LOOP: ; loop start
CMP DL, 'A' ; if( DL == 'A' )
JE @PRINT ; goto PRINT
CMP DL, 'O' ; else if( DL != 'O' )
JNE @SKIP ; goto SKIP
@PRINT:
INT 21H ; print character
@SKIP:
INC DL ; increment DL to next ASCII character
DEC CX ; decrement CX
JNZ @LOOP ; jump to label @LOOP if CXis 0
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.