gpt4 book ai didi

c - x86 程序集小写未处理异常

转载 作者:行者123 更新时间:2023-11-30 17:59:11 26 4
gpt4 key购买 nike

Possible Duplicate:
x86 convert to lower case assembly

该程序是将二维字符数组转换为小写快速编辑:我正在使用 Visual Studio 2010

int b_search (char list[100][20], int count, char* token)
{
__asm
{
mov eax, 0 ; zero out the result
mov esi, list ; move the list pointer to ESI
mov ebx, count ; move the count into EBX
mov edi, token ; move the token to search for into EDI
MOV ecx, 0

LOWERCASE_TOKEN: ;lowercase the token
OR [edi], 20h
INC ecx
CMP [edi+ecx],0
JNZ LOWERCASE_TOKEN
MOV ecx, 0

在我的 OR 指令中,我试图将包含 token 地址的寄存器更改为全部小写,我不断收到未处理的异常...访问冲突,并且如果没有括号,则没有任何内容会被小写。后来在我的代码中我有

LOWERCASE_ARRAY:        ;for(edi = 0, edi<ebx; edi++), loops through each name
CMP ecx, ebx
JGE COMPARE
INC ecx ;ecx++
MOV edx, 0; ;edx = 0

LOWERCASE_STRING: ;while next char != 0, loop through each byte to convert to lower case
OR [esi+edx],20h ;change to lower case
INC edx
CMP [esi+edx],0 ;if [esi+edx] not zero, loop again
JNZ LOWERCASE_STRING
JMP LOWERCASE_ARRAY ;jump back to start case change of next name

OR那里的指令似乎工作得很好,所以我不知道为什么第一个不起作用。另外,我正在尝试转换几个字符串。

完成一个字符串后,有什么想法我将如何转到下一个字符串(如 list[1][x]list[2][x] 等...)我尝试添加 20 如 [esi+20*ecx+edi]但这行不通。我可以获得有关如何进行的建议吗?

最佳答案

一种可能性:

如果过程b_search的参数存储为寄存器(寄存器调用约定),那么您将覆盖第一个asm行中的list指针,因为eax指向列表数组:

mov eax, 0          ; zero out the result

因为:

mov esi, list       ; move the list pointer to ESI

应转换为:

mov esi, eax

尝试将第一行和第二行交换为:

mov esi, list       ; move the list pointer to ESI
mov eax, 0 ; zero out the result

关于c - x86 程序集小写未处理异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11654423/

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