汇编 字母大小写问题
从ASCII码的二进制形式来看,除第5位(位数从0开始计算)外,大写字母和小写字母的其他各位都一样。
大写字母ASCII码的第5位为0,小写字母的第5位为1;
这样就可以使用汇编中的and、or指令来处理大小写字母;
and指令:通过该指令可将操作对象的相应位设为0,其他位不变;
例子:and al,11011111b(使第5位变为0 ,其他位不变)
or指令:通过该指令可将操作对象的相应位设为1,其他位不变;
例子:or al,00100000(使第5位变为1,其他位不变)
-----------
具体代码:
assume cs:codesg,ds:datasg datasg segment db 'BaSiC' db 'iNfOrMaTiOn' datasg ends codesg segment start: mov ax,datasg mov ds,ax mov bx,0 mov cx,5 s: mov al,[bx] and al,11011111B mov [bx],al inc bx loop s mov bx,5 mov cx,11 s0: mov al,[bx] or al,00100000B mov [bx],al inc bx loop s0 mov ax,4c00h int 21h codesg ends end start

浙公网安备 33010602011771号