Page 1 of 1

stage 2 issue

Posted: Tue Nov 10, 2009 2:09 am
by xixpsychoxix
I was looking through the code for stage2.asm and common.inc from the demos. In common.inc you have the following:

Code: Select all

ImageSize db 0
but in stage2.asm you refer to it in the following way:

Code: Select all

mov dword [ImageSize],ecx
so what im asking is, was ImageSize supposed to be db or dd? Cuz it seems like that could be causing an issue very easily...

Re: stage 2 issue

Posted: Tue Nov 10, 2009 2:32 am
by Mike
Hello,

It is supposed to be a dd for a dword - I apologize for the error and it will be corrected.

Re: stage 2 issue

Posted: Tue Nov 10, 2009 12:35 pm
by xixpsychoxix
yeah i made the change in my own code and i dunno if i was imagining it or not but the program actually seemed to perform a little better, faster and more consistently but like i said my mind could be playin tricks on me...

actually, i just found something else that i wanted to ask about too. in the multiboot structure we define the following:

Code: Select all


at multiboot_info.memoryLo dd 0
at multiboot_info.memoryHi dd 0

but again they are referenced later as:

Code: Select all


call BiosGetMemorySize64MB
cmp ax,-1
je .error

mov word [boot_info+multiboot_info.memoryLo],bx
mov word [boot_info+multiboot_info.memoryHi],ax

now obviously since we are working with 16-bit registers that is why we use word here, but will that cause an error or is this code correct? I dont seem to have problems with memory returns but this just seems odd is all.

Re: stage 2 issue

Posted: Wed Nov 18, 2009 2:49 pm
by Mike
Hello,

The code will not cause any issues so long as the high word is cleared out (a movzx instruction can be used to insure of this.) You can also just use ebx and eax (even from real mode.) to copy a dword instead, however the high words of eax and ebx should be cleared before doing so.

What that code does is assume the high words of memoryLo and memoryHi are 0, and only copies the low word.