Reputation: 336
I'm currently developing a bios bootloader and im newer to assembly ive been reading up on it and I understand how it works but theres some things I dont understand involving the sequence of execution of my assembly code.
So basically how is my subroutine _print being called even though im not calling it. Second how is it allocating the bios magic number if thats all the way at the end of the file even though im not reaching.
I would appreciate any help, Thanks.
[ORG 0000:7C00]
global _start
_print:
mov ah, 0x0e
mov al, '['
int 0x10
mov al, '+'
int 0x10
mov al, '['
int 0x10
ret
_start:
jmp $
times 510 - ($-$$) db 0
dw 0xAA55
Upvotes: 0
Views: 71
Reputation: 58528
Unlike executables run by an operating system, the boot sector doesn't have a way to designate an arbitrary entry point; it always starts at the first instruction. So the _start
label doesn't work as a way to specify where to start. You have to literally put that code first.
Upvotes: 5