86转换为小写总成 [英] x86 convert to lower case assembly

查看:73
本文介绍了86转换为小写总成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此程序在字符指针转换成小写。我使用Visual Studio 2010。

This program is to convert a char pointer into lower case. I'm using Visual Studio 2010.

这是另一个问题,但更简单的阅读,更直接的一点。

This is from another question, but much simpler to read and more direct to the point.

int b_search (char* token)
{
__asm
{
mov eax, 0          ; zero out the result
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指令,在那里我试图改变包含地址令牌到全部小写的寄存器,我不断收到未处理的异常...访问冲突,没有括号什么都没有,我不明白错误,但没有得到小写。任何建议?
这是另外一个问题了一些较大的code的一部分,但我把它弄坏了下来,因为我需要这个解决方案只。

At my OR instruction, where I'm trying to change the register that contains the address to token into all lower case, I keep getting unhandled exception...access violation, and without the brackets nothing, I don't get errors but nothing gets lowercased. Any advice? This is part of some bigger code from another question, but I broke it down because I needed this solution only.

推荐答案

的问题是,OR运算符和许多人一样不允许两个内存或恒定的参数。这意味着:OR操作符只能有下列参数:

The problem is, that the OR operator like many others don't allow two memory or constant parameters. That means: The OR operator can only have following parameters:

OR register, memory
OR register, register
OR register, constant

第二个问题是,该或具有结果存储到寄存器,而不是存储器。
这就是为什么你会得到一个访问冲突,当支架被设置。如果去掉括号,参数都OK,但你不写小写字母记忆,你打算做什么。因此,使用另一个寄存器,复制的信,然后用OR。
例如:

The second problem is, that the OR has to store the result to a register, not to memory. Thats why you get an access violation, when the brackets are set. If you remove the brackets, the parameters are ok, but you don't write your lowercase letter to memory, what you intend to do. So use another register, to copy the letter to, and then use OR. For example:

mov eax, 0          ; zero out the result
mov edi, [token]      ; move the token to search for into EDI 
MOV ecx, 0
LOWERCASE_TOKEN:            ;lowercase the token
MOV ebx, [edi]        ;## Copy the value to another register ##
OR ebx, 20h         ;## and compare now the register and the memory ##    
MOV [edi], ebx      ;##Save back the result ##    
INC ecx    
CMP [edi+ecx],0    
JNZ LOWERCASE_TOKEN    
MOV ecx, 0

这应该工作^^

这篇关于86转换为小写总成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆