flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
egos 15 Nov 2011, 10:13
smiddy wrote: After some reading, it appears that some BIOSes don't report the correct drive number in the DL upon boot up from a CD-ROM. _________________ If you have seen bad English in my words, tell me what's wrong, please. |
|||
![]() |
|
smiddy 15 Nov 2011, 12:17
The Virtual PC and VirtualBox both report 00h, then after doing INT 13h Function 4B01h do I get the drive numbers that they should be (E0h and EFh respectively). My AMD 3000+ report a 00h at boot up, it's a circa 2003-ish machine, after running INT 13h Function 4B01h it reports E0h as well. On my other two machines, it fails do to the CARRY FLAG being set. Once the CARRY FLAG is set I don't recheck, this is where I will do the loop to check for each drive decrementing down from FFh until I reach 81h. I probably won't get to that for a week or so, since I will be on business travel this week.
|
|||
![]() |
|
cod3b453 15 Nov 2011, 19:01
Where are you writing the boot sector to your disk image and have you created the necessary ISO tables (primary partition, boot record, boot catalog etc)?
VirtualBox supports both emulation (ID 0x00, image location 0000, 512 byte sectors) and non-emulation boots (ID 0xE0, image location A000, 2048 byte sectors). I've also had no problems with VirtualPC or QEMU in non-emulation. |
|||
![]() |
|
smiddy 16 Nov 2011, 00:44
Hi cod3b453,
Yep, it took me a while to get the iso built, I created it with FASM and I used MagicISO to check it. Everything is there to boot, I can PM you the code, I'd rather it not be put out "in the wild" until I have finished my boot process. So, it boots as I would expect, but the DL upon boot, always returns 00h no matter the system. So I'm on the learning curve of figuring out how to get the true boot drive, since the code is only on a CD the assumption is (from the code's perspective) that it booted from a CD, but finding the where seems to be the problem. I used INT 13h function 4B01h to get the actual drive number by putting what was given from BIOS in the DL to this function, and in the Disk Results Buffer at offset byte 2, I get the right results. I then read in the Primary Volume Descriptor to get the location of the boot directory. At this point that is as far as I've gotten. I need to parse the root directory and find the OS file information, then load to memory, and jump to its location to run. I'm a ways form that at the moment, since I'm being distracted by figuring out a decent method to determine the actual drive, since on my real machine I use all the time, it returns 00h in the DL at but AND the CF is indicated when using INT 13h function 4B01h. I want it to boot on my true machine. My legacy machines it works ok thus far. BTW, I found a BIOS Enhance Disk Drive Services document and I found this excerpt interesting: Code: 7.1.2 No Emulation Boot If an image is marked as No Emulation Boot, the system BIOS shall load the specified number of sectors and jump to the specified segment number to start the boot program executing. Since this is a no emulation boot, the system BIOS shall not provide access to the media through INT 13h FNs 00h through 3Fh. The system BIOS shall assign the CD-ROM drive a device number. A common industry number is A0h. This is outside the range of normal BIOS hard drive numbers (above 9Ah), but still within INT 13h range limitation. It appears that I won't have to cycle down from FFh to 81h, but only to A0h... ![]() Oh, BTW, I am using no emulation upon boot. I haven't tried QEMU or Bochs for that matter recently. |
|||
![]() |
|
smiddy 16 Nov 2011, 00:53
Here's a screenshot from VirtualBox of the current progress.
|
||||||||||
![]() |
|
egos 16 Nov 2011, 09:04
Bochs reports 0xE0. Try to run this code in VirtualBox:
Code: org 7C00h xor bx,bx cli mov ss,bx mov sp,$$ sti mov ds,bx ; jmp 0:@f @@: mov al,dl call hexbyte mov [disknum],ax mov si,msgstr call putstr mov ah,0 int 16h int 19h @@: push si mov bx,7 mov ah,0Eh int 10h pop si putstr: mov al,[si] inc si and al,al jg short @b ret hexbyte: aam 10h cmp al,0Ah sbb al,69h das xchg al,ah cmp al,0Ah sbb al,69h das ret msgstr: db 13,10,"BIOS disk number: 0x" disknum: db "??",13,10,"Press any key to reboot...",32,0 rb 83FEh-$ dw 0AA55h |
|||
![]() |
|
cod3b453 16 Nov 2011, 18:28
I posted an ISO image in: http://board.flatassembler.net/topic.php?p=122150 - it's not a particularly amazing example (and is wrong in places
![]() I realise your aim is not to be in CDROM emulation but that's what an ID of 0x00, until you use the BIOS emulation functions int 0x13 ax=0x4B0X, is. |
|||
![]() |
|
egos 16 Nov 2011, 19:41
I think the problem is here:
Code: MOV [CDDriveNumber],DL ... MOV DS,AX ... MOV AL,[CDDriveNumber] I can't understand what's happened with stack initialization too. |
|||
![]() |
|
smiddy 17 Nov 2011, 00:06
egos wrote: Bochs reports 0xE0. Try to run this code in VirtualBox: I need to study this more, your code reports E0h, so maybe I'm doing something wrong there...
|
||||||||||
![]() |
|
smiddy 17 Nov 2011, 00:08
cod3b453 wrote: I posted an ISO image in: http://board.flatassembler.net/topic.php?p=122150 - it's not a particularly amazing example (and is wrong in places cod3b453 wrote: I realise your aim is not to be in CDROM emulation but that's what an ID of 0x00, until you use the BIOS emulation functions int 0x13 ax=0x4B0X, is. Last edited by smiddy on 17 Nov 2011, 00:14; edited 1 time in total |
|||
![]() |
|
smiddy 17 Nov 2011, 00:13
egos wrote: I think the problem is here: I am not using the stack (yet) so I'm not pushing and popping. I don't intend to either, yet. Too much to work first, the stack will be part of my memory management plan, which I haven't set down and thought of yet. In my older code I did set it up prior to booting my OS, and I loaded started my os, and began using the same stack there. I don't know if I want to do that this time or not. I'll correct my code by setting up the DS prior to assigning the CDDriveNumber and report back, I bet that is it. |
|||
![]() |
|
smiddy 17 Nov 2011, 00:20
That did it, I changed it to set all the segment registers (except the stack segment) and it worked:
Code: format binary as "bin" ; Tell FASM to make an BIN image ORG 0 DEBUG_MESSAGES: ; Comment out to remove debugging messages BootSector: ; Label in order to determine size of code for ; padding at the end. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Start Boot Procedure ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Begin: ; Begining of instructions CLI ; Turn off intterrupts mov ax,07C0h ; Boot Segment mov gs,ax mov ds,ax mov es,ax mov fs,ax MOV [CDDriveNumber],DL ; Save boot drive, right away STI ; Turn interrupts back on
|
||||||||||
![]() |
|
bitshifter 18 Nov 2011, 19:34
I just stopped in to give advice, but it seems others have already done so...
Oh well, anyway here is what i was going to post... Code: org 0 use16 cli jmp 0x07C0:start start: mov ax,cs mov ds,ax mov es,ax ; mov fs,ax ;check CPU type before using these... ; mov gs,ax mov ss,ax xor sp,sp mov [ds:drive],dl sti _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.