flat assembler
Message board for the users of flat assembler.

Index > OS Construction > INT 13h....... again!

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 26 Mar 2011, 15:05
Hi everyone,
I cant find what is the problem in my int 13h code(it is a bootloader)
Code:
        ORG 07C00h

        AMOUNTOFMEMSCAN:  ;here i get amount of existing memory
        mov ax, 0E801h
        int 15h
        jc FAIL
        mov ax, bx
        mov bx, 0FFFFh
        mul bx
        mov di, MAXMEMADDR
        mov [cs:di], eax

        READKERN:; that is it, the place where the problem is
        xor dx, dx
        mov di, cs
        mov ds, di
        mov di, DAP
        mov ah, 42h
        xor al, al
        int 13h
        push ax ;it is like tracking of error code for debugger
        jc FAIL



        FINLOOP:
        jmp FINLOOP

        FAIL:
        mov ah, 0Eh
        mov al, 'F'
        int 10h
        mov ah, 0Eh
        mov di, 0810h
        mov ds, di
        xor di, di
        mov al, [ds:di]
        int 10h
        pop ax
        FAILEND:
        jmp FAILEND

        DAP:; this is DAP(i dont know what does that mean, because I've just copied it from wikipedia)) 
        DAP_SIZE      db 10h
                      db 0;reserved
        NUM_OF_SECT   db 01h
                      db 0;reserved too
        ADDRESS2WRITE dd 08100000h
        LBA2READ      dq 1h

        END_DAP:

        MAXMEMADDR dd 0

        times 1961 db 0
        dw 0AA55h     


can you please tell me where is the problem
the code must load the 2nd sector of CD, where kernel is located
also, at the end(when it goes to fail loop), debugger says
VirtualBox's debugger wrote:
dbgf event: VM 01ee0000 is halted! (rem)
eax=00000100 ebx=0000ffff ecx=000f3c00 edx=00000000 esi=fee07c41 edi=00000000
eip=00007c3f esp=0000fffe ebp=00000000 iopl=0 nv up ei pl zr na po cy
cs=0000 ds=0810 es=0000 fs=0000 gs=0000 ss=0000 eflags=00000247
0000:00007c3f eb fe jmp -002h (07c3fh)
VBoxDbg>
Post 26 Mar 2011, 15:05
View user's profile Send private message Reply with quote
revo1ution



Joined: 04 Mar 2010
Posts: 34
Location: somewhere, twiddling something
revo1ution 26 Mar 2011, 20:30
Well you haven't given your INT 13h code!

DAP from memory stands for Device Address Packet which is used ONLY with the extended INT 13h functions (EDDx), not the standard INT 13h BIOS functions.
Post 26 Mar 2011, 20:30
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 26 Mar 2011, 20:38
Quote:
can you please tell me where is the problem
In your code. In many locations. Initialize the stack. Set ds to zero. Use correct drive number and holder of DAP pointer for function 42h. And so on.

Quote:
the code must load the 2nd sector of CD, where kernel is located
What you say? Do you know something about ISO 9660 format?
Post 26 Mar 2011, 20:38
View user's profile Send private message Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER 27 Mar 2011, 05:51
Code:
 ; Output
        format binary as 'iso' 


        ; Macros 
macro @align_null a 
 { 
        repeat ((a - ($ mod a)) mod a) 
                db NULL 
        end repeat 
 } 

macro iso9660_timestamp yr,mo,da,hr,mi,sc,off 
 { 
        db (yr - 1900) 
        db mo 
        db da 

        db hr 
        db mi 
        db sc 

        db off 
 } 

macro iso9660_dw v 
 { 
        dw v 

        db (v shr 8) 
        db (v and 0xFF) 
 } 

macro iso9660_dd v 
 { 
        dd v 

        db ((v shr 24) and 0xFF) 
        db ((v shr 16) and 0xFF) 
        db ((v shr  8) and 0xFF) 
        db (v and 0xFF) 
 } 

macro iso9660_ddx v 
 { 
        db ((v shr 24) and 0xFF) 
        db ((v shr 16) and 0xFF) 
        db ((v shr  8) and 0xFF) 
        db (v and 0xFF) 
 } 

        ; Constants 
        DISK_SIZE_SECTOR        equ 2048 

        NULL                    equ 0 

        ; OS Constants:

        ISO9660_BOOT_NUM_OF_SECTORS_PRESENT equ 1

        ;Other stuff:

        IS09660_VDT_BOOTRECORD equ 0x00
        IS09660_VDT_PRIMARY equ 0x01 
        IS09660_VDT_SUPPLEMENTARY equ 0x02 
        IS09660_VDT_PARTITION equ 0x03 
        IS09660_VDT_TERMINATOR equ 0xFF 

        ; ISO image 
        rb (16 * DISK_SIZE_SECTOR) 
        db IS09660_VDT_PRIMARY 
        db 'CD001' 
        db 0x01 
        db 0 
        db '                                ' 
        db '                                ' 
        iso9660_dd 0
        iso9660_dd (iso9660.boot / DISK_SIZE_SECTOR) 
        dd 0,0,0,0,0,0,0,0 
        iso9660_dw 1 
        iso9660_dw 1 
        iso9660_dw DISK_SIZE_SECTOR 
        iso9660_dd 10 
        dd (iso9660.plpath / DISK_SIZE_SECTOR) 
        dd 0 
        iso9660_ddx (iso9660.pmpath / DISK_SIZE_SECTOR) 
        dd 0 
        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) 
        iso9660_dd DISK_SIZE_SECTOR 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0x00 
        db 0x00 
        iso9660_dw 0 
        db 0x01 
        db 0x00 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        db '2000010100000000',0 
        db '2000010100000000',0 
        dd 0,0,0,0 
        db 0 
        dd 0,0,0,0 
        db 0 
        db 0x01 
        @align_null DISK_SIZE_SECTOR 

    iso9660.brd: 

        db IS09660_VDT_BOOTRECORD 
        db 'CD001' 
        db 0x01 
        db 'EL TORITO SPECIFICATION',0 
        dd 0,0 
        dd 0,0,0,0,0,0,0,0 
        dd (iso9660.bootcat / DISK_SIZE_SECTOR) 
        @align_null DISK_SIZE_SECTOR 

    iso9660.svd: 

        db IS09660_VDT_SUPPLEMENTARY 
        db 'CD001' 
        db 0x01 
        db 0x00 
        dd 0,0,0,0,0,0,0,0 
        db 0,'c',0,'o',0,'d',0,'3',0,'b',0,'4',0,'5',0,'3' 
        db 0,'b',0,'o',0,'o',0,'t',0,' ',0,'c',0,'d',0,' ' 
        iso9660_dd 0 
        iso9660_dd (iso9660.boot / DISK_SIZE_SECTOR) 
        db 0x25,0x2F,0x45,0 
        dd 0,0,0 
        dd 0,0,0,0 
        iso9660_dw 1 
        iso9660_dw 1 
        iso9660_dw DISK_SIZE_SECTOR 
        iso9660_dd 10 
        dd (iso9660.slpath / DISK_SIZE_SECTOR) 
        dd 0 
        iso9660_ddx (iso9660.smpath / DISK_SIZE_SECTOR) 
        dd 0 
        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) 
        iso9660_dd  DISK_SIZE_SECTOR 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0x00 
        db 0x00 
        iso9660_dw 0 
        db 0x01 
        db 0x00 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        dq 0,0,0,0 
        dd 0 
        db 0 
        db '2000010100000000',0 
        db '2000010100000000',0 
        dd 0,0,0,0 
        db 0 
        dd 0,0,0,0 
        db 0 
        db 0x01 
        @align_null DISK_SIZE_SECTOR 

    iso9660.tvd: 

        db IS09660_VDT_TERMINATOR 
        db 'CD001' 
        db 0x01 
        @align_null DISK_SIZE_SECTOR 

    iso9660.boot: 

        ; The boot sector 
        include 'boot.asm' 

        org (21 * DISK_SIZE_SECTOR) 

    iso9660.bootcat: 

        db 0x01 
        db 0x00 
        dw 0 
        dd 0,0,0,0,0,0 
        db 0xAA,0x55 
        db 0x55,0xAA 
        db 0x88 
        db 0x00 
        dw 0x0000 
        db 0x00 
        db 0 
        dw 0x0004 
        dd (iso9660.boot / DISK_SIZE_SECTOR) 
        @align_null DISK_SIZE_SECTOR 

    iso9660.pdr: 

        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) 
        iso9660_dd DISK_SIZE_SECTOR 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0 
        db 0 
        iso9660_dw 0 
        db 0x01 
        db 0x00 

        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.pdr / DISK_SIZE_SECTOR) 
        iso9660_dd 2048 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0 
        db 0 
        iso9660_dw 0 
        db 0x01 
        db 0x01 
        @align_null DISK_SIZE_SECTOR 

    iso9660.plpath: 

        db 0x01 
        db 0x00 
        dd (iso9660.pdr / DISK_SIZE_SECTOR) 
        dw 1 
        dw 0 
        @align_null DISK_SIZE_SECTOR 

    iso9660.pmpath: 

        db 0x01 
        db 0x00 
        iso9660_ddx (iso9660.pdr / DISK_SIZE_SECTOR) 
        iso9660_dw 1 
        iso9660_dw 0 
        @align_null DISK_SIZE_SECTOR 

    iso9660.sdr: 

        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) 
        iso9660_dd DISK_SIZE_SECTOR 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0 
        db 0 
        iso9660_dw 0 
        db 0x01 
        db 0x00 

        db 0x22 
        db 0x00 
        iso9660_dd (iso9660.sdr / DISK_SIZE_SECTOR) 
        iso9660_dd DISK_SIZE_SECTOR 
        iso9660_timestamp 2000,1,1,0,0,0,0 
        db 0x02 
        db 0 
        db 0 
        iso9660_dw 0 
        db 0x01 
        db 0x01 
        @align_null DISK_SIZE_SECTOR 

    iso9660.slpath: 

        db 0x01 
        db 0x00 
        dd (iso9660.sdr / DISK_SIZE_SECTOR) 
        dw 1 
        dw 0 
        @align_null DISK_SIZE_SECTOR 

    iso9660.smpath: 

        db 0x01 
        db 0x00 
        iso9660_ddx (iso9660.sdr / DISK_SIZE_SECTOR) 
        iso9660_dw 1 
        iso9660_dw 0 
        @align_null DISK_SIZE_SECTOR 

        ; 2nd sector
        include 'kernel.asm'
        ; 3rd sector
        ;......

        ; Other disk data can go here                                    


that is the code i use to output ISO file, I dont need any file system on this image, so, I guess kernel is going to be on the 2nd sector(please correct me if Im not right)
Post 27 Mar 2011, 05:51
View user's profile Send private message Reply with quote
egos



Joined: 10 Feb 2009
Posts: 144
egos 27 Mar 2011, 14:26
KERNEL_SECTOR = KERNEL_POSITION/DISK_SIZE_SECTOR
Post 27 Mar 2011, 14:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


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