我正在尝试在64位OS X计算机上使用nasm编译this OS。但是,汇编程序给我的错误似乎来自于它没有意识到这段代码是64位而不是32位的事实。如何在不修改代码的情况下修复此问题?
错误:
$ nasm kernel64.asm -o kernel64.sys
init_64.asm:153: error: symbol `lodsq' redefined
init_net.asm:38: error: symbol `stosq' redefined
init_net.asm:40: error: symbol `stosq' redefined
init_net.asm:42: error: symbol `stosq' redefined
init_net.asm:49: error: symbol `stosq' redefined
init_net.asm:51: error: symbol `stosq' redefined
init_net.asm:53: error: symbol `stosq' redefined
syscalls/string.asm:363: error: parser: instruction expected
syscalls/screen.asm:264: error: symbol `jrcxz' redefined
syscalls/screen.asm:264: error: parser: instruction expected
syscalls/debug.asm:23: error: symbol `pushfq' redefined
syscalls/misc.asm:119: error: symbol `jrcxz' redefined
syscalls/misc.asm:119: error: parser: instruction expected
syscalls/misc.asm:126: error: symbol `jrcxz' redefined
syscalls/misc.asm:126: error: parser: instruction expected
syscalls/misc.asm:132: error: symbol `jrcxz' redefined
syscalls/misc.asm:132: error: parser: instruction expected
syscalls/misc.asm:326: warning: numeric constant 0x23D8AD1401DE7383 does not fit in 32 bits
syscalls/smp.asm:121: error: symbol `stosq' redefined
syscalls/smp.asm:123: error: symbol `stosq' redefined
syscalls/smp.asm:179: error: symbol `lodsq' redefined
syscalls/smp.asm:181: error: symbol `lodsq' redefined
drivers/net/rtl8169.asm:219: error: symbol `stosq' redefined
drivers/net/i8254x.asm:195: error: symbol `stosq' redefined
drivers/net/i8254x.asm:200: error: symbol `stosq' redefined
interrupt.asm:102: error: symbol `iretq' redefined
interrupt.asm:116: error: symbol `iretq' redefined
interrupt.asm:166: error: symbol `iretq' redefined
interrupt.asm:239: error: symbol `iretq' redefined
interrupt.asm:307: error: symbol `iretq' redefined
interrupt.asm:322: error: symbol `iretq' redefined
interrupt.asm:537: error: symbol `lodsq' redefined
cli.asm:22: error: symbol `jrcxz' redefined
cli.asm:22: error: parser: instruction expected
cli.asm:26: error: symbol `jrcxz' redefined
cli.asm:26: error: parser: instruction expected
答案 0 :(得分:1)
我认为您的NASM版本太旧了。 BareMetal OS安装说明页面说使用最新版本的NASM,即2.9.10(现在),而您使用的是0.98.40版本。 NASM手册也说:
NASM 2系列支持x86-64,是自2007年以来的NASM生产版本。
而BareMetal OS installation manual说:
NASM会将程序集源文件编译成可执行的二进制文件。 NASM还用于编译在Assembly中写入的任何应用程序。确保您使用的是最新版本的NASM,因为旧版本无法正常运行。
因此请安装最新版本。