Assembly 仅识别和打印字符串中的元音

Assembly 仅识别和打印字符串中的元音,assembly,emu8086,Assembly,Emu8086,我有个问题。我必须在8086汇编中编写一个程序,用字符串填充数组,然后只打印出字符“a,a,e,e,I,I,o,o,u,u”。 我已成功打印出数组中的每个字符,但当我开始添加条件和跳转时,我的程序就进入了无限循环:( 以下是全部代码: org 100h jmp main ;messsages to be shown: msg1 db 'this is an example program.', 10, 13, 'made to show only the v

我有个问题。我必须在8086汇编中编写一个程序,用字符串填充数组,然后只打印出字符“a,a,e,e,I,I,o,o,u,u”。
我已成功打印出数组中的每个字符,但当我开始添加条件和跳转时,我的程序就进入了无限循环:(

以下是全部代码:

    org 100h

    jmp main

    ;messsages to be shown:

    msg1 db 'this is an example program.', 10, 13, 'made to show only the vocal letters of a string', 10, 13, 'write some words', 10, 10, 13, '$'
    msg2 db 10, 10, 13, 'your phrase:', 10, 10, 13, '$'

    ;variables

    aux db 0 
    vct dw 0

    ;program start

    main:
    lea dx, msg1
    mov ah, 09h
    int 21h

    mov cx, 20
    ingresarNumero:
    mov ah, 08h
    int 21h
    cmp al, 08h
    je borrar
    cmp al, 0Dh
    je enter 
    cmp al, 20h
    je enter
    mov ah, 0Eh
    int 10h
    mov ah, 0
    mov vct[si], ax
    inc si
    loop ingresarNumero

    ultimaPosicion:
    mov ah, 08h
    int 21h
    cmp al, 08h
    je borrar
    cmp al, 0Dh
    je finIngreso
    jmp ultimaPosicion

    borrar:
    cmp cx, 20
    je ingresarNumero
    mov ah, 0Eh
    int 10h
    mov al, 0
    int 10h
    mov al, 8
    int 10h
    pop ax
    inc cx
    dec si
    jmp ingresarNumero

    enter:
    cmp cx, 20
    je ingresarNumero
    jmp finIngreso

    finIngreso:

    lea dx, msg2
    mov ah, 09h
    int 21h

    push cx
    mov cx, si
    mov si, 0
    superloop: 
    mov ax, vct[si]
    mov ah, 0Eh
    int 10h
    inc si
    loop superloop


    ret
因为您没有为开始覆盖程序的字符保留足够的内存!请更改此定义(使用字节代替单词):

存储/检索此内存时,使用
AL
代替
AX

mov vct[si], AL
inc si
而且

superloop: 
mov AL, vct[si]
mov ah, 0Eh
int 10h

你知道
push
pop
是如何工作的吗?
程序中的
pop ax
push cx
都是毫无意义的!
只需将两者都移除。
或者,在
push cx
的情况下,您可以通过添加缺少的
pop cx
来更正代码:

push cx
mov cx, si
mov si, 0
superloop: 
mov AL, vct[si]
mov ah, 0Eh
int 10h
inc si
loop superloop
pop cx               <<<<Add this

您已选择将ASCII零作为退格字符输出。这里更常见的选择是ASCII 32。好的是,您可以使用
mov al',
将其作为空格写入

borrar:
cmp cx, 20
je ingresarNumero
mov ah, 0Eh        ;AL=8 at this point
int 10h
mov al, ' '        <<<< Better choice
int 10h
mov al, 8
int 10h
pop ax             <<<< Remove this entirely
inc cx
dec si
jmp ingresarNumero
跳转到
jmp
指令正下方的位置被认为是糟糕的编程。在这段代码中,如果您没有跳转到Ingrearnumero,您可能会在finIngreso部分失败,如下所示:

enter:
cmp cx, 20
je ingresarNumero
finIngreso:

cmp-al,0Dh
我进入

CMP AL,20h你试过用调试器损坏它吗?非常感谢!我不是8086的粉丝,我很难做这个程序。我没有意识到这些错误,谢谢你,现在我可以继续了!很高兴看到我的答案帮助了你。请考虑通过点击检查标记来接受它。左边。这也会为你赢得一些额外的分数
mov si, 0
mov cx, 20
ingresarNumero:
borrar:
cmp cx, 20
je ingresarNumero
mov ah, 0Eh        ;AL=8 at this point
int 10h
mov al, ' '        <<<< Better choice
int 10h
mov al, 8
int 10h
pop ax             <<<< Remove this entirely
inc cx
dec si
jmp ingresarNumero
enter:
cmp cx, 20
je ingresarNumero
jmp finIngreso

finIngreso:
enter:
cmp cx, 20
je ingresarNumero
finIngreso:
cmp al, 0Dh
je enter 
cmp al, 20h       <<<< Space character
je enter