更灵活的定位内存地址的方法(学习汇编)

1.and指令:逻辑与指令,按位进行与运算。与1不变,与0变0,可将对象相应位设为0。
 
2.or指令:逻辑或指令,按为进行或运算。或1变1,或0变0,可将对象位设为1。
 
3.[BX+idata]的几种表现形式:
mov ax,[200+bx]
mov ax,200[bx]
mov ax,[bx].200
 
4.SI和DI是8086CPU中和Bx功能相似的寄存器,只是不能分成两个8位的寄存器来用。
 
5.[BX+SI]进行内存地址定位的几种形式:
mov ax,[bx][si]
mov ax,[bx+si]
 
6.[BX+SI+idata]进行内存地址定位的几种形式:
mov ax,[bx+200+si]
mov ax,[200+bx+si]
mov ax,200[bx][si]
mov ax,[bx].200[si]
mov ax,[bx][si].200
 
7.一般来说,需要暂存数据,我们都应该使用栈。也可以考虑将需要暂存的数据放到内存单元中。
 
8.使用栈暂存数据的案例:
assume CS:codesg,DS:datasg

datasg SEGMENT
     DB 'ibm               '
     DB 'dec               '
     DB 'dso               '
     DB 'vax               '
datasg ENDS

stacksg SEGMENT
    DW 0,0,0,0,0,0,0,0
stacksg ENDS 

codesg SEGMENT
    start : MOV AX,datasg
                    MOV DS,AX
                    MOV DX,stacksg
                    MOV SS,DX
                    MOV SP,16
                    MOV BX,0
                    MOV CX,4
            s0: PUSH CX
                MOV SI,0
                    MOV CX,3
            s:    MOV AL,[BX+SI]
                    AND AX,11011110b
                    MOV [BX+SI],AL
                    INC SI
                    LOOP s
                    ADD BX,16
                    POP CX
                    INC BX
                    LOOP s0
                    MOV AX,4c00h
                    INT 21h
codesg ends 
end start