组装 - 改变案例

Assembly - changing case

我正在用 AT&T 语法写作。 这个循环应该检查大小写是否在 61-7A ASCII 范围内(这意味着是这个小字母) - 如果不是,则将其转换为 space ' '.

change:
    movb (%esi), %bh        #move case temporary to bh register
    cmp [=10=]x61,%bh           #compare 'a' ASCII and case from bh register
    jge nothing             #if ascii from bh is greater than 'a', jump to nothing
    cmp [=10=]x7A,%bh
    jle nothing             #same, if is in range 61-7A jump to nothing
    movb [=10=]x20,%bh          #if wasn't in range, change to 20 ASCII (space)
nothing:
    movb %bh, (%esi)        #put case back into string
    addl ,%esi            #move pointer to the next case
    loop change

这是我的循环。 ESI 是我指向字符串的指针。

我的问题很简单 - 这不起作用,我不知道为什么。

第一个条件跳转错误!

change:
    movb (%esi), %bh        #move case temporary to bh register
    cmp [=10=]x61,%bh           #compare 'a' ASCII and case from bh register
    jl space             #if ascii from bh is greater than 'a', jump to nothing
    cmp [=10=]x7A,%bh
    jle nothing             #same, if is in range 61-7A jump to nothing
space: 
   movb [=10=]x20,%bh          #if wasn't in range, change to 20 ASCII (space)
nothing:
    movb %bh, (%esi)        #put case back into string
    addl ,%esi            #move pointer to the next case
    loop change