汇编_数组的底层使用

采用ds作为数组的头,用bx寄存器来做偏移量,实现将abcd转换为大写,ABCD转换为小写。

assume cs:codesg,ds:data

data segment
    db 'abcd'
    db 'ABCD'
data ends

codesg segment
start:    
    mov ax, data
    mov ds, ax;定义数据段
    mov bx, 0;定义初始偏移量

    mov cx, 4;循环次数
s:  mov al, [bx]
    or al, 20h;转大写
    mov [bx],al

    mov al, [bx+4];也可以写成[4+bx],4[bx],[bx].4
    and al, 0DFh;转小写
    mov [bx+4],al

    add bx, 1;修改数组位置
    loop s

    mov ax, 4c00h
    int 21h
codesg ends
end start

实验结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45931661/article/details/120321428
今日推荐