Subversion Repositories Kolibri OS

Rev

Rev 7121 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7121 Rev 8091
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
7
 
8
$Revision: 7121 $
8
$Revision: 8091 $
9
 
9
 
10
; All parsers are called with ds:si -> value of the variable,
10
; All parsers are called with ds:si -> value of the variable,
11
; possibly with spaces before, and dx = limit of config file.
11
; possibly with spaces before, and dx = limit of config file.
12
 
12
 
13
; Three subroutines parse_char, parse_number and parse_bool set CF
13
; Three subroutines parse_char, parse_number and parse_bool set CF
14
; if something has failed, otherwise return the value in al/ax.
14
; if something has failed, otherwise return the value in al/ax.
15
 
15
 
16
parse_timeout:
16
parse_timeout:
17
; timeout is a number not greater than 9
17
; timeout is a number not greater than 9
18
        call    parse_number
18
        call    parse_number
19
        jc      .nothing
19
        jc      .nothing
20
        cmp     ax, 9
20
        cmp     ax, 9
21
        jbe     @f
21
        jbe     @f
22
        mov     ax, 9
22
        mov     ax, 9
23
@@:
23
@@:
24
        imul    ax, 18
24
        imul    ax, 18
25
        mov     [es:preboot_timeout], ax
25
        mov     [es:preboot_timeout], ax
26
.nothing:
26
.nothing:
27
        ret
27
        ret
28
 
28
 
29
parse_resolution:
29
parse_resolution:
30
; resolution is *, 'x' can be used instead of '*'
30
; resolution is *, 'x' can be used instead of '*'
31
; parse width
31
; parse width
32
        call    parse_number
32
        call    parse_number
33
        jc      .nothing
33
        jc      .nothing
34
; save width
34
; save width
35
        xchg    ax, bx
35
        xchg    ax, bx
36
; test for 'x' or '*'
36
; test for 'x' or '*'
37
        call    parse_char
37
        call    parse_char
38
        cmp     al, 'x'
38
        cmp     al, 'x'
39
        jz      @f
39
        jz      @f
40
        cmp     al, '*'
40
        cmp     al, '*'
41
        jnz     .nothing
41
        jnz     .nothing
42
@@:
42
@@:
43
; parse height
43
; parse height
44
        call    parse_number
44
        call    parse_number
45
        jc      .nothing
45
        jc      .nothing
46
; write width and height
46
; write width and height
47
        mov     [es:x_save], bx
47
        mov     [es:x_save], bx
48
        mov     [es:y_save], ax
48
        mov     [es:y_save], ax
49
.nothing:
49
.nothing:
50
        ret
50
        ret
51
 
51
 
52
parse_vbemode:
52
parse_vbemode:
53
; vbemode is a number
53
; vbemode is a number
54
        call    parse_number
54
        call    parse_number
55
        jc      .nothing
55
        jc      .nothing
56
        mov     [es:number_vm], ax
56
        mov     [es:number_vm], ax
57
.nothing:
57
.nothing:
58
        ret
58
        ret
59
 
59
 
60
parse_biosdisks:
60
parse_biosdisks:
61
; using biosdisks is a boolean setting
61
; using biosdisks is a boolean setting
62
        call    parse_bool
62
        call    parse_bool
63
        jc      .nothing
63
        jc      .nothing
64
; convert 0 to 2, 1 to 1
64
; convert 0 to 2, 1 to 1
65
        inc     ax
65
        inc     ax
66
        xor     al, 3
66
        xor     al, 3
67
        mov     [es:preboot_biosdisk], al
67
        mov     [es:preboot_biosdisk], al
68
.nothing:
68
.nothing:
69
        ret
69
        ret
70
 
70
 
71
parse_imgfrom:
71
parse_imgfrom:
72
; boot device (1-floppy 2-kolibri.img using primary loader)
72
; boot device (1-floppy 2-kolibri.img using primary loader)
73
        call    parse_number
73
        call    parse_number
74
        jc      .nothing
74
        jc      .nothing
75
        cmp     al, 1
75
        cmp     al, 1
76
        jb      .nothing
76
        jb      .nothing
77
        cmp     al, 2
77
        cmp     al, 3
78
        ja      .nothing
78
        ja      .nothing
79
        mov     [es:preboot_device], al
79
        mov     [es:preboot_device], al
80
.nothing:
80
.nothing:
81
        ret
81
        ret
-
 
82
 
-
 
83
parse_syspath:
-
 
84
; everything except spaces
-
 
85
        mov     bx, preboot_syspath
-
 
86
.next_char:
-
 
87
        call    parse_char
-
 
88
        jc      .done
-
 
89
        mov     [es:bx], al
-
 
90
        inc     bx
-
 
91
        jmp     .next_char
-
 
92
.done:
-
 
93
        mov     byte[es:bx], 0          ; terminator
-
 
94
        ret
82
 
95
 
83
parse_char:
96
parse_char:
84
; skip spaces and return the next character or CF if EOF.
97
; skip spaces and return the next character or CF if EOF.
85
        cmp     si, dx
98
        cmp     si, dx
86
        jae     .eof
99
        jae     .eof
87
        lodsb
100
        lodsb
88
        cmp     al, ' '
101
        cmp     al, ' '
89
        jbe     parse_char
102
        jbe     parse_char
90
        ret
103
        ret
91
.eof:
104
.eof:
92
        stc
105
        stc
93
        ret
106
        ret
94
 
107
 
95
parse_number:
108
parse_number:
96
; initialize high part of ax to zero
109
; initialize high part of ax to zero
97
        xor     ax, ax
110
        xor     ax, ax
98
; skip spaces
111
; skip spaces
99
        call    parse_char
112
        call    parse_char
100
        jc      .bad
113
        jc      .bad
101
; al should be a digit
114
; al should be a digit
102
        sub     al, '0'
115
        sub     al, '0'
103
        cmp     al, 9
116
        cmp     al, 9
104
        ja      .bad
117
        ja      .bad
105
; accumulate the value in cx
118
; accumulate the value in cx
106
        xchg    cx, ax
119
        xchg    cx, ax
107
@@:
120
@@:
108
        cmp     si, dx
121
        cmp     si, dx
109
        jae     .eof
122
        jae     .eof
110
        lodsb
123
        lodsb
111
        sub     al, '0'
124
        sub     al, '0'
112
        cmp     al, 9
125
        cmp     al, 9
113
        ja      .end
126
        ja      .end
114
        imul    cx, 10
127
        imul    cx, 10
115
        add     cx, ax
128
        add     cx, ax
116
        jmp     @b
129
        jmp     @b
117
; if the end is caused by non-digit, unwind the last character
130
; if the end is caused by non-digit, unwind the last character
118
.end:
131
.end:
119
        dec     si
132
        dec     si
120
.eof:
133
.eof:
121
        xchg    cx, ax
134
        xchg    cx, ax
122
        clc
135
        clc
123
        ret
136
        ret
124
.bad:
137
.bad:
125
        stc
138
        stc
126
        ret
139
        ret
127
 
140
 
128
parse_bool:
141
parse_bool:
129
; skip spaces
142
; skip spaces
130
        call    parse_char
143
        call    parse_char
131
        jc      .bad
144
        jc      .bad
132
; Boolean false can be represented as 0=no=off,
145
; Boolean false can be represented as 0=no=off,
133
; boolean true can be represented as 1=yes=on.
146
; boolean true can be represented as 1=yes=on.
134
        cmp     al, '0'
147
        cmp     al, '0'
135
        jz      .false
148
        jz      .false
136
        cmp     al, '1'
149
        cmp     al, '1'
137
        jz      .true
150
        jz      .true
138
        mov     ah, al
151
        mov     ah, al
139
        cmp     si, dx
152
        cmp     si, dx
140
        jae     .bad
153
        jae     .bad
141
        lodsb
154
        lodsb
142
        cmp     ax, 'n'*256 + 'o'
155
        cmp     ax, 'n'*256 + 'o'
143
        jz      .false
156
        jz      .false
144
        cmp     ax, 'o'*256 + 'f'
157
        cmp     ax, 'o'*256 + 'f'
145
        jz      .false
158
        jz      .false
146
        cmp     ax, 'y'*256 + 'e'
159
        cmp     ax, 'y'*256 + 'e'
147
        jz      .true
160
        jz      .true
148
        cmp     ax, 'o'*256 + 'n'
161
        cmp     ax, 'o'*256 + 'n'
149
        jz      .true
162
        jz      .true
150
.bad:
163
.bad:
151
        stc
164
        stc
152
        ret
165
        ret
153
.true:
166
.true:
154
        xor     ax, ax
167
        xor     ax, ax
155
        inc     ax
168
        inc     ax
156
        ret
169
        ret
157
.false:
170
.false:
158
        xor     ax, ax
171
        xor     ax, ax
159
        ret
172
        ret