Reputation: 309
I am following some tutorials on operating system development and I found an article on the multiboot header. These are some 'magic' values you have to define for it to work with GRUB2. These are the commands:
# Declare constants used for creating a multiboot header.
.set ALIGN, 1<<0 # align loaded modules on page boundaries
.set MEMINFO, 1<<1 # provide memory map
.set FLAGS, ALIGN | MEMINFO # this is the Multiboot 'flag' field
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
Now what I don't understand, and i can't find anywhere, is what the 1<<0 and the 1<<1 do when we .set the align and meminfo.
Thanks in advance!
Upvotes: 3
Views: 4473
Reputation: 58782
Surely if you are interested in operating system development you have already encountered the <<
operator in some other language? It's bitwise shift left. It is just used for defining some constants here, based on bit indices. Supposedly it is more clear than writing .set ALIGN 1
and .set MEMINFO 2
.
You should also learn to read the manuals, or else you won't have much luck with programming.
Upvotes: 3