|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
72-74(直接定址法)
标号a : db 1,2,3,4,5,6,7,8 a表示的是内存单元的地址(只能在代码段使用,不能其他段使用)
标号b后面不加: b dw 0 a就同时描述了内存单元地址和每个单元长度
mov ax,b = mov ax,cs:[8]
mov b,2 = mov word ptr cs:[8],2
mov al,a[si] = mov al,cs:0[si]
如果想在代码段用数据标号访问数据,则需要用伪指令assume将标号和段寄存器联系起来(否则编译器无法确定)
c dw a,b
相当于c dw offset a,offset b
c dd a,b
相当于c dw offset a,seg a,offset b,seg b
- assume cs:code
- code segment
- start:
- mov ax, 0
- mov es, ax
- mov ax, 200h
- mov di, ax
- push cs
- pop ds
- mov ax, offset int7c
- mov si, ax
- mov cx, offset int7cend - offset int7c
- cld
- rep movsb
- cli
- mov ax, 0
- mov ds, ax
- mov bx, 07ch*4
- mov word ptr ds:[bx], 200h
- mov word ptr ds:[bx+2], 0
- sti
- mov ax, 4c00h
- int 21h
- int7c:
- jmp short int7ccode
- table dw sub1-int7c+200h, sub2-int7c+200h
- int7ccode:
- push ax
- push bx
- cmp ah, 1
- ja int7c_ok
- sub bx, bx
- mov bl, ah
- add bx, bx
- push cs
- pop ds
- call word ptr [bx+200h+2]
- int7cok:
- pop bx
- pop ax
- iret
- ; clear screen
- sub1:
- push bx
- push cx
- push es
- mov bx, 0b800h
- mov es, bx
- mov bx, 0
- mov cx, 2000
- sub1s:
- mov byte ptr es:[bx], ' '
- add bx, 2
- loop sub1s
- pop es
- pop cx
- pop bx
- ret
- ; change text color
- sub2:
- push bx
- push cx
- push es
- mov bx, 0b800h
- mov es, bx
- mov bx, 1
- mov cx, 2000
- sub2s:
- and byte ptr es:[bx], 11111000b
- or byte ptr es:[bx], al
- add bx, 2
- loop sub2s
- pop es
- pop cx
- pop bx
- ret
- suberror:
- ret
- int7cend:
- nop
- code ends
- end start
复制代码 |
评分
-
查看全部评分
|