flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Simple Booter Questions

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 18:38
A future project of mine is to make a simple booter to run some code, but unfortunately my laptop doesn't have a floppy drive. I have several questions, and I've never worked in anything but 32-bit protected mode but I'll figure it out sooner or later.

1) Will an external floppy drive work for my laptop? (Sony VAIO, NR110E), 1 Gb RAM, 1.43 Ghz dual-core pentium)

2) If so, will any floppy disk work (how do I tell the difference when at store)

3) Will a CD work? And again, how do I know which one to buy?

4) How do I get the code onto the boot sector of what I will use, I've seen "debug" used in Windows but I haven't seen it for anything but HDD.

5) I've seen "Bochs" and "Qemu", are these boot-simulators? (I'll research them both today, check them out).

6) How do I read from a CD ( If I could boot from it) ? I've read threads around here but they didn't help me much.

7) With 32-bit protected mode, will my code that ran under Windows still work fine (of course with major modifications, but the basic instruction syntax)

* This is meant only for personal use, just copy the data to memory and start executing my code (I'll need to get the 32-bit protected working too).

Oh, and one more, Cool Does this look good?
Code:
 use16
org 0x7c00

    xor     ax, ax
    mov     ds, ax
    mov     si, boot_str
    call    prints
    jmp     $

 prints:
    mov     ah, 0x0e
    mov     bh, 0x00
    mov     bl, 0x07
@@: lodsb
    or      al, al
    jz      @f
    int     0x10
    jmp     @b
@@: ret

 boot_str:
    db 'Booting AdvEnSTOS...',13,10,0

 times 510-($-$$) db 0
 dw 0xaa55
    
Post 28 Mar 2008, 18:38
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20338
Location: In your JS exploiting you and your system
revolution 28 Mar 2008, 19:08
AlexP: There is a wealth of info on this very board about bootloaders, booting from floppy, booting from HDD, booting from USB, booting from CD, entering PM, entering FRM etc. All the answers are waiting for you, I encourage you to seek and guarantee you will find it in abundance.
Post 28 Mar 2008, 19:08
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 19:09
if your machine support the boot from usb pens, then, you can use them as floppies. with int13h. or boot from the usb floppy as well.
Post 28 Mar 2008, 19:09
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 19:16
I didn't know that you could have boot code on a flash drive, mine has a FAT file system, that is all I can tell about it. So how do I get the booter onto the base of the drive? And can I use Windows to place files in the root directory?
Post 28 Mar 2008, 19:16
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 19:31
all depends on the code on the bootloader.
if your boot loader support a file system, then, yes, if not, you can use only your stuff to put files on the drive.

the file system have it's root in the boot sector. the first sector of the root is pointed by a dword in the mbr.
then, if your mbr don't have a structure compatible with win$ file systems, it will act as a virus on your drive (cf my stupid manipulation of this night).
Post 28 Mar 2008, 19:31
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 19:43
I will use my own file system, all it will be is a piece of 32-bit code that I would like to execute ( on my spare CPU hours ).

Is it possible to use some sort of Windows tool too wipe the USB drive, write the bootloader to it, and then place binaries onto the USB after the boot code? That would be the preferred method for me, but I do not know of any tool to do it. Does anyone here know one?
Post 28 Mar 2008, 19:43
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 19:59
you can write a tool with windows api to write on sectors.

after, if you use the int13h to read at boot time, i invite you to make it with a lba localisation of sectors.
the idea to optimise the file system function of the geometry is a bullshit as the geometry is variable, and there are less sectors per physical tracks in the center of the drive than on the periphery.
the chs geometry is not the same as the real geometry.

does your file system support files up to 4G sectors? and will it support lfn? and etc... ?

if you want we can start to code it in team. just because alone, it's boring.
Post 28 Mar 2008, 19:59
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 20:09
Quote:
if you want we can start to code it in team. just because alone, it's boring.
Sure, could you join the FASM IRC channel? (FreeNode/#flatassembler) I'm in there every day, all day while I work on my AES project.

[edit]: Which Win32 API would you call to wipe a flash drive? I don't know the structure of one internally, but I could probably find out.
Post 28 Mar 2008, 20:09
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 21:37
i don't code for win.
i don't go to irc, cauz it's not free for windows, then, only this place is available.
Post 28 Mar 2008, 21:37
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 22:02
Does anyone know how to use Bochs under Windows? I don't want to start a new thread just to ask... It never works for me, I can't figure out how to make it load my .bin file.
Post 28 Mar 2008, 22:02
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 22:39
xchat is not free after 30 days of free eval.

for bochs, it's simple, you simply put a times 1474560-($-$$)-512 db 0
at the end of the file.
then compile, and you have a .bin ready to use in bochs.
- 512 for the boot sector at the start of the file in case of redifinition of org.

Code:
org 7c00h
boot sector
rb 510-($-$$)
dw 0aa55h
org xxxx
kernel
times 1474560-($-$$)-512 db 0
    


then:
run bochs
configure bochs : 3 enter
disk options : 10 enter
floppy 1: 1 enter
floppy name = file.bin
floppy type = 1.44M
inserted
save to config.config
run
that's all


if you run xp, you can use virtual pc, it's a bit better..
Post 28 Mar 2008, 22:39
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 22:59
VirtualPC doesn't run on my Vista OS (I got a friendly message when I tried it yesterday), I'll try out that Bochs like it says, and I will post if it works. THanks

[edit]: I love you. (in a manly way) *? Now I can play with it, and figure out what protected mode is Smile. I will most likely need help, please post links to protected mode sources if you have them!
Post 28 Mar 2008, 22:59
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 28 Mar 2008, 23:19
i let you seek.
for exemple, the source for fab
it is a project to boot, and 1 second later, show xhtml

then it can be concidered as an os

the pm switch is from dex.. and it is very powerfull, you can return to rm, rereturn to pm as you want..

not an edit:
did you seek in existing threads? because as stated revolution, there are a lot of examples on this forum. a lot, a lot, alot, a lot .....

this is an edit:
seek in a thread named int 13h, starter was rhyno dagreat. it is full of many little pm switchers.
Post 28 Mar 2008, 23:19
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 28 Mar 2008, 23:32
I've gone through several pages reading all the threads in this section Smile, but I was mostly half-asleep (oxymoron?). So, I'll re-read what I have to. I do have one question, are the parameters for int 0x13 the same for a USB memory read? And I still need to get the thing wiped and written to... I'll find something, but for now I'll try Bochs.
Post 28 Mar 2008, 23:32
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 29 Mar 2008, 00:19
the best it to try.
Post 29 Mar 2008, 00:19
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 29 Mar 2008, 01:24
Why the small font? And I just bought a little USB for me to try with, "Attache PNY, 1 GB". I'll have fun, I just hope that the BIOS is able to boot from it... If anyone has any advice to give WHATSOEVER about using USB for any programming, PLEASE TELL MEEEE!!!!. I should be able to get it working eventually though....

[update]: I'm using "dd" software, I just tested my new USB by doing a full copy of it to my HDD, the program appears to be working and I'll try writing to the boot sector.

[update2]: I copied the boot sector of the USB to a file on my disk, got a nice little hex editor, and found 0x55aa, so I know what I must do.. <triumphant voice>
Post 29 Mar 2008, 01:24
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 29 Mar 2008, 02:57
Okay, I heard that if you write to a USB (raw data copy), then that becomes the size of the USB drive from now on... Source;
http://www.bootdisk.com/pendrive.htm
I think it's only for Windows, so it shouldn't affect me, but if I'm wrong then I'm screwed.
Post 29 Mar 2008, 02:57
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20338
Location: In your JS exploiting you and your system
revolution 29 Mar 2008, 03:06
Looks like you answered all your own questions. Learning is the best way to stay happy.
Post 29 Mar 2008, 03:06
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 29 Mar 2008, 03:24
I just got a BIOS error when trying to boot from my USB bootloader code, it said "No bootable partiton in table". Yes, it's spelled wrong.

1) It's a just-bought USB flash drive, FAT file system (now unusable drive?)

2) The bootloader code is OK, it works on Bochs and only consists of a "jmp $"

3) I used the 'dd' software to write directly to the first 512 bytes of the USB stick, and I double checked by importing the same memory and loading it into a hex viewer, it's fine (with 55aa)

Is this the proper way to write bootloader code to a flash drive? I do not know why the BIOS is giving me that error, or what the error means.

BTW, Windows says it needs to be formatted before using it (of course), but when I check the "properties" tab it shows 0 bytes for everything.
Post 29 Mar 2008, 03:24
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20338
Location: In your JS exploiting you and your system
revolution 29 Mar 2008, 05:53
Your BIOS might be checking for the first 3-byte jump instruction. Try "jmp word $".
Post 29 Mar 2008, 05:53
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.