首页 > 解决方案 > 在汇编语言编程中用星号替换元音

问题描述

我创建了这个程序,但我必须添加代码以将元音替换为字符串中的星号我能得到任何帮助吗?它必须有 BufferedKeyboard Input、打印字符串、打印字符、CMP 和跳转指令。

.model small
.stack
.data
s1   db  'Enter name: $'
s2   db  0ah,0dh,'Hello, $'
buff db  20,?,20 dup(?) 
temp db  20 dup(?)


.code
m   proc
mov ax,@data
mov ds,ax   ; ds is needed for si
mov es,ax   ; es is needed for di   

mov ah,9    ; display 'Enter name'
mov dx,offset s1
int 21h

mov ah,0ah  ; get string input
mov dx,offset buff  ; input string will be stored in 'buff'
int 21h

mov si,offset buff  ;point si to 'buff' where the string is 
mov di,offset temp  ;point di to 'temp' 

inc si          ;point si to the number of characters in the string
lodsb           ;load the number pointed to by si into al; al now 
will 
hold the number of characters in the string     
mov ch,0
mov cl,al   ;copy al to cl; the number in cl will now serve as the 
counter for the loop
ulit:   movsb       ;copy the character pointed to by si to the 
location 
pointed to by di in each iteration
loop ulit

mov al,'$'  ;append the $ at the end of the string in 'temp'
stosb

mov ah,9    ;display 'Hello'
mov dx,offset s2
int 21h
mov dx,offset temp ; display the string in 'temp'
int 21h  

mov ah,4ch  ;terminate program
int 21h
m   endp
end m 

标签: assemblyx86-16

解决方案


推荐阅读