Message board for the users of flat assembler.
> OS Construction > Need help with code
BOTOKILLER 30 Mar 2011, 09:33
It's me again. Here's my code
USE16 ORG 07C00h START: mov ecx, 0FFh ; put 0FFh to ecx for loop LOADKERN: ; loading kernel mov dl, cl ; number in dl is number in ecx now mov di, cs mov ds, di ; loading DAP segment mov di, DAP ; and offset mov ah, 42h ; function number pusha ; saving registers(because i dont know what int is going to do with them int 13h ; calling INT 13h push ax ; saving error code mov al, '2' ; that just was to indicate where mistake occured(remains of fail handler) jnc FAIL ; jump to FAIL(originally it was fail handler, but now it's non-fail handler pop ax ; put ax back to ax if we didnt jump to FAIL AFTERFAIL: ; just pointer where FAIL must return popa ; taking back all registers loop LOADKERN ; and doing all of this FF times AMOUNTOFMEMSCAN:; it has nothing to do with problem mov ax, 0E801h int 15h mov al, '1' jc FAIL xchg ax, bx mov bx, 0FFFFh mul bx mov di, MAXMEMADDR mov [cs:di], eax LDSO: jmp LDSO FAIL: ; FAIL, as I said previiously it is non-fail handler mov ah, 0eh ; int 10h ; putting number in al to screen(remains of fail handler) pop ax ; taking error code back to ax, so I can see it in debugger(remains of fail handler, but still usefull, only a bit) jmp AFTERFAIL ; back to procedure DAP: DAP_Size db 10h ;size of packet DAP_Res1 db 0 ; reserved DAP_Bytes2Transfer db 4h ;amount of sectors that have to be transferred DAP_Res2 db 0 ;reserved DAP_Buff_Addr dd 08100000h ;place where im putting my kernel - 0810h:0000 or 8100h DAP_LBA dq 0h ;lba address of the first sector to read times 12 db 0 MAXMEMADDR dd 0;it has nothing to do with problem too times 1954 db 0 dw 0AA55h
I start it in Virtual Box, and that is what i get(picture)
The code must try all BIOS device numbers, and try to read from each one, and if there is no mistake it goes to FAIL(dont ask), and I guess it finaly found CD-ROM number (F0h in ah when message strikes) but what about this message???
Last edited by BOTOKILLER on 30 Mar 2011, 10:22; edited 1 time in total
|30 Mar 2011, 09:33||
roboman 30 Mar 2011, 10:01
>AH = 42h
>DL = drive number
>DS:SI -> disk address packet
So you have FFh as your drive number....
and I'm guessing the >mov di, DAP
should have been: mov si, DAP
>00h BYTE size of packet (10h or 18h)
>01h BYTE reserved (0)
>02h WORD number of blocks to transfer (max 007Fh for Phoenix EDD)
>04h DWORD -> transfer buffer
>08h QWORD starting absolute block number
(for non-LBA devices, compute as
(Cylinder*NumHeads + SelectedHead) * SectorPerTrack +
SelectedSector - 1
>10h QWORD (EDD-3.0, optional) 64-bit flat address of transfer buffer;
used if DWORD at 04h is FFFFh:FFFFh
DAP_Size db 10h
DAP_Res1 db 0
DAP_Bytes2Transfer db 4h
DAP_Res2 db 0
DAP_Buff_Addr dd 08100000h
DAP_LBA dq 0h
Um, the sizes don't match. Comments as to what you are trying to do might help. Guessing that's a boot sector and you are taking a shot at loading something, from some drive, to some where, but am a bit lost as to exactly what you are shooting for.
|30 Mar 2011, 10:01||
BOTOKILLER 30 Mar 2011, 10:27
code comments - done(much of old useless code, which is now no needed there)
about DAP - http://www.t13.org/Documents/UploadedDocuments/project/d1386r5-EDD.pdf - these are specs, page 9 - I filled it accordingly to this table
any other ideas???
|30 Mar 2011, 10:27||
roboman 31 Mar 2011, 03:31
>AH - 42h
>DL - BIOS device number
>DS:SI - Device address packet
That part agrees with Ralf Brown's Interrupt List. So you are starting at the highest possible device and just working your way down, trying to load the boot sector
mov ds, di ; loading DAP segment
mov di, DAP ; and offset
oopps, the offset should have been put in si. Don't see si in the program, so it's a guess as to what chunk of memory it's reading as a DAP table.
So the software just starts with the last possible device and counts down loading any thing found in the first 4 sectors into the same location it did with the last device, then goes into an endless loop?
Or 400h sectors get copied, depending on whos docs are right.
Hoping to see each drives lights come on as a test? Don't know why the error message, I checked several bois that I have on the computers around here and some don't have the extended functions, so I don't use them...
|31 Mar 2011, 03:31||
BOTOKILLER 31 Mar 2011, 12:25
>AH - 42h
thanks, the error message is gone, but nothing more, I look into memory through debugger, but nothing on 810h:0000h
about 400h sectors, I think, that I fixed it too
USE16 ORG 07C00h START: mov ecx, 0FFh LOADKERN: mov di, DAP_Buff_Addr mov dword [cs:di], 8100000h ; that is where i fixed it mov dl, cl mov si, cs ; changed di to si mov ds, si mov si, DAP mov ah, 42h pusha int 13h push ax push dx mov al, '2' jnc FAIL pop ax pop dx AFTERFAIL: popa loop LOADKERN ; AMOUNTOFMEMSCAN: ; mov ax, 0E801h ; int 15h ; mov al, '1' ; jc FAIL ; xchg ax, bx ; mov bx, 0FFFFh ; mul bx ;mov di, MAXMEMADDR ;mov [cs:di], eax LDSO: jmp LDSO FAIL: mov ah, 0eh int 10h pop ax push ax xchg ah, al mov ah, 0eh int 10h pop ax pop dx jmp LDSO DAP: DAP_Size db 10h DAP_Res1 db 0 DAP_Bytes2Transfer db 4h DAP_Res2 db 0 DAP_Buff_Addr dd 08100000h DAP_LBA dq 0h times 12 db 0 ;MAXMEMADDR dd 0 times 1958 db 0 dw 0AA55h
i doubt that it reads CD even once, or I just have mor mistakes in my code????
|31 Mar 2011, 12:25||
Dex4u 31 Mar 2011, 16:03
Have you tryed something like this
DAP_Size db 10h DAP_Res1 db 0 DAP_Bytes2Transfer db 4h DAP_Res2 db 0 DAP_Buff_Addr1 dw 0x0810 DAP_Buff_Addr2 dw 0 DAP_LBA dq 0
As if i can remember right some of the info on the net about DAP layout is wrong.
|31 Mar 2011, 16:03||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.