Explanation required for Linux source code [setup.s]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
osdevkid
Member
Member
Posts: 72
Joined: Sun Nov 21, 2010 11:15 am
Location: India, Chennai

Explanation required for Linux source code [setup.s]

Post by osdevkid »

Dear All,

I have attached a linux boot sector file [bootsect.s]

I have read the code several times, but few lines I cant able to understand, can you please help me ?

Line numbers from 172 to 174.
Attachments
cp.zip
(14.21 KiB) Downloaded 65 times
Last edited by osdevkid on Wed Mar 16, 2011 7:29 am, edited 6 times in total.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Explanation required for Linux source code [setup.s]

Post by Tosi »

Shifting an unsigned value left by 9 effectively multiplies it by 2^9, which is 512, the size of a sector. So it is converting a number of sectors into the size of those sectors in bytes, and adding bx, which is explained above as "bx is starting address within segment".
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Explanation required for Linux source code [setup.s]

Post by Combuster »

Its a left shift by 9 bits, in other words, a multiplication by 512. In this case it looks like they are converting sectors to bytes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
osdevkid
Member
Member
Posts: 72
Joined: Sun Nov 21, 2010 11:15 am
Location: India, Chennai

Re: Explanation required for Linux source code [setup.s]

Post by osdevkid »

Oh god, how simple it is, I cant able to get it.

Thank you very much for Tosi and Cumbuster.
Post Reply