flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > multi-stage bootloader on vmware workstation... Goto page 1, 2 Next |
Author |
|
revolution 18 Jun 2012, 03:49
Once your boot loader is running you can do whatever you want. There is no requirement to force the 2nd sector to be anything. Your code is executing and the CPU will do whatever you tell it to. If you want to make a file system that writes from the back end of the disk in reverse then you can. If you want to leave the 2nd sector completely unused then you can. If you want to follow the "usual" method of putting a partition table in sector 1 then you can.
|
|||
18 Jun 2012, 03:49 |
|
newport 18 Jun 2012, 08:25
I found this awesome layout and information table describing sectors of floppies and HD's...It has helped me to understand more about disk structure..I thought I'd post the link and hope it helps someone else like it has me...
If anyone has any objections to the table or spots any misinformation - please comment on it...so we all know what is correct. Thanks! Drive offset and Sector Conversions |
|||
18 Jun 2012, 08:25 |
|
revolution 18 Jun 2012, 10:30
(Floppy Diskettes never have a Master Boot Record!) |
|||
18 Jun 2012, 10:30 |
|
newport 18 Jun 2012, 11:04
good looking out revolution!
|
|||
18 Jun 2012, 11:04 |
|
newport 18 Jun 2012, 11:11
I'm still having a problem and I'm sure it's because of my limited knowledge and understanding..
but... I create a bootsector.. which loads fine and displays my message on the screen.... Code: format binary as 'img.flp' ; VMware floppy format use16; mov ax, 7C0h ;0000:7C00 mov ds, ax mov si, msg get_msg:lodsb or al, al jz keys_hang mov ah, 0x0E int 0x10 jmp get_msg keys_hang: xor ax, ax mov ah, 0 int 16h jz hang_end hang_end: ;int 16h int 19h ;just reboots and displays message again ;I believe here the code should transfer to the 2nd stage but am unsure how to implement....without the int 19h of course... msg db 'Welcome to Newbie_OS BootLoader...', 13, 10 db 'A newbie style boot loader...', 13, 10 db ' ', 13, 10, 0 times 510 - ($-$$) db 0 db 0x55 db 0xAA However calling the 2nd file remains a mystery...I've tried several of the examples listed within the boards..however nothing seems to work..guidance please.....? |
|||
18 Jun 2012, 11:11 |
|
revolution 18 Jun 2012, 11:27
newport wrote: However calling the 2nd file remains a mystery... |
|||
18 Jun 2012, 11:27 |
|
BAiC 18 Jun 2012, 13:34
newport: your situation sounds like mine. I also have a background in web development with PHP being one of the last languages I mastered before diving into the deep end of OS development with assembly a couple years ago. I've been developing Mathis with the goal of a scripting language also.
Assembly, x86 in particular, requires every little step of an algorithm to be expressed explicitly. if you want your OS to work on anything more than an emulator (or virtual machine) then you'll need to look beyond the BIOS. I chose to implement my own drivers for disk access as well as my own File System. the latter of which is looking more like SQL than FAT. by the way, VMware supports "*.img" files for the Floppy Image. Stefan |
|||
18 Jun 2012, 13:34 |
|
newport 18 Jun 2012, 23:01
Thanks BAiC ! I was also thinking of my own filesystem and drivers...I guess great minds think alike huh? LOL! Anyways, that definitely is the road I'm wanting to travel, but I've reach a stumbling block of crossing from one section to the other... I'm still working on expanding the bootsector...when I get it done would you mind taking a look at it and try and help me understand where I'm going wrong. I want to try to do it as much as possible to get it work myself, but so far I've failed...I'll post my new code as soon as get time to complete it...Maybe I'll get lucky this time...who knows?
oh, and the .flp i use for vmware...I created a blank floppy(.flp) using vmware and just stuck with that...It never crossed my mind that .img would work as well. Thanks for the info! |
|||
18 Jun 2012, 23:01 |
|
newport 19 Jun 2012, 03:08
Ok guys..I'm bout at my wits end and officially a stroke candidate...
Nearly 24 hours later and I still can not load anything or execute beyond my bootsector...could someone please help me to understand where I am going wrong. This is what I have so far... loadbootsector.asm Code: format binary as 'img.flp' use16 ; boot sector code include 'mbr_s1.asm' ;stage 2 include 'mbr_s2.asm' mbr_s1.asm Code: mov ax, 7C0h ;0000:7C00 mov ds, ax mov si, msg get_msg:lodsb or al, al jz keys_hang mov ah, 0Eh int 10h jmp get_msg keys_hang: xor ax, ax mov ah, 0 ;int 16h jz hang_end hang_end: xor ah, ah ;0200:07C0 mov ah, 02h ;read disk sectors into memory mov al, 1 ;number of sectors to read/write mov ch, 0 ;cylinder number mov cl, 2 ;sector number mov dh, 0 ;head number mov dl, 0 ;drive number mov bx, 27C0h mov es, bx ;points to the data buffer int 13h jmp 27C0h msg db 'Welcome to My_OS BootLoader...', 13, 10 db 'A newbie style boot loader...', 13, 10 db ' ', 13, 10, 0 times 510 - ($-$$) db 0 db 0x55 db 0xAA mbr_s2.asm Code: org 27C0h mov si, stage2msg ld_msg: lodsb or al, al jz inf_lp mov ah, 0Eh int 10h jmp ld_msg inf_lp: jmp inf_lp stage2msg db 'Second Stage following boot sector....', 13, 10, 0 times 512 - ($-$$) db 0 |
|||
19 Jun 2012, 03:08 |
|
revolution 19 Jun 2012, 05:52
Do you understand how the segmentation works?
ES:BX in your example points to: 0x27c0:0x27c0 ---> linear address of 0x27c00 (ES*0x10) + 0x27c0 (BX) = 0x2a3c0 |
|||
19 Jun 2012, 05:52 |
|
newport 19 Jun 2012, 05:59
not entirely, but that particular address was just one that I tried. I originally had 0800h but that didn't work either. However when I replaced it with 7C0h as in the boot sector, it worked just now, so that gets me to wondering that before I can jump to the second stage, I need to relocate the boot sector in memory. Is this correct? or am I way off in left field. To be honest, i've been reading about segments and such and at this point am totally confused. Thanks for wanting to help!
Isn't it like [segment * 16] + offset = memory address? |
|||
19 Jun 2012, 05:59 |
|
revolution 19 Jun 2012, 06:02
The BIOS will load your 2nd sector to address 0x2a3c0 because you have set ES and BX to point to there. But you jump to address 0x027c0 where there will be random data in memory.
|
|||
19 Jun 2012, 06:02 |
|
newport 19 Jun 2012, 06:13
revolution wrote: The BIOS will load your 2nd sector to address 0x2a3c0 because you have set ES and BX to point to there. But you jump to address 0x027c0 where there will be random data in memory. so es:bx should point to the memory address but I need to jump to the linear address? correct? while I'm here.. could 27C0h also be written as... 0027h:00C0h ??? I was trying to understand that book I got Assembly Step by Step but it just aint happnin...but if I'm correct in understanding what you are saying then yet another light has come on... |
|||
19 Jun 2012, 06:13 |
|
revolution 19 Jun 2012, 06:20
Your jump address is affected by the CS segment register. After the BIOS jumps to your code CS==0x0000.
0x27c0 can be addressed in many ways. Here are some: 0x0000:0x27c0 0x0200:0x07c0 0x0070:0x20c0 0x0270:0x00c0 0x027c:0x0000 But not 0x0027:0x00c0 |
|||
19 Jun 2012, 06:20 |
|
newport 19 Jun 2012, 06:26
thanks for the patience revolution...
so i just tried substituting what you had stated prior and I get a value out of range error.... it's a little confusing cause if bios loads the boot sector at 7C0h, this should in all rights be the first sector, however it isn't is it...it's like way on down the line... so how would I do the formula in reverse order..say I wanted to jump to 100h for the second stage...? |
|||
19 Jun 2012, 06:26 |
|
BAiC 19 Jun 2012, 06:28
if I may suggest something; why don't you place the second sector immediately after the first one?
edit: at 0x7E00, I mean.. (es=0, bx=0x7E00) |
|||
19 Jun 2012, 06:28 |
|
newport 19 Jun 2012, 06:30
BAiC wrote: if I may suggest something; why don't you place the second sector immediately after the first one? so that would be 7E0h correct? sorry I didn't see where you had the edit... |
|||
19 Jun 2012, 06:30 |
|
BAiC 19 Jun 2012, 06:34
Code: xor ax, ax mov es, ax mov bx, 0x7E00 or Code: mov ax, 0x7E0 mov es, ax xor bx, bx |
|||
19 Jun 2012, 06:34 |
|
newport 19 Jun 2012, 06:41
sorry guys..I feel like such a dumbass...it ain't working...the cpu freezes before going to second stage....
|
|||
19 Jun 2012, 06:41 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.