;This code searches through sectors of the hard disk one at a time, starting with the
;sector in ecx (1 in this case) and counting downward as the loop decrements it.
;It requires that a test_dsel selector be set up in the GDT and that it has a corresponding
;data area almost exactly like:

	;testdata:
	;        TIMES 100h      db      "c"
	;        test_string     equ     $ - testdata
	;                        db      "poop"
	;end_testdata:

	push es
        push ds
        mov ax, test_dsel
        mov es, ax
        mov ds, ax
        mov ecx, 1;16 ;the value of this will set what sector is read also
search_loop:
        push ecx
        xor edi, edi
        mov eax, 0
        mov ebx, ecx    ;!!!*!*!*!*!*!!* CHANGED WAS mov ebx, 1 ***!!!!!!!!
        mov ecx, 1
        call sys_hdread_csel:0

        mov ecx, 512            ;test 1 sector in the instr search
        mov esi, 0              ;start searching at test_dsel:0
        mov edx, 4              ;"Oper" is 4 chars long
        mov al, 1               ;Case doesn't matter.
        mov edi, test_string    ;string searched for is at test_dsel:test_string
        call lib_instr_csel:0
        test al, 0ffh
        jz found_it

        mov ecx, 07d00000h
wait4hd:        loop wait4hd
        pop ecx
        loop search_loop
        jmp not_found

found_it:
        pop ecx
        mov al, white
        call sys_print_csel:0   ;ds:esi still points to the match string
not_found:
        pop ds
        pop es

        push ds
        mov ax, test_dsel
        mov ds, ax
        mov ax, white
        xor esi, esi
        call sys_print_csel:0
        pop ds