Today's question

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
wererabit
Posts:30
Joined:Wed Sep 03, 2008 2:50 am
Today's question

Post by wererabit » Wed Apr 01, 2009 9:04 am

:D guys, I have some other questions :roll: I know I know I am such a paint :)

I am at tutorial 11, the last part. I know we did most of these while we were working on our boot loader. I understand the main points, but there are some changes and some of those confuse me. and here they go:

Sorry guys, its kind of messy

Question 1: FindFile "method",

Code: Select all

.LOOP:
	push    cx
	mov     cx, 11					; eleven character name. Image name is in SI
	mov	si, bx						; image name is in BX
 	push    di
     rep  cmpsb							; test for entry match
	pop     di
	je      .Found
	pop     cx
	add     di, 32					; queue next directory entry
	loop    .LOOP

.NotFound:
       .............................................
.Found:
	pop	ax						; return value into AX contains entry of file
	pop	bx						; restore registers and return
       .............................................
	ret

If you look at rep cmpsb statement, just before that statement we push di, right after that we pop di, to restore the value (before we jump to the .Found label.

Suppose that if the strings are equals and we jump to .Found. Now we want to store the index of the entry to ax by executing pop ax. But we already pop di, The value on top of the stack will not be di anymore. Will it just get another value on top of the stack and put into ax? so our ax will not contains the right index

I was thinking it should be this, jump before restore di

Code: Select all

       push    di
       rep  cmpsb							; test for entry match
       je      .Found
       pop     di
Question 2: In LoadFile

Code: Select all

LOAD_IMAGE_PRE:
	sub	edi, ROOT_OFFSET
	sub	eax, ROOT_OFFSET
what those 2 subtract lines do?

Thank you :roll:

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Re: Today's question

Post by Mike » Sat Apr 04, 2009 3:48 am

Hello,

I have not worked on that code for a little while, but I am suspecting their might be a bug in the code related to the sections that you are referring to. I will take a look into it when I have more time and will post back when I find anything :)
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

Post Reply