gpt4 book ai didi

c - 在 Assembly x86 中遍历二维数组

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

Possible Duplicate:
x86 convert to lower case assembly

在我的问题中,我有一个二维字符数组,我需要将所有内容更改为小写。

char list[100][20] = {{"ArtUro"}, {"Bryan"}, {"chris"}, {"David"}, {"Jon"}, {"Mark"}, {"shane"}, {"SIMON"}, {"Thomas"}, {"TONY"}};

我有

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_ARRAY: ;for(ecx = 0, ecx<ebx; ecx++), loops through each name
CMP ecx, ebx
JGE GET_OUT
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

GET_OUT:

我成功地将 ArtUro 转换为小写,但我无法弄清楚如何将数组遍历到 Bryan 的地址,因为我无法按 20 缩放,并且添加 20 导致我的 ESI到另一个地方。

最佳答案

    LEA esi, [esi+20]       

我把它放在第二个循环中的两个跳转指令之间。感谢那些阅读我的问题的人。

关于c - 在 Assembly x86 中遍历二维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11660291/

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