Today's question
Posted: Wed Apr 01, 2009 9:04 am



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
Code: Select all
LOAD_IMAGE_PRE:
sub edi, ROOT_OFFSET
sub eax, ROOT_OFFSET
Thank you
