如何解决如何使用 DOSBox 中的汇编程序消除字符串中的空格和标点符号?
遇到意外的文件结尾
;Program p02.asm
.MODEL small
.stack 100h
.data
source db "STRING,WITH. PUNCTUATION : AND * SPACES!$"
aux db " "
.code
mov ax,@data
mov ds,ax
;REMOVE EVERYTHING BUT UPPERCASE LETTERS.
mov si,offset source ; POINT TO STRING.
mov di,offset aux ; POINT TO AUXILIARY.
L1:
mov al,[ si ] ; get character from source
;CHECK IF END STRING ($).
cmp al,'$'
je finale
;CHECK IF CHAR IS UPPERCASE LETTER.
cmp al,65
jb is_not_a_letter ; CHAR IS LOWER THAN 'A'.
cmp al,90
ja is_not_a_letter ; CHAR IS HIGHER THAN 'Z'.
;copY LETTER TO AUX STRING.
mov [ di ],al
inc di ; POSITION FOR NEXT CHaraCTER.
is_not_a_letter:
inc si ; move to next character
jmp L1
finale:
mov [ di ],al ; '$',NECESSARY TO PRINT.
;PRINT STRING.
mov dx,OFFSET aux
mov ah,9
int 21h
;END PROGRAM.
mov ax,4c00h
int 21h
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。