Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this 'hello world' x86 bootloader code written for NASM work without the [BITS 16] and [ORG 0x7C00] directives?

push word 0b800h
pop es
xor di, di
mov [es:di], word 441h
jmp $
times 510 - ($-$$) db 0
db 55h
db 0AAh
like image 280
gazdascheff Avatar asked Dec 29 '22 20:12

gazdascheff


1 Answers

Because you are writing a flat binary without labels. NASM should default to 16-bit. Related to this is the fact that you have no addressing or labels - so no requirement to provide an [ORG ...] directive.

like image 133
IAbstract Avatar answered Dec 31 '22 15:12

IAbstract