stage 2 issue

If you are new to development, plan on spending some time here before visiting the other forums.

Moderator: Moderators

stage 2 issue

Postby xixpsychoxix » Tue Nov 10, 2009 2:09 am

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...
xixpsychoxix
 
Posts: 59
Joined: Tue Oct 13, 2009 8:49 pm

Re: stage 2 issue

Postby Mike » Tue Nov 10, 2009 2:32 am

Hello,

It is supposed to be a dd for a dword - I apologize for the error and it will be corrected.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com
User avatar
Mike
Site Admin
 
Posts: 463
Joined: Sat Oct 20, 2007 7:58 pm

Re: stage 2 issue

Postby xixpsychoxix » Tue Nov 10, 2009 12:35 pm

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.
xixpsychoxix
 
Posts: 59
Joined: Tue Oct 13, 2009 8:49 pm

Re: stage 2 issue

Postby Mike » Wed Nov 18, 2009 2:49 pm

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.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com
User avatar
Mike
Site Admin
 
Posts: 463
Joined: Sat Oct 20, 2007 7:58 pm


Return to Beginners

Who is online

Users browsing this forum: No registered users and 0 guests

cron