我编写了一个引导加载程序,并使用NASM汇编程序(而不是AS86)编译它,一切都很完美。
现在,我想学习如何将16位C代码插入到我的应用程序中。我从几个SOs中读到,由于bcc支持8086处理器,所以推荐在这种情况下使用它。
在将我的代码与C测试代码组合时,我遇到了以下错误:ld86: testasm.o has bad magic number
我将代码简化如下:
testasm.asm
[bits 16]
global foo
foo:
mov ax, 0x0e41
int 0x10
jmp $testc.c
extern void foo();
main() {
foo();
}和Makefile
CFLAGS=-0 -c
LDFLAGS=-T 0x7C00 -0
ASFLAGS=-f aout
all: testc.bin
testc.bin: testasm.o testc.o
ld86 -o $@ $^ $(LDFLAGS)
testc.o: testc.c
bcc -o $@ $^ $(CFLAGS)
testasm.o: testasm.asm
nasm -o $@ $^ $(ASFLAGS)
clean:
rm -f *.o testc.bin我还是有问题的。任何人都知道如何将NASM、bcc和ld86组合在一起。
发布于 2017-05-13 09:00:42
对于新来的人,我发现了问题。为了与NASM兼容,NASM的输出格式应该是AS86。所以,
ASFLAGS=-f aout应改为
ASFLAGS=-f as86此外,代码还有另一个问题:应该用foo替换testasm.asm中的_foo,但不要问我为什么!
https://stackoverflow.com/questions/43951063
复制相似问题