hello
I wanna use cmpsb to compare a string in memory whith one I defined. But I don't know how to define a string :S Tried this
first_kernel_file_letter db 'k'
but it wont compile...
Compare a STRING
RE:Compare a STRING
srry, I was doing something else wrong. I used cmpsb like this
mov al, [es:bx]
cmpsb al, [string]
the docs sait it work, but it seems that I have to do it like this
mov al, [es:bx]
mov si, ax
mov di, string
cmpsb
now, it can't find the thing. I'm reading out the root directory, using LBACHS to calculate the location of the root dir. But it can't find the file... Is my method of seaching wrong, or something else? The file I search (which I've pasted on the diskette) I've defined like this
file db 'file bin'
is that wrong? The file name is 8 chars long, than a space and then a three chars long extension...
mov al, [es:bx]
cmpsb al, [string]
the docs sait it work, but it seems that I have to do it like this
mov al, [es:bx]
mov si, ax
mov di, string
cmpsb
now, it can't find the thing. I'm reading out the root directory, using LBACHS to calculate the location of the root dir. But it can't find the file... Is my method of seaching wrong, or something else? The file I search (which I've pasted on the diskette) I've defined like this
file db 'file bin'
is that wrong? The file name is 8 chars long, than a space and then a three chars long extension...
RE:Compare a STRING
;Try this:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Looks for a file with particular name ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Input: DS:SI -> file name (11 chars) ;;
;; ES:DI -> root directory array ;;
;; DX = number of root entries ;;
;; Output: SI = cluster number ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FindName:
mov cx, 11
FindNameCycle:
cmp byte [es:di], ch
je FindNameFailed ; end of root directory
pusha
repe cmpsb
popa
je FindNameFound
add di, 32
dec dx
jnz FindNameCycle ; next root entry
FindNameFailed:
jmp ErrFind
FindNameFound:
mov si, [es:di+1Ah] ; si = cluster no.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Looks for a file with particular name ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Input: DS:SI -> file name (11 chars) ;;
;; ES:DI -> root directory array ;;
;; DX = number of root entries ;;
;; Output: SI = cluster number ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FindName:
mov cx, 11
FindNameCycle:
cmp byte [es:di], ch
je FindNameFailed ; end of root directory
pusha
repe cmpsb
popa
je FindNameFound
add di, 32
dec dx
jnz FindNameCycle ; next root entry
FindNameFailed:
jmp ErrFind
FindNameFound:
mov si, [es:di+1Ah] ; si = cluster no.
RE:Compare a STRING
there should NOT be a space between the fileName and ext -- it should be a total of:
8 char (fileName)+ 3 char(ext)=11 characters TOTAL not 12!
also the filename should be ALLCAPS (since FAT12 dir entries are always in capital letters to make searching easier)
8 char (fileName)+ 3 char(ext)=11 characters TOTAL not 12!
also the filename should be ALLCAPS (since FAT12 dir entries are always in capital letters to make searching easier)