I was wondering how NASM works with this piece of code:
Just let you know that it is loaded at 0x1000 by a bootloader, and the bootloader goes into protected mode (setup GDT with segments covering whole memory, setup segment registers...) before jumping to 0x1000 (this piece of code):
[bits 32]
[org 0x0]
jmp test
loop:
jmp loop
test:
mov byte [0xB8000], 'H'
mov byte [0xB8001], 0x57
end:
jmp end
When I compile this code in a separate file, how NASM knows the address of test label in memory to jump (it should be 0x1000 + difference in file)? Because it works but I don't understand how.