x86 convert to lower case assembly

后端 未结 3 2063
孤独总比滥情好
孤独总比滥情好 2020-12-12 08:24

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 mo

3条回答
  •  一个人的身影
    2020-12-12 08:43

    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
    

    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
    

    That should work^^

提交回复
热议问题