1

我正在尝试使用以下代码使用 TASM 开发一个简单的内核:

; beroset.asm
;
; This is a primitive operating system.
;
;**********************************************************************
code segment para public use16 '_CODE'
        .386
        assume cs:code, ds:code, es:code, ss:code
        org 0
Start:
        mov     ax,cs
        mov     ds,ax
        mov     es,ax
        mov     si,offset err_msg
        call    DisplayMsg
spin:
        jmp     spin


;****************************************************************************
; DisplayMsg
;
; displays the ASCIIZ message to the screen using int 10h calls
;
; Entry:
;    ds:si ==> ASCII string
;
; Exit:
;
; Destroyed:
;    none
;
;
;****************************************************************************
DisplayMsg proc
        push    ax bx si
        cld
nextchar:
        lodsb
        or      al,al
        jz      alldone
        mov     bx,0007h
        mov     ah,0eh
        int     10h
        jmp     nextchar
alldone:
        pop     si bx ax
        ret
DisplayMsg endp


err_msg db      "Operating system found and loaded.",0

code ends
        END

然后我像这样编译它:

C:\DOCUME~1\Nathan\Desktop> tasm /la /m2 beroset.asm
Turbo Assembler 版本 4.1 版权所有 (c) 1988, 1996 Borland International

汇编文件:beroset.asm
错误消息:无
警告消息:无
通过:2
剩余内存:406k

C:\DOCUME~1\Nathan\Desktop> tlink beroset,loader.bin
Turbo Link 版本 7.1.30.1。版权所有 (c) 1987, 1996 Borland International
致命:无程序入口点

C:\DOCUME~1\Nathan\Desktop>

我能纠正这个错误吗?

4

1 回答 1

2

I would say that you need to end the Start: section by adding end Start at the last line like this:

code ends
end Start

But again in that code you never initialize stack... It will not work, but it sould print "Operating system found and loaded.".

UPDATE: Actually, this did the trick. I just added end Start in place of END and the "No entry point" error was gone. but you get the stack warning.

So there you go. =)

CONCERNING THE STACK: Just add this before everything:

.model  small
.stack 
于 2010-03-27T18:38:01.330 回答