如何解决在x86 MASM Assembly中将字符串转换为小写
所以我必须检查字符串的回文,但是它必须首先将字符串转换为小写,所以我在这部分上很挣扎。在这里,我有代码可以找到字符串的长度,现在我很困惑如何将字符串中的每个字母都转换为小写。我正在考虑遍历字符串并逐个转换每个字母,但实际上不知道转换是如何发生的,谢谢
我的代码:
.686
.model flat
.code
_IsPalindrome PROC ;
push ebp
mov ebp,esp ;stack pointer to ebp
mov ebx,[ebp+8] ; address of first array element
mov eax,0
xor dl,dl ;set dl = 0
lengthloop: ;find the length
cmp [ebx+eax],dl
je FirstLast
inc eax
jmp lengthloop
Lowercase: ;change to lower case
;STUCK AT THIS PART CURRENTLY
FirstLast: ;I'm thinking using this for traversing through the string
mov ecx,0 ;ecx = firt character of the string
dec eax ;subtract one from eax
mov edx,eax ;edx = length of the string
CheckPalindrome: ;Will work on this after the lowercase
AllDone:
pop ebp
ret
_IsPalindrome ENDP
END
这在我的主程序中称为此asm文件
#include <iostream>
using namespace std;
extern"C" {
bool IsPalindrome(char[]);
}
int main()
{
char myString[] = "kayak";
IsPalindrome(myString);
return 0;
}
非常感谢,如果您也能以这种形式提供反馈,那就太好了,它是MASM x86 Intel
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。