The use of
to increment the value here is troubling to me, for two reasons.
First, it implies that you don't know the increment operator (or just don't realize that it is a general operator rather than a part of the for() loop's control structure). The ++ operator is such a critical feature in C/C++ that not knowing it is a sign that you really don't understand the language as a whole as well as you think.
Second, I'm not sure just why you are incrementing that address in the first place. You already have the address of the boot map, why do you need to change it to map to a specific element in that map?
Third, since you are using an integer to hold the address rather than a pointer, incrementing the address gives it a value of address+1, but since you are working with a structure already (albeit one passed to you from the assembly code), you would only really need to increment it by address + sizeof(bootmap), if at all. By using a pointer, you could have the compiler do this part for you automatically.
If you had declared the boot_info structure
first, then declared boot_information as a pointer to that type and implicitly cast the address to that type by passing boot_information as the inline assembly parameter, you wouldn't need any of this.
Code: Select all
typedef struct boot_info
{
int a; //First info
int b; //Second info
} BOOT_INFO;
BOOT_INFO* boot_information;
asm("\t movl %%ebx,%0" : "=r"(boot_information)); //get the address from EBX