gpt4 book ai didi

组装-更换外壳

转载 作者:行者123 更新时间:2023-12-02 19:46:00 27 4
gpt4 key购买 nike

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

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

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

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

最佳答案

第一个条件跳转错误!

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

关于组装-更换外壳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29733950/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com