【发布时间】:2018-12-07 06:07:30
【问题描述】:
我正在尝试为我正在开发的操作系统编写引导加载程序。
第一行出现语法错误。
这是我的汇编代码:
.286 ; CPU Type
.model TINY ; memory of model
;---------------------- EXTERNS -----------------------------
extrn _BootMain:near ; prototype of C func
;------------------------------------------------------------
;------------------------------------------------------------
.code
org 07c00h ; for BootSector
_main:
jmp short _start ; go to main
nop
;----------------------- CODE SEGMENT -----------------------
_start:
cli
mov ax,cs ; Setup segment registers
mov ds,ax ; Make DS correct
mov es,ax ; Make ES correct
mov ss,ax ; Make SS correct
mov bp,7c00h
mov sp,7c00h ; Setup a stack
sti
; start the program
call _BootMain
ret
END _start
END _main ; End of program
这是我的编译行:
"*location*\14.10.25017\bin\HostX86\x86\ML.EXE" /c StartPoint.asm
我得到的错误:
StartPoint.asm(1):错误 A2008:语法错误:.
据我所知,这条线应该没有问题。
感谢您的帮助:)
【问题讨论】:
-
.286不是根据msdn 的有效指令。删掉就好了。 -
您可能希望考虑使用旧版本的 MASM 或 TASM 来组装 16 位代码和 16 位链接器。我也希望您不要尝试调用 32 位代码。
-
或者使用 NASM,它仍然可以很好地组装 16 位代码,AFAIK。 (但使用不同的 intel 语法变体,请参阅 stackoverflow.com/tags/intel-syntax/info。
-
删除该行导致另一个错误:/assembly-fatal-error-lnk1190-invalid-fixup-found-type-0x0001。我最终使用了@Michael Petch 解决方案,下载了旧版本的 MASM,并且成功了。感谢您的快速回复。