Converting from lower case to upper case

前端 未结 2 1037
傲寒
傲寒 2021-01-06 15:56

I am trying to convert from lower case to upper case. I know it can easily be done by,

SUB AL, 20H

But I am have been given another solutio

2条回答
  •  心在旅途
    2021-01-06 16:41

    Look at the bit patterns:

    • A (0x41): 0100 0001
    • a (0x61): 0110 0001
    • M (0x4d): 0100 1101
    • m (0x6d): 0110 1101
    • Z (0x5a): 0101 1010
    • z (0x7a): 0111 1010

    Lower case ASCII is upper case ASCII + 0x20 (0010 0000) - i.e. the same bit pattern with the sixth bit set.

    0xdf is 1101 1111 in binary. AND:ing AL with that will set the sixth bit to zero but preserve the other bit values.

提交回复
热议问题