0.首先了解程序段前缀psp
https://editor.csdn.net/md/?articleId=130749208
1. 字母转换ASCII码
规律1:大写字母 + 20H = 小写字母
规律2:大写字母二进制第6位为0,对应的小写字母二进制第6位为1,其他位相同
2.大小写转换问题
3.思路
4.代码
p8.asm
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 ;数据段的偏移地址
;第一个字符串:小写字母转换为大写字母
;a 0110 0001 小写
;and(dfH) 1101 1111 规律:x&0=0(与零变零) x&1=x(与一不变)
;A 0100 0001 大写
mov cx,5 ;循环次数
s:mov al,[bx]
;and al,0dfH ;直接数不能以字母开头,最前面加上数字0。结尾h代表十六进制数
and al,11011111b ;结尾b代表二进制数
mov [bx],al
inc bx
loop s
;第二个字符串:大写字母转换为小写字母
;A 0100 0001 大写
;or(20H) 0010 0000 规律:x|0=x(或零不变) x|1=1(或一变一)
;a 0110 0001 小写
mov cx,11 ;循环次数
s0:mov al,[bx]
;or al,20H
or al,00100000b
mov [bx],al
inc bx
loop s0
mov ax,4c00h
int 21h
codesg ends
end start