]>
wirehaze git hosting - BOS.git/blob - kernel/vfs/parse.asm
1 ;--------------------------------------------------------------;
2 ; parse_path - parse path to get info on each part ;
3 ;--------------------------------------------------------------;
5 ; in: esi = pointer to full ASCIIZ path ;
6 ; cl = part no. to extract or 0 for none ;
8 ; out: bl = drive no. (VFS assigned) or zero ;
9 ; bh = number of elements or zero for none ;
10 ; edi = pointer to ASCIIZ part of path in ;
11 ; cl, or 0 on error or no input ;
12 ;--------------------------------------------------------------;
21 cmp byte [esi+1], 0 ; minimum 3 chars drive
26 and byte [esi], 11011111b ; (0xDF) to uppercase
27 and byte [esi+1], 11011111b ; (0xDF) to uppercase
29 mov bl, 0x00 ; fd base is 0x00
30 cmp word [esi], 'FD' ; fd check
32 mov bl, 0x0F ; hd base is 0x0F
33 cmp word [esi], 'HD' ; hd check
35 mov bl, 0x5F ; cd base is 0x5F
36 cmp word [esi], 'CD' ; cd check
38 mov bl, 0x7F ; rd base is 0x7F
39 cmp word [esi], 'RD' ; rd (ram drive) check
41 mov bl, 0x8F ; rm base is 0x8F
42 cmp word [esi], 'RM' ; rm (removable/usb)
44 mov bl, 0xAF ; nd base is 0xAF
45 cmp word [esi], 'ND' ; nd (net) check
48 jmp .error
; no valid drive found
50 ;-----------------------;
52 ;-----------------------;
54 xor edx, edx ; esi offest for first /
55 cmp byte [esi+3], 0 ; end of path
57 cmp byte [esi+3], '/' ; one number
60 mov edx, 4 ; first / after numbers
62 mov ax, word [esi+2] ; get 2 bytes number
65 mov edx, 3 ; first / after numbers
67 mov al, byte [esi+2] ; 1 byte ASCII number
74 sub al, 0x30 ; only one ASCII char.
75 jmp .number_found
; done.
78 sub cx, 0x30 ; take care of first
79 push ecx ; save it for later..
82 shl cx, 1 ; multiply with 10 using
83 mov eax, ecx ; x*8 + x*2 =
87 add ax, cx ; add first number
91 add bl, al ; add number to base
93 ;------------------------;
94 ; parse parts of path ;
95 ;------------------------;
96 mov bh, 0 ; start at zero
97 add esi, edx ; add start offset
100 jne .end ; root, no parts
101 xor eax, eax ; counter
102 .parts_loop: ; loop for path parts
104 cmp byte [esi], 0 ; end of path?
105 je .end ; no inc in parts
106 cmp byte [esi], '/' ; end of part?
110 inc bh ; inc no. of parts
112 inc eax ; char count inc
114 cmp cl, bh ; check for part to
115 jne .parts_loop
; save, if match:
116 mov edi, .filename_buffer
; get buffer
117 dec edi ; offset starts at 1,
118 add edi, eax ; not 0 - so fixed now
121 mov byte [edi], al ; put the byte
122 mov byte [edi+1], 0 ; make ASCIIZ
127 xor eax, eax ; reset char count
128 jmp .parts_loop
; loop again
130 ;------------------------;
131 ; cleanup and return ;
132 ;------------------------;
134 mov edi, .filename_buffer
145 mov edi, 0 ; not a valid part
146 mov bl, 0 ; not a valid drive
147 mov bh, 0 ; not a valid path
150 .filename_buffer: times 256 db 0