문제

I am beginning some experimentation in writing a kernel and having fun doing it. I have the basic boot-loader done and the following directives:

[BITS 16]
[ORG 0x0000]

In the kernel tutorial, however, it starts with:

[ORG 0x0000]
[BITS 16]

I was wondering if the order in which these directives are given makes a difference? I am using NASM version 2.06rc2, OpenSUSE 11.2

도움이 되었습니까?

해결책

The latest NASM is at version 2.08, and judging by the documentation on the BITS directive..

The order should not make a difference since they tell NASM to generate a file with certain conditions, such as using 16 bits and addressing start at zero. From it, NASM seems to be smart enough to know what kind of output it will generate.

다른 팁

It doesn't matter which one comes first, but I generally follow this order in my programs:

        cpu 8086
        bits 16
        org 256

(Because bits 16 is the default for NASM's bin output format I generally do not specify it explicitly, except when there are some bits 32 parts to a file.)

By the way, the forms with brackets are the lower-level, non-"user" forms of these directives. https://www.nasm.us/xdoc/2.14.02/html/nasmdoc6.html#section-6.1

The BITS directive has an exactly equivalent primitive form, [BITS 16], [BITS 32] and [BITS 64]. The user-level form is a macro which has no function other than to call the primitive form.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top