版权声明:本文为 gfson
原创文章,转载请注明出处。
注:作者水平有限,文中如有不恰当之处,请予以指正,万分感谢。
7.1 and 和 or 指令
![](https://img.haomeiwen.com/i5351166/b26c078e58f2eb41.png)
7.2 大小写转换问题
- 字母的大写字符和小写字符对应的 ASCII 码表如下:
![](https://img.haomeiwen.com/i5351166/f180bebe885148fa.png)
-
通过对比,我们发现:
- 小写字母的 ASCII 值比大写字母的 ASCII 值大 20H。
- 大 20H 以二进制的方式体现在第 5 位为 1。
-
所以,可以使用 and 和 or 得到如下结论:
- 大写字母 or 00100000B,将大写字母的第 5 位置为 1,变为小写字母。
- 小写字母 and 11011111B,将小写字母的第 5 位置为 0,变为大写字母。
7.3 SI 和 DI
- si 和 di 不能分成两个八位寄存器使用。
- 其功能与 bx 相近。
![](https://img.haomeiwen.com/i5351166/aeab108f28f8592d.png)
7.4 不同寻址方式的灵活应用
- [idata] 用一个常量来表示地址,可用于直接定位一个内存单元。
- [bx] 用一个变量来表示内存地址,可间接定位一个内存单元。
- [bx+idata] 用一个变量和常量表示地址,可在一个起始地址的基础上用变量间接定位一个内存单元。
- [bx+si] 用两个变量表示地址。
- [bx+si+idata] 用两个变量和一个常量表示地址。
- 一般来说,在需要暂存数据时,我们应该使用栈。
7.5 实验 6
![](https://img.haomeiwen.com/i5351166/1d20c6144941d587.png)
- 答案:
assume cs:codesg,ss:stacksg,ds:datasg
stacksg segment
dw 0,0,0,0,0,0,0,0
stacksg ends
datasg segment
db '1. display '
db '2. brows '
db '3. replace '
db '4. modify '
datasg ends
codesg segment
start:
mov ax,stacksg
mov ss,ax
mov sp,16
mov ax,datasg
mov ds,ax
mov bx,0
mov cx,4
s0:
push cx
mov si,0
mov cx,4
s:
mov al,[bx+si+3]
and al,11011111b
mov [bx+si+3],al
inc si
loop s
add bx,16
pop cx
loop s0
mov ax,4c00h
int 21h
codesg ends
end start
网友评论