For example, I have the following code (MikeOS).
jmp short bootloader_start ; Jump past disk description section
nop ; Pad out before disk description
...
...
OEMLabel db "MIKEBOOT" ; Disk label
BytesPerSector dw 512 ; Bytes per sector
SectorsPerCluster db 1 ; Sectors per cluster
ReservedForBoot dw 1 ; Reserved sectors for boot record
NumberOfFats db 2 ; Number of copies of the FAT
bootloader_start:
mov ax, 07C0h ; Set up 4K of stack space above buffer
add ax, 544 ; 8k buffer = 512 paragraphs + 32 paragraphs (loader)
...
...
....
Now, I know that jmp short bootloader_start
means that it jumps past the OEMLabel...
section and jumps to the label.
Since I am new to assembly, I have a couple of questions:
Does assembly allocate memory the moment you write the instructions? For example, in the last couple of lines, the code goes like:
times 510-($-$$) db 0 ; Pad remainder of boot sector with zeros dw 0AA55h ; Boot signature (DO NOT CHANGE!) buffer: ; Disk buffer begins (8k after this, stack starts)
buffer:
allocates memory?In this code block:
cli ; Disable interrupts while changing stack mov ss, ax mov sp, 4096 sti ; Restore interrupts
Why do we clear the Clear the Interrupts? If I am not wrong, this bit of code allocates 4096 bytes of stack.
Finally, after the above block, we have this:
mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax
Why do we do this? In my opinion, this is done to tell the Data Segment start where its origin is?