程序集反向字符串有问题(Irvine32)

时间:2019-03-01 23:30:36

标签: assembly x86 visual-studio-2017 irvine32

我的汇编程序在计算大写字母的数量并转换大小写并反转字符串时遇到问题。它不让我输入字符串。请帮助

这是我的数据

.data
    buffer BYTE 128 dup(0)
    msg1 BYTE "Enter a string of at most 128 characters:",0dh, 0ah, 0
    msg2 BYTE "Here it is in lowercase and in reverse order:", 0dh, 0ah, 0
    msg3 BYTE 0dh, 0ah, "there are",0
    msg4 BYTE "lower-case characters ", 0dh, 0ah, 0
    countLower BYTE 0

我的输入区域

.code

    main PROC

    mov ecx, 0
    mov eax, 0
    mov edx, OFFSET msg1
    call WriteString
    call ReadString

比较字符串大小

read_again:
        cmp ecx, 128
        ja endread
        call ReadChar
    cmp al, 0Dh
    je display
    cmp al, 61h
jae test_lower
    cmp al, 41h
    jb store
    cmp al, 5Ah
    ja store
    add al, 20h
    inc countLower
    ja store

测试最后一个字符

test_lower :
    cmp al, 7Ah
    ja store
    sub al, 20h

store:
    push eax
    inc ecx
    jmp read_again
endread:
    lea esi, buffer
    display:
    jecxz quit
    mov edx, OFFSET msg2
    call WriteString
again:
    pop eax
    call WriteChar
    loop again
    mov edx, OFFSET msg3
    call WriteString
    movzx eax,countLower
    call WriteDec
    mov edx, OFFSET msg4
    call WriteString
quit:

0 个答案:

没有答案