在Assembly x86 16位

时间:2016-10-30 17:37:27

标签: assembly x86 dos tasm 16-bit

我试图编写一个程序,从键盘读取3个字符串,然后以小写形式显示2个字符串,最后一个以大写字母显示。这就是我到现在为止所做的:我可以读取字符串,但之后它将所有内容转换为大写字母。无论如何只转换最后一个字符串?提前致谢

.MODEL SMALL
.DATA
    MSG  DB  0DH,0AH, 'ENTER A STRING: $'
    MSG2 DB  0DH,0AH, ' YOUR STRING IS  :-----> :  $'
    STR1 DB  255 DUP(?)
.CODE
BEGIN:

    MOV AX,@DATA
    MOV DS,AX

    LEA DX,MSG  
    MOV AH,09H
    INT 21H

    LEA SI,STR1 
    MOV AH,01H

READ:
    INT 21H 
    ;MOV BL,AL

    CMP AL,0DH
    JE  DISPLAY

    SUB AL,20H
    MOV [SI],AL
    INC SI

    ;CMP BL,0DH
    JMP READ

DISPLAY:

    MOV AL,'$'  ;caracter '$'
    MOV [SI],AL ;

    LEA DX,MSG2 
    MOV AH,09H  
    INT 21H 


    LEA DX,STR1 
    MOV AH,09H  
    INT 21H

    ; MOV AH,4CH
    ; INT 21H

.EXIT
END BEGIN

我正在使用TASM。

1 个答案:

答案 0 :(得分:0)

谢谢大家的意见。我能够用这种方式解决它:

.MODEL SMALL
.STACK 100h
.DATA
    Mensagem1  DB  "Meu Prompt>>",'$',13,10
    first DB  80 DUP (?)
.CODE
    MOV AX, @DATA
    MOV DS, AX
    LEA DX, Mensagem1
    MOV AH, 9
    INT 21H
    LEA SI, first   
READ:
    MOV AH, 01H
    INT 21H
    CMP AL, 13
    JE  DONE
    OR AL, 20H
    MOV [SI], AL
    INC SI
    CMP AL, 20H
    JE READ2
    JMP READ
READ2:
    INT 21H
    CMP AL, 13
    JE  DONE
    OR AL, 20H
    MOV [SI], AL
    INC SI
    CMP AL, 20H
    JE READ3
    JMP READ2
READ3:
    INT 21H
    CMP AL, 13
    JE  DONE
    XOR AL, 20H
    MOV [SI], AL
    INC SI
    JMP READ3
DONE:
    MOV AL, '$'
    MOV [SI], AL
    LEA DX, Mensagem1
    MOV AH, 9
    INT 21H
    LEA DX, first
    MOV AH, 9
    INT 21H
    MOV AH,4CH
    INT 21H
END