细节之转换大小写的底层方法,免判断

先看一下如下case:

‘A’=01000001=41h

‘a’=01100001=61h

‘B’=01000010=42h

‘b’=01100010=62h

可得出以下显而易见的结论:

1.小写=大写+20h

2.大写和小写字母仅第5位不同(从0计数),大写为0,小写为1

另有以下结论

1.and 0清零,or 1置1,and 1不变,or 0不变

2.事实上and和or的效率高于add和sub(未验证,至少高于sub)

由法2,写出如下代码case:

第一行数据转为大写,第二行数据转为小写

这个知识点在编程中实际上是个很小的细节,但在反汇编和调试中则需要快速反应。

顺便记下[bx+idata]的几种形式:

[bx+idata]

[idata+bx]

idata[bx]

[bx].idata        (注意中间有个点)

附上ascii表。。。

Dec Hex Char     Dec Hex Char   Dec Hex Char   Dec Hex Char
0 0 NUL (null) 32 20 SPACE 64 40 @ 96 60 `
1 1 SOH (start of heading) 33 21 ! 65 41 A 97 61 a
2 2 STX (start of text) 34 22 66 42 B 98 62 b
3 3 ETX (end of text) 35 23 # 67 43 C 99 63 c
4 4 EOT (end of transmission) 36 24 $ 68 44 D 100 64 d
5 5 ENQ (enquiry) 37 25 % 69 45 E 101 65 e
6 6 ACK (acknowledge) 38 26 & 70 46 F 102 66 f
7 7 BEL (bell) 39 27 71 47 G 103 67 g
8 8 BS (backspace) 40 28 ( 72 48 H 104 68 h
9 9 TAB (horizontal tab) 41 29 ) 73 49 I 105 69 i
10 A LF (NL line feed, new_line) 42 2A * 74 4A J 106 6A j
11 B VT (vertical tab) 43 2B + 75 4B K 107 6B k
12 C FF (NP form feed, new page) 44 2C , 76 4C L 108 6C l
13 D CR (carriage return) 45 2D - 77 4D M 109 6D m
14 E SO (shift out) 46 2E . 78 4E N 110 6E n
15 F SI (shift in) 47 2F / 79 4F O 111 6F o
16 10 DLE (data link escape) 48 30 0 80 50 P 112 70 p
17 11 DC1 (device control 1) 49 31 1 81 51 Q 113 71 q
18 12 DC2 (device control 2) 50 32 2 82 52 R 114 72 r
19 13 DC3 (device control 3) 51 33 3 83 53 S 115 73 s
20 14 DC4 (device control 4) 52 34 4 84 54 T 116 74 t
21 15 NAK (negative acknowledge) 53 35 5 85 55 U 117 75 u
22 16 SYN (synchronous idle) 54 36 6 86 56 V 118 76 v
23 17 ETB (end of trans. block) 55 37 7 87 57 W 119 77 w
24 18 CAN (cancel) 56 38 8 88 58 X 120 78 x
25 19 EM (end of medium) 57 39 9 89 59 Y 121 79 y
26 1A SUB (substitute) 58 3A : 90 5A Z 122 7A z
27 1B ESC (escape) 59 3B ; 91 5B [ 123 7B {
28 1C FS (file separator) 60 3C < 92 5C 124 7C
29 1D GS (group separator) 61 3D = 93 5D ] 125 7D }
30 1E RS (record separator) 62 3E > 94 5E ^ 126 7E ~
31 1F US (unit separator) 63 3F ? 95 5F _ 127 7F