x86 convert to lower case assembly

后端 未结 3 2061
孤独总比滥情好
孤独总比滥情好 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:56

    I would load the data into a register, manipulate it there, then store the result back to memory.

    int make_lower(char* token) {
        __asm {
            mov edi, token
            jmp short start_loop
        top_loop:   
            or al, 20h
            mov [edi], al
            inc edi
        start_loop:
            mov al, [edi]
            test al, al
            jnz top_loop
        }       
    }
    

    Note, however, that your conversion to upper-case is somewhat flawed. For example, if the input contains any control characters, it will change them to something else -- but they aren't upper case, and what it converts them to won't be lower case.

提交回复
热议问题