大小写转换问题
A 41H 0100 0001B or 0010 0000B 转换为小写
B 42H 0100 0010B
C 43H 0100 0011B
D 44H 0100 0100B
a 61H 0110 0001B and 1101 1111B 转换为大写
b 62H 0110 0010B
c 63H 0110 0011B
d 64H 0110 0100B
方法一:
assume cs:code
data segment
db 'ABcDEF' ; 将ABcDEF全部转换为小写
db 'abCdef' ; 将abCdef全部转换为大写
data ends
stack segment stack
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov bx, 0
mov ax, data
mov es, ax
mov cx, 6
downLetter: mov dl, ds:[bx]
or dl, 00100000B
mov es:[bx], dl
inc bx
loop downLetter
mov cx, 6
mov bx, 6
UpLetter: mov dl, ds:[bx]
and dl, 11011111B
mov es:[bx], dl
inc bx
loop UpLetter
mov ax, 4C00H
int 21H
code ends
end start
方法二:
assume cs:code
data segment
db 'ABcDEF' ;单引号
db 'abCdef'
data ends
stack segment stack
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
stack ends
code segment
start:
mov ax, data
mov ds, ax
mov bx, 0
mov ax, data
mov es, ax
mov cx, 6
setLetter: mov dl, ds:[bx]
or dl, 00100000B
mov es:[bx], dl
mov dl, ds:[bx + 6]
and dl, 11011111B
mov es:[bx + 6], dl
inc bx
loop setLetter
mov ax, 4C00H
int 21H
code ends
end start
代码执行结果:
data 段中每个单词的头一个字母改为大写
assume cs:code, ds:data
data segment
db '1. file '
db '2. edit '
db '3. search '
db '4. view '
db '5. options '
db '6. help '
data ends
code segment
start:
mov ax, data
mov ds, ax
mov es, ax
mov bx, 0
mov si, 3
mov cx, 6
upLetter: mov dl, ds:[bx + si]
and dl, 11011111B
mov es:[bx + si], dl
add bx, 16
loop upLetter
mov ax, 4C00H
int 21
code ends
end start
代码执行结果:
data 段中每个单词都改为大写
assume cs:code, ds:data
data segment
db '1. ibm '
db '2. dec '
db '3. dos '
db '4. vax '
data ends
stack segment
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 32
mov ax, data
mov ds, ax
mov es, ax
mov cx, 4
mov bx, 0
mov si, 3
upLetter: push cx
push si
mov cx, 3
upRow: mov dl, ds:[bx + si]
and dl, 11011111B
mov es:[bx + si], dl
inc si
loop upRow
pop si
pop cx
add bx, 16
loop upLetter
mov ax, 4C00H
int 21
code ends
end start
代码执行结果:
data 段中每个单词前4个字母都改为大写
assume cs:code, ds:data
data segment
db '1. display '
db '2. brows '
db '3. replace '
db '4. modify '
data ends
stack segment
dw 0, 0, 0, 0, 0, 0, 0, 0
dw 0, 0, 0, 0, 0, 0, 0, 0
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 32
mov ax, data
mov ds, ax
mov es, ax
mov cx, 4
mov bx, 0
mov si, 3
upRow: push cx
push si
mov cx, 4
upCol: mov dl, ds:[bx + si]
and dl, 11011111B
mov es:[bx + si], dl
inc si
loop upCol
pop si
pop cx
add bx, 16
loop upRow
mov ax, 4C00H
int 21
code ends
end start
上一篇:汇编语言 字符串的复制
下一篇:汇编语言 在存储单元中显示字符串
推荐阅读最新更新时间:2024-11-03 16:18
设计资源 培训 开发板 精华推荐
- FC-135_PCF85263,PCF85263实时时钟32.768kHz晶振的振荡电路及选型指南
- 【已验证】基于esp-12F的 多功能温湿度计
- 使用 Microchip Technology 的 TC660 的参考设计
- L5980、0.7A降压型开关稳压器评估板
- HC32L110C6PA最小系统
- SY58025U,用于 GB 以太网交换机的时钟多路复用器的评估板
- A000074,带有 PoE 的 Arduino 以太网 Rev3 - 基于 ATmega328 8 位 ATmega AVR MCU 的开发套件
- LTC1775CGN -5V/2.5A 正负转换器的典型应用电路
- 单片机+电机驱动集成
- ADA4000-4ARZ-R7运算放大器建立时间电路的典型应用电路