flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Int 13h?

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
[quote="rhyno_dagreat"]All it does is set up the offset of the segment address to 600h of certain variables so that they'll be added to whatever is in that ORG statement?|/quote]

not the offset of the segment
the offset inside the segment
segment is a memory zone
virtually this zone begins at zero
and end at the highest possible address

inside the segment all offset are zero based
not segment based

outside the segment you add the effective address of the begin of the segment with the offset

read with more care the intel documents
and make some drawing on paper
it helps to understand
Post 27 Oct 2007, 18:46
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
[quote="edfed"]
rhyno_dagreat wrote:
All it does is set up the offset of the segment address to 600h of certain variables so that they'll be added to whatever is in that ORG statement?|/quote]

not the offset of the segment
the offset inside the segment
segment is a memory zone
virtually this zone begins at zero
and end at the highest possible address

inside the segment all offset are zero based
not segment based

outside the segment you add the effective address of the begin of the segment with the offset

read with more care the intel documents
and make some drawing on paper
it helps to understand


I've had some bad experiences with trying to find info in the Intel documents myself - to be perfectly honest, mainly I'm not sure half the time where to begin because there are at least 4 different PDF files for the documents.

And also I meant offset from the beginning of the segment. I'm thinking back to Starman's site which had an explaination of it:

http://mirror.href.com/thestarman/asm/debug/Segments.html
Post 27 Oct 2007, 18:54
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
In pmode you normal have one 4GB address space, that starts at 0, now when you set your GDT up, if you set your descriptor to 0 base (most codes do), than ds or es etc, add nothing to the address.
So has long as you have zero based code and data descriptor, you can think of address, as whats in say edi, in this example
Code:
mov  edi,10mov  [es:edi],4 ; move 4 into the address 10    


Once your in pmode you need to think in teams, of one long continues address space. All ORG does is add that number, to all memory reference in your code.
So say in your code there was a
Code:
MyVar dd 0    

At 12 bytes from start of your program and your ORG was "org 0x0000", then that would 12bytes, But if you had a "org 0x100" then the address would be 256 + 12 bytes.
Post 27 Oct 2007, 19:53
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
I think I'm getting it now. Thanks!
Post 28 Oct 2007, 01:21
View user's profile Send private message Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
rhyno_dagreat wrote:
Quote:

Thanks Mac! Though it's not so much the real mode I'm having the problem with as it is the PMode.


I use similar boot loader in own protected mode projects. I switch to PM right after the boot loader has finished it's job. I hope my code can help you a bit. Smile

regards,
Mac2004


Last edited by Mac2004 on 29 Oct 2007, 20:00; edited 1 time in total
Post 28 Oct 2007, 07:36
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Mac2004 wrote:
rhyno_dagreat wrote:
Quote:

Thanks Mac! Though it's not so much the real mode I'm having the problem with as it is the PMode.


I use similar boot loader in own protected mode projects. I switch to PM right after the boot loader has finished it's job. I hope my code can you a bit. Smile

regards,
Mac2004

It has! In fact, I think I'm the person you wrote that code for originally a while back, lol.
Post 29 Oct 2007, 04:57
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
it really helped
but now my code is far to be like the basic exemple

Wink
Post 29 Oct 2007, 12:29
View user's profile Send private message Visit poster's website Reply with quote
Mac2004



Joined: 15 Dec 2003
Posts: 313
Mac2004
rhyno_dagreat wrote:
Quote:

It has! In fact, I think I'm the person you wrote that code for originally a while back, lol.



That's why I decided to publish the loader example in the first place. I wanted to help others to pass the first hurdle .... Smile

regards,
Mac2004
Post 29 Oct 2007, 20:03
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
i think this is the code writen by the designers of the µP Wink

the gdt and the pm switch is hardware
what about a pm int 13h
Post 12 Nov 2007, 20:21
View user's profile Send private message Visit poster's website Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta
[ Post removed by author. ]


Last edited by mikegonta on 27 Jan 2009, 22:26; edited 1 time in total
Post 12 Nov 2007, 22:24
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
i speak about a simple manner to handle int and irq in pm

not a switch to rm and a call of the desired int

i seek, i seek
i'll find how to control all the machine
Post 13 Nov 2007, 01:17
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
hi rhyno!
here is the best place to speak about the os project.
better than DOS/3D thread.

sure it needs to provide install option.
but before this, it needs to work.
and possess a file system, a text editor, a fasm version, and other stuff...
the fact that current os exist is good for us.
we don't have to make all since the beginning.
we can read many documents.
wa can quote/read on the board.flatassembler.
we can use fasmw to develop our os.
so let's go
contact me by PrivateMessage
after we'll open a private channel.
Post 28 Nov 2007, 01:47
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
secteur de boot archi simple.
Code:
use16
        org 7c00h
        push cs
        pop ds
        mov ax,1000h
        mov es,ax
        mov bx,7C00h
        mov ax,0201h
        mov dx,0
        mov cx,1
        int 13h
        jmp far 1000h:there
there:
        push cs
        pop ds
        mov ax, 0B800h
        mov es,ax
        mov di,0
        mov si,hello
        mov ah,71h
@@:
        mov al,[si]
        cmp al,0
        je @f
        mov [es:di],ax
        inc si
        inc di
        inc di
        jmp @b
@@:
        xor ax,ax
        mov es,ax
        mov bx,7C00h
        mov ax,0201h
        mov dx,80h
        mov cx,1
        int 13h
        jmp far 0:7C00h

hello db 'hello world',0
free =  510-(padding-$$)
padding rb free
        dw 0aa55h

    



while attempting to read and write to Floppy drives, i saw that the multi sectors int13h is not ok. it don't works good. then, to load the second stage and all files on a floppy, sectors read and writes shall be done one by one.
if not it will not work.

a link to uptade of the INT 13h utilities for DOS

and the source code of the prototype routine of read and write on drives using INT 13h

Code:
; access all disk
db 'disk',0
disk:
.read:
        push es
        mov al,[.sector]
        mov ah,[.head]
        ror eax,16
        mov ax,[.track]
.nextr:
        dec [.sectors]
        jl .endr
        push eax
        mov cx,ax
        mov bl,cl
        mov cl,ch
        mov ch,bl
        shl cl,6
        and cl,0c0h
        ror eax,16
        or cl,al
        mov dh,ah
        mov dl,[.drive]
        mov bx,[.segment]
        mov es,bx
        mov bx,[.offset]
        mov ah,2
        mov al,1
        int 13h
        add [.offset],512
        pop eax
        ror eax,16
        inc al
        cmp al,[sectors0]
        jne @f
        mov al,1
        inc ah
        cmp ah,[heads0]
        jne @f
        mov ah,0
        ror eax,16
        inc ax
        cmp ax,[tracks0]
        jne .nextr
        mov ax,1
@@:
        ror eax,16
        jmp .nextr
.endr:
        pop es
        ret
.write:
        mov bx,[.segment]
        push es
        mov es,bx
        xor bx,bx
        mov al,[.sector]
        mov ah,[.head]
        ror eax,16
        mov ax,[.track]
.nextw:
        dec [.sectors]
        jl .endw
        push eax
        mov cx,ax
        mov bl,cl
        mov cl,ch
        mov ch,bl
        shl cl,6
        and cl,0c0h
        ror eax,16
        or cl,al
        mov dh,ah
        mov dl,[.drive]
        mov ah,3
        mov al,1
        int 13h
        add bx,512
        pop eax
        ror eax,16
        inc al
        cmp al,[sectors0]
        jne @f
        mov al,1
        inc ah
        cmp ah,[heads0]
        jne @f
        mov ah,0
        ror eax,16
        inc ax
        cmp ax,[tracks0]
        jne .nextw
        mov ax,1
@@:
        ror eax,16
        jmp .nextw
.endw:
        pop es
        ret
.id:
        mov ah,0
        mov dl,[disk.drive]
        cmp dl,0
        je .floppy
        int 13h
        jc @f
        mov ah,8
        mov dl,[disk.drive]
        int 13h
        inc dh
        mov [heads0],dh
        mov bx,cx
        and cl,not 0c0h
        mov [sectors0],cl
        mov cl,ch
        mov ch,bl
        shr ch,6
        inc cx
        mov [tracks0],cx
        mov eax,0
        mov al,[sectors0]
        mov ebx,0
        mov bl,[heads0]
        mov ecx,0
        mov cx,[tracks0]
        imul eax,ebx
        imul eax,ecx
        shr eax,1
        mov [kbytes0],eax
        stc
        ret
.floppy:
        mov [tracks0],80
        mov [sectors0],18
        mov [heads0],2
        mov al,[sectors0]
        mov ebx,0
        mov bl,[heads0]
        mov ecx,0
        mov cx,[tracks0]
        imul eax,ebx
        imul eax,ecx
        shr eax,1
        mov [kbytes0],eax
        stc
        ret
@@:
        clc
        ret
.sectors db 128
.sector  db 1
.track   dw 0
.head    db 0
.drive   db 0
.segment dw 0
.offset  dw 0
kbytes0   dd 1
tracks0   dw 1
cnt01     dw 1
sectors0  db 1
heads0    db 1
    


Description: the start of the shell project. will be cleaned up to be FOOL compliant, and easier to code of course.
just somo mods made on an old source. but... backup and sharing!

Download
Filename: shell.zip
Filesize: 26.13 KB
Downloaded: 42 Time(s)

Description: a bootloader able to launch a .com program located at sector n°2 and after, limited to 10 KB load, and reboot from C: when exiting, to use on a floppy.
Download
Filename: comload.zip
Filesize: 2.57 KB
Downloaded: 40 Time(s)

Post 13 Apr 2008, 19:08
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
i tested to access the ide0 master with IO, but nothings happend.

i think i miss something in this code....

boot.asm
Code:
use16
        org 7c00h
        push 1000h
        pop es
        mov bx,7C00h
        mov ax,0201h
        mov cx,1
        int 13h
        jmp far 1000h:@f
@@:
        mov si,boot
        call disk
        jmp far 0:7C00h

boot    dd disk
        db disk.read,0
        dw 1
        dd 1
        dd 0:7c00h

include 'io.asm'


db 'version 1',0
took = padding-$$
free =  510-took
padding rb free
        dw 0aa55h

    

io.asm
Code:

disk:
.call=0    ; function

.cmd=4     ; drive command read or write
.drv=5     ; drive number, BIOS based
.cnt=6     ; count of sectors to read

.lba=8     ; sector location in lba
.off=12    ; offset part of far pointer to mem
.seg=16    ; segment part of  far pointer to mem

.read=20h  ;
.write=30h ;
.ata:

        mov dx,1f6h
        mov al,0          ;Drive 0, chs, h=0
        out dx,al
        mov dx,1f2h
        mov al,1            ;512bytes
        out dx,al
        mov dx,1f3h
        mov al,1            ;S=1
        out dx,al
        mov dx,1f4h
        mov al,0            ;Cl=0
        out dx,al
        mov dx,1f5h         ;Ch=0
        mov al,0
        out dx,al
        mov dx,1f7h
        mov al,[esi+.cmd]
        out dx,al
@@:
        in al,dx
        test al,8
        je @b
        mov cx,256
        mov ax,[esi+.seg]
        mov es,ax
        mov di,[esi+.off]
        mov dx,1f0h
        rep insw
        ret

    


this gives me a strange result in bochs.
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
int13h_cdrom: function 2,ELDL out of range f0
....
Post 13 Sep 2009, 18:25
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 Previous  1, 2, 3

< 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-2020, Tomasz Grysztar.

Powered by rwasa.