Extended read problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
falstart
Posts: 9
Joined: Sun May 02, 2010 1:09 pm

Extended read problem

Post by falstart »

I'm trying to recursively read this program from the first sector of a floppy disk but it's making no sense. When I boot, it gives me a blank screen when it should at least get to the first print. I tried enabling and disabling interrupts but it ignores that, too. I'm beyond confused, I can't even tell where the problem is :( Can anyone tell me what I'm doing wrong?

Code: Select all

[bits 16]

section .data
	alert db "test ",0

section .text
	xor ax,ax
	mov ax,ds
	cmp ax,0x1000 ;check for first iteration
	je start ;if so, just start
	mov ax,0x7c00 ;otherwise set up
	mov ds,ax
	start:
		mov si,alert ;generic print function
		print:
			lodsb
			cmp al,0x00
			je read
			mov ah,0x0e
			xor bh,bh
			mov bl,0x07
			int 0x10
			jmp print

	dap: ;hopefully this is correct?
		db 0x10 ;16 bytes
		db 0x00 ;unused
		dw 0x01 ;read one sector
		dw 0x00 ;offset
		dw 0x1000 ;segment 0x1000:0x00
		dq 0x00 ;start from the first sector. dq means quadruple word right? I couldn't find much documentation on it :(

	read:
		xor ax,ax
		int 0x13
		mov ah,0x42 ;extended read
		xor dx,dx
		mov dl,0x00 ;floppy drive index
		mov si,dap
		reread:
			int 0x13
			jc reread

	recurse:
		mov ax,0x1000
		mov ds,ax ;reset ds to the new location
		jmp 0x1000:0x00 ;jump there

db 0x55aa
Thanks in advance!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Extended read problem

Post by Combuster »

The bios doesn't know anything about object files - don't make one. This isn't even bootable according to many BIOSes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Extended read problem

Post by bewing »

I'm seeing a lot of things that look mighty iffy in this asm code -- but the "blank screen" problem (specifically) is caused by the fact that your db 0x55aa signature command is not at the right place. It needs to be at the very end of the first sector (bytes 510 and 511). It also should be dw 0xaa55 and not db. No matter how you compile this thing, there is no way your signature will end up where it needs to be. The system you are booting this on is checking for the signature and is not finding it. That blank screen deal is typical of a failed signature check.
falstart
Posts: 9
Joined: Sun May 02, 2010 1:09 pm

Re: Extended read problem

Post by falstart »

Wow, thanks. I had no idea I was that off. I assembled it as flat bin and corrected the bootloader signature and placement (the section .*'s were making it pad to everything but 512). It's working perfectly now :)

I'll just post the corrected bootloader piece just in case someone else has the same problem

Code: Select all

times 510-($-$$) db 0
dw 0xaa55
Post Reply