X86 NASM Assembly converting lower to upper and upper to lowercase characters

后端 未结 5 1465
失恋的感觉
失恋的感觉 2020-12-20 06:02

As i am pretty new to assembly, i have a few questions in regards to how i should convert from a lowercase to an uppercase if the user enters an uppercase letter or vice ver

5条回答
  •  無奈伤痛
    2020-12-20 06:24

    Cute trick: if they type only letters, you can XOR their input letters with 0x20 to swap their case.

    Then, if they can type more than letters, you just have to check each letter to see if it is alphabetical before XORing it. You can do that with a test to see if it lies in the ranges 'a' to 'z' or 'A' to 'Z', for example.

    Alternately, you can just map each letter through a 256-element table which maps the characters the way you want them (this is usually how functions like toupper are implemented, for example).

提交回复
热议问题