一个Boot Sector

本文详细介绍了如何使用openwatcom编译boot.asm文件,并提供了boot.asm文件的具体代码示例,包括从MODELSMALL模型到JMP指令的应用,以及PrintStr函数的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用openwatcom编译测试过微笑

boot.asm文件:

            .186
            .MODEL SMALL

            .DATA
            .CODE

            ORG     0

            JMP     Start

hello       DB      'Hello, World', 13, 10, 0

Start:
            MOV     AX, 07C0H
            MOV     DS, AX
            MOV     ES, AX
            CLD
            MOV     SI, OFFSET hello
            CALL    PrintStr

Hang:
            JMP     Hang

PrintStr:
            LODSB
            OR      AL, AL
            JZ      PrintStrEnd
            MOV     AH, 0EH
            MOV     BX, 0007
            INT     10H
            JMP     PrintStr
PrintStrEnd:
            RET

            ORG     510
            DW      0AA55H

            END


Makefile文件:

ASM = wasm
CL = wcl

boot.bin: boot.asm
	$(ASM) boot.asm
	$(CL) boot.obj
	exe2bin boot.exe boot.bin

clean:
	del *.exe
	del *.obj