boot0 step-by-step tutorial: Need comments

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.
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

search for keyboard in that last link
gtsphere

Re:boot0 step-by-step tutorial: Need comments

Post by gtsphere »

okay will do, thanks very much for giving me such a hand! ;D
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

no prob
gtsphere

Re:boot0 step-by-step tutorial: Need comments

Post by gtsphere »

maybe its me, or maybe its because i'm tired, but why would they have the ability to enable an amount of RAM in the keyboard? heh
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

just because of engineering errors and non-scalable designs.

AST said that if humans had been designed by intel, they would have a back-to-primate pin ;)
gtsphere

Re:boot0 step-by-step tutorial: Need comments

Post by gtsphere »

lol

those sites you gave me are really decent, danke again for those
dronkit

Re:boot0 step-by-step tutorial: Need feedback on this

Post by dronkit »

i'm very interested in code optimization.

...anyone... ? ;)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:boot0 step-by-step tutorial: Need comments

Post by Pype.Clicker »

gtsphere wrote: maybe its me, or maybe its because i'm tired, but why would they have the ability to enable an amount of RAM in the keyboard? heh
in fact, it's not in the keyboard: it's in a microcontroller that lies on the motherboard and that can be used to enable/disable some configuration lines (such as #reset, #A20 ...) on the processor, but which is also used to communicate using some serial protocol with your PS/2 keyboard/mouse etc.

That chip does a lot of miscellaneous work ...
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

oh... well, i knew it was in the motherboard. but i thought it was only used as keyboard controller + a20 line
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:boot0 step-by-step tutorial: Need comments

Post by Pype.Clicker »

__
1. \______________________________________________

If you want to use a BPB, your initial jump *must* fit within 3 bytes, which means you'll have to do a double jump if you want to set up CS properly:

Code: Select all

jmp (short) start ;; will be assembled as an offset -> org-independent
nop
oem_vendor: must be at 03, not at 05!
 ...
fileSysType  :  FAT-----
start: jmp far 0x7c0:ready
ready: ;; let's get cracking
__
2. \______________________________________________

your stack setup seems weird to my sense ... why the hell do
you use 0x7bf rather than 0x7c0 ? are you aware this is only
16 bytes lower and that it won't prevent code trashing due to
stack overflow in any kind ? -- hum you seem to move the code.
forget about the overflow stuff ...

---> optimization notes <-----
according to the last documents i've read, xor reg,reg usually
don't pair and introduce more complex dependences due to
flags, etc. using mov reg, byte_constant_0 is usually a better
option.

__
3. \______________________________________________

If i get it correctly, your code could be used from a floppy disk
(as boot sector) as well as on a hard disk (on the MBR ?) where it can extract a list of active partitions and prompt the user for its boot choice (? la Lilo :) ...
Now, if you *do* use it as a MBR, remember that the MBR has no BPB, but instead it has a partition table ...
And if you put your sector as the bootsector of a partition, then it's likely that the system either has a single active partition or that the user has already been prompted for a choice ...

or did i get lost ?...

___
4. \____________________________________________

Maybe it's just due to the large amount of comments, but i
have the feeling that your code will lead to >512b ...
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

Hello, thanks for your comments!

1) nah, i don't want to use a bpb. see that it is commented out. it's just there just to remember what the hell is a bpb ;)

2) i setup the stack like that because i want to ;) Besides, i saved one byte ;) anyway, if cs=07c0 ip=0 and ss=07bf and sp=ffff that sholud give my stack 64k free of use, right?

i use xor reg, reg because it is a 1-byte opcode. what did you read about it? (i've been using this "trick" since my days as a dos programmer)

3) you're right, that code wont fit on a hard disk mbr. i will eventually do an mbr version, this is intended for floppy only, and remember is just something i'm playing with ;)

4) right again, the code is almost 512 bytes. that's why i want to reduce code size. i saw many many source codes doing a lot more of what i do here... so...

thanks again for your comments.

take care
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:boot0 step-by-step tutorial: Need comments

Post by Pype.Clicker »

dronkit wrote:
2) i setup the stack like that because i want to ;) Besides, i saved one byte ;) anyway, if cs=07c0 ip=0 and ss=07bf and sp=ffff that sholud give my stack 64k free of use, right?

take care

Code: Select all

        
       ._7c0:ffff___   linear: 17bff
       |_7bf:ffff___|    linear: 17bef (top of stack)
       |       |          |
       =      v         =
       |_7c0:200__|  7e00
       |  <code>    |
       |_7c0:0____|  7c00
it's unlikely that you could find 64K below your code (at 7c00) as this address is within the first 64K ...
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

ooops... right.

how about setting ss=0 and sp=7c00 ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:boot0 step-by-step tutorial: Need comments

Post by Pype.Clicker »

fine as long as you don't write over the IVT, Bios vars, etc.
you have the whole address space for yourself alone, why not to use ss=9000 & sp=fffe ? at least you're pretty sure it won't hurt .
dronkit

Re:boot0 step-by-step tutorial: Need comments

Post by dronkit »

ok. i'll use absolute address 0x7c00.

thanks. anything else?
Post Reply