在 Assembly x86 16 位上拆分字符串
Split strings on Assembly x86 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。
谢谢大家的评论。我是这样解决的:
.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
我正在尝试编写一个程序,从键盘读取 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。
谢谢大家的评论。我是这样解决的:
.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