1- 转化为大写
方法一:
assume cs:code,ds:data
data segment
db 'BaSiC'
db 'MinIX'
data ends
code segment
start: mov ax,data
mov ds,ax
mov bx, mov cx,
s: mov al,[bx]
and al,11011111B
mov [bx],al
inc bx
loop s mov cx,
mov bx,
s0: mov al,[bx]
or al,00100000B
mov [bx],al
inc bx
loop s0 mov ax,4c00H
int 21h
code ends
end start
方法二:
assume cs:code,ds:data
data segment
db 'BaSiC'
db 'MinIX'
data ends
code segment
start: mov ax,data
mov ds,ax
mov bx, mov cx,
s: mov al,[bx]
and al,11011111B
mov [bx],al mov al,[ + bx]
or al,00100000B
mov [ + bx],al
inc bx
loop s mov ax,4c00H
int 21h
code ends
end start
方法三:
assume cs:code,ds:data
data segment
db 'BaSiC'
db 'MinIX'
data ends
code segment
start: mov ax,data
mov ds,ax
mov bx, mov cx,
s: mov al,0[bx]
and al,11011111B
mov [bx],al mov al,5[bx]
or al,00100000B
mov [bx],al
inc bx
loop s mov ax,4c00H
int 21h
code ends
end start
C语言编写:
#include <stdio.h> int main()
{
char a[] = "BaSiC";
char b[] = "MinIX"; int i = ;
do
{
a[i] = a[i] & 0xDF; //小->大
b[i] = b[i] | 0x20; //大->小
printf("%c",a[i]);
i++;
}
while (i < ); printf("\n"); for(i = ; i < ; i++)
{ printf("%c",b[i]);
}
printf("\n"); system("PAUSE");
return ;
}
C语言定位方式: a[i], b[i]
汇编语言定位方式: 0[bx], 5[bx]
[bx+idata]的方式为高级语言实现数组提供了便利机制