flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Help to start my own OS

Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 31 May 2010, 20:26
ORG is just a reference to help me to point labels to correct position?

E.g.: if a binary file (.bin) must be loaded at address 900h, there is nothing inside the code to tell the labels to point to that place. So we use ORG to do that, right?

If i omit ORG the code will know where labels are in, in other words, ORG is only a helper to the programmer? to the code it seems mean nothing.
Post 31 May 2010, 20:26
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 31 May 2010, 20:47
indeed, if there is no ORG, labels will assume start at position 0. And in the case of a .com file, there is nothing at position 0 bc it start at 100h. So that will give error when the code try to access address 0. Very HappyVery HappyVery Happy I GOT IT!!! woohoo!

Thanks for the patience guys Very Happy
Post 31 May 2010, 20:47
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 31 May 2010, 23:27
This is my boot:

Code:
org 7C00h          ; bc boot start from 0000:7C00h

    mov ah, 02h         ; read
    mov al, 1           ; sectors count to read
    mov ch, 0           ; track/cylinder 
    mov cl, 2           ; sector
    mov dh, 0           ; head
    mov dl, 0           ; drive ( 0=A:, 1=2nd floppy, 80h=drive 0, 81h=drive 1 )
    mov bx, 0800h       ; ES:BX point to where data will be write
    mov es, bx          
    mov bx, 0000h       ; 0800:0000h ( ES = 0800h, BX = 0000h )
    int 13h             ; disk interrupt

    jmp kernel

    rb 510-($-$$)       ; fill boot sector
    dw 0xAA55           ; BIOS signature end boot    


I chose to change to PM in the kernel (i'll show it later).
A question:
Code:
    mov bx, 0800h       ; ES:BX point to where data will be write
    mov es, bx          
    mov bx, 0000h       ; 0800:0000h ( ES = 0800h, BX = 0000h )    

In this samle it puts data at 0800:0000, why? To which locations can i write the loaded data?

_________________
Sorry if bad english.
Post 31 May 2010, 23:27
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 01 Jun 2010, 05:37
Teehee wrote:
This is my boot:
...
In this samle it puts data at 0800:0000, why?
Are you joking? You don't know why you put data there?

Seriously, RBIL comes with MEMORY.TXT that contains thorough break-down of conventional/upper memory.
Post 01 Jun 2010, 05:37
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Jun 2010, 13:45
my boot file... but i take this sample from the internet.
Post 01 Jun 2010, 13:45
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 01 Jun 2010, 16:07
Teehee,

So, this is how you define "yours"?

Jokes aside, how do you think yourself? There are valuable locations, like 0:34h/0:100h, that you might want to keep intact (unless FDC/ATA/whatever controller programming is done). You can use any byte available (despite some of them are 0FFh forever) for any purpose you want.
Post 01 Jun 2010, 16:07
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 01 Jun 2010, 16:31
Baldr, don't we all ape our predecessors, one way or another, to varying degrees? What's genuinely new under the sun? Wink


Teehee, there are BIOS interrupts available on all modern machines that provide memory maps. They allow the OS to know how much physical memory is present and which parts are used by what. Some memory addresses are reserved for hardware and ACPI and should never be used.
In general you place the kernel relatively low, e.g. around 1MB or below.
Post 01 Jun 2010, 16:31
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 01 Jun 2010, 21:54
Although BIOS E820 memmap is useful it won't tell you about the IVT, BDA, ROM or screen buffer.

Basically, 0x00600 to 0x07C00 is free (about 30kB), so is 0x07E00 to 0x9FC00 (over 0.5MB). The kernel/loader stage need to be on a 4kB boundary if you're using paging or booting multiprocessors and so either 0x1000 or 0x8000 are a 'good' place but the last one allows plenty of space to grow into Smile However, you can choose anywhere in memory you please according to these constraints.
Post 01 Jun 2010, 21:54
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 19 Feb 2011, 13:28
Im so frustrated Sad
I took about 6 months without touch an asm code and i forgot almost everything.

now i need to read about boot sector, a20, GDT, etc. again *ahem*

_________________
Sorry if bad english.
Post 19 Feb 2011, 13:28
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 19 Feb 2011, 15:12
there is a way to boot without use INT's instructions?
Post 19 Feb 2011, 15:12
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 19 Feb 2011, 19:57
Of course, if you want to write your own drivers for everything you want to use.
Post 19 Feb 2011, 19:57
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 19 Feb 2011, 20:02
how can i learn that, Tyler?
Post 19 Feb 2011, 20:02
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 19 Feb 2011, 22:00
For each device you want to support, you'll want a specification/reference manual (you might also be able to find some examples) e.g. if you want to boot a floppy disk, you'll need a floppy disk controller driver or for CD an ATA/ATAPI driver and so on.

In all cases, you're replacing INT calls with device-defined memory region read/writes (MMIO) using MOV and/or device-defined IO port IN/OUT's.
Post 19 Feb 2011, 22:00
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 20 Feb 2011, 16:59
i don't know how to do that (using IN/OUT's) Sad

---------

here says:

Quote:

Flat Setup
You want to have full 4 GiB addresses untranslated: just use
Code:
GDT[0] = {.base=0, .limit=0, .type=0};                     // Selector 0x00 cannot be used
GDT[1] = {.base=0, .limit=0xffffffff, .type=0x9A};         // Selector 0x08 will be our code
GDT[2] = {.base=0, .limit=0xffffffff, .type=0x92};         // Selector 0x10 will be our data
GDT[3] = {.base=&myTss, .limit=sizeof(myTss), .type=0x89}; // You can use LTR(0x18)    

Note that in this model, code is not actually protected against overwriting since code and data segment overlaps.


1. where they are overlaps? its bc both start (.base) at 0 and have the same limit?
2. how do i know the types availabled?
3. how is the asm version of that?

_________________
Sorry if bad english.
Post 20 Feb 2011, 16:59
View user's profile Send private message Reply with quote
dosin



Joined: 24 Aug 2007
Posts: 337
dosin 20 Feb 2011, 17:57
Post 20 Feb 2011, 17:57
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 20 Feb 2011, 19:32
I'm reading, thanks.

Look at this img:

Image

1. I use the same value in the field [Base 31:24] and [Base 23:16]?

_________________
Sorry if bad english.
Post 20 Feb 2011, 19:32
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 20 Feb 2011, 20:27
base 31:24 means: bits 24 to 31 of base.
base 23:16 means: bits 23 to 16 of base.
to concatenate with base 0:15 to obtain the full 32 bits value base.
base 31:24 23:16 15,0 => base 31:0
Post 20 Feb 2011, 20:27
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 20 Feb 2011, 20:33
wow.. they like to complicate...
Post 20 Feb 2011, 20:33
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 20 Feb 2011, 20:37
so the same for Segment Limit 15:00 and Seg.Limit 19:16 ?

edit: ok i saw the answer is yes. Embarassed


Last edited by Teehee on 20 Feb 2011, 21:01; edited 1 time in total
Post 20 Feb 2011, 20:37
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 20 Feb 2011, 20:53
After read that all, this is how my GDT looks like for awhile:
Code:
gdt:
   dd base_first_entry
 dw limit_gdt_size - 1
base_first_entry:
      dq 0 ; 0x00 null descriptor
 ;  (  limit  ) (     base     ) (P,DPL,DT,Type)(G,DB,0,AVL,limit)(base)
     db 0xFF, 0xFF, 0x00, 0x00, 0x00,  1001'1111b,     1100'1111b,     0x00 ; 0x08 CS
  db 0xFF, 0xFF, 0x00, 0x00, 0x00,  1001'0111b,     1100'1111b,     0x00 ; 0x10 DS
limit_gdt_size = $ - gdt
    

Is everything right?

_________________
Sorry if bad english.
Post 20 Feb 2011, 20:53
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4, 5, 6, 7  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.