如何使用 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 (将#修改为@)