assume cs:code, es:data
data segment
a db 1, 2, 3, 4, 5, 6, 7, 8
b dw 0
data ends
code segment
start:
mov al, a[si]
mov ax, 4c00h
int 21h
code ends
end start
D:\Masm615>debug test.exe
-u
0BA9:0000 26 ES:
0BA9:0001 8A840000 MOV AL,[SI+0000]
0BA9:0005 B8004C MOV AX,4C00
0BA9:0008 CD21 INT 21
0BA9:000A 0033 ADD [BP+DI],DH
0BA9:000C C0 DB C0
0BA9:000D 26 ES:
0BA9:000E 8A840000 MOV AL,[SI+0000]
0BA9:0012 26 ES:
0BA9:0013 01060800 ADD [0008],AX
0BA9:0017 46 INC SI
0BA9:0018 E2F3 LOOP 000D
0BA9:001A B8004C MOV AX,4C00
0BA9:001D CD21 INT 21
0BA9:001F 07 POP ES
-
0BA9:0000 26 ES:
0BA9:0001 8A840000 MOV AL,[SI+0000]
可以看到有ES前缀
assume cs:code, es:data
data segment
a db 1, 2, 3, 4, 5, 6, 7, 8
b dw 0
data ends
code segment
start:
mov al, [si]
mov ax, 4c00h
int 21h
code ends
end start
D:\Masm615>debug test.exe
-u
0BA9:0000 8A04 MOV AL,[SI]
0BA9:0002 B8004C MOV AX,4C00
0BA9:0005 CD21 INT 21
0BA9:0007 4C DEC SP
0BA9:0008 CD21 INT 21
0BA9:000A 0033 ADD [BP+DI],DH
0BA9:000C C0 DB C0
0BA9:000D 26 ES:
0BA9:000E 8A840000 MOV AL,[SI+0000]
0BA9:0012 26 ES:
0BA9:0013 01060800 ADD [0008],AX
0BA9:0017 46 INC SI
0BA9:0018 E2F3 LOOP 000D
0BA9:001A B8004C MOV AX,4C00
0BA9:001D CD21 INT 21
0BA9:001F 07 POP ES
没有ES前缀,这说明和si寄存器没有关系
然后我又看到了 assume cs:code, es:data
我猜想是不是和这个有关系?试一试assume cs:code
data segment
a db 1, 2, 3, 4, 5, 6, 7, 8
b dw 0
data ends
code segment
start:
mov al, a[si]
mov ax, 4c00h
int 21h
code ends
end start
D:\Masm615>ml test.asm
Microsoft (R) Macro Assembler Version 6.15.8803
Patched for you by promethee [ECL] in the year 2001 - enjoy
Copyright (C) Microsoft Corp 1981-2000. All rights reserved.
Assembling: test.asm
test.asm(10) : error A2074: cannot access label through segment registers
报错了
cannot access label through segment registers
这是什么意思?
我也不知道,有道翻译一下
无法通过段寄存器访问标签
有 assume cs:code, es:data就能编译
这下就明白了吧
没有assume关联寄存器,编译器不知道该如何访问标签a |