我正试图拆分一个很大的。ASM文件放入几个外部库中,只留下我的主程序。asm。
这是一个游戏,所以我希望把我的键盘输入代码分割成输入。asm和我的即兴声卡代码转换成音乐。asm等。
mov ax, ((scrWidth*YCoord)+XCoord)
当我将包含这些行的过程移动到外部库中并尝试组装该外部库时,MASM会给出以下错误。
A2032: Illegal use of external
这个错误对我来说确实有意义。由于它们是外部的,汇编程序无法直接知道scrWidth、YCoord或XCoord是什么,因此无法将它们相加或相乘。我想这就是为什么它实际上无法生成obj文件。
为了澄清问题,这里有两个完整的示例文件。
主要。ASM公司
TheStack SEGMENT STACK
DB 64 DUP ('THESTACK')
TheStack ENDS
VarData SEGMENT PUBLIC
PUBLIC const1,const2
const1 EQU 1
const2 EQU 2
VarData ENDS
EXTRN Proc1:PROC
Code SEGMENT PUBLIC
assume cs:Code,ds:VarData
MAIN PROC
START:
mov ax, VarData ;load DS
mov ds, ax
call Proc1 ;call external procedure
mov ah,4ch ;exit to dos
mov al,0
int 21h
Main ENDP
Code ENDS
END Start
VarData SEGMENT PUBLIC
EXTRN const1:ABS,const2:ABS
VarData ENDS
Code SEGMENT PUBLIC
PUBLIC Proc1
assume cs:Code,ds:VarData
Proc1 PROC
mov ax, (const1*const2) ;this generates the error
ret
Proc1 ENDP
Code ENDS
END
我确实尝试了一种解决方法,主要是更改EQU。将ASM导入变量而不是常量,然后将其导入UTIL。ASM作为实际字节。然后从那里我尝试将它们映射回Util中的eq。ASM,但错误是相同的。