+.intel_syntax noprefix # instruct GNU assembler that we’ll be using Intel syntax
+ # (e.g. mov ax, 1 instead of movw $1, %ax – some prefer the latter
.code16 # 16 bit code generation
# Since all intel based start up with 16-bit instructions,
# we won't be able to write 32 bit code yet.
+.org 0x0 # the origin of our code will be 0×0,
+ # i.e. all absolute addresses start at 0×0, which will be convenient.
jmp _start_stage1 # this is the main entry point of our code which corresponds to the first byte
nop # of actual output when assembled The code under "_start" simply jumps over the
# - Interrupts may not act now, so they are disabled.
cli # block all maskable interrupts (does not block NMI - non-maskable interrupts)
+ mov ax, cs # CS is set to 0x0, because that is where boot sector is loaded (0:07c00)
+ mov ds, ax # DS = CS = 0x0
+ mov es, ax # ES = CS = 0x0
+ mov ss, ax # SS = CS = 0x0
+ mov sp, 0x7C00 # Stack grows down from offset 0x7C00 toward 0x0000.
.fill (510-(.-main)), 1, 0 # Pad with nulls up to 510 bytes (exclude boot magic)