将datasg中的第一个字符串转化为大写,第二个字符串转化为小写。

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        

 如果两个字符串的长度一致,程序可以使用[bx+idata]的方式优化如下:

assume cs:codesg,ds:datasg

datasg segment
      db   'BaSiC'
      db   'MinIX'
datasg ends

codesg segment

start:
              mov ax,datasg
              mov ds,ax

              mov bx,0

              mov cx,5

s:
              mov al, 0[bx]
              and al,11011111b
              mov 0[bx],al
mov al,5[bx]
or al,00100000b mov 5[bx],al inc bx loop s mov ax,4c00h int 21h codesg ends end start

 

posted on 2018-11-06 16:25  迷心迷  阅读(150)  评论(0编辑  收藏  举报