Subversion Repositories Kolibri OS

Rev

Rev 8091 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8091 Rev 8092
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: 8091 $
8
$Revision: 8092 $
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, 3-don't use ramdisk)
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, 3
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
 
82
 
83
parse_syspath:
83
parse_syspath:
84
; everything except spaces
84
; everything except spaces
85
        mov     bx, preboot_syspath
85
        mov     bx, preboot_syspath
86
.next_char:
86
.next_char:
87
        call    parse_char
87
        call    parse_char
88
        jc      .done
88
        jc      .done
89
        mov     [es:bx], al
89
        mov     [es:bx], al
90
        inc     bx
90
        inc     bx
91
        jmp     .next_char
91
        jmp     .next_char
92
.done:
92
.done:
93
        mov     byte[es:bx], 0          ; terminator
93
        mov     byte[es:bx], 0          ; terminator
94
        ret
94
        ret
95
 
95
 
96
parse_char:
96
parse_char:
97
; skip spaces and return the next character or CF if EOF.
97
; skip spaces and return the next character or CF if EOF.
98
        cmp     si, dx
98
        cmp     si, dx
99
        jae     .eof
99
        jae     .eof
100
        lodsb
100
        lodsb
101
        cmp     al, ' '
101
        cmp     al, ' '
102
        jbe     parse_char
102
        jbe     parse_char
103
        ret
103
        ret
104
.eof:
104
.eof:
105
        stc
105
        stc
106
        ret
106
        ret
107
 
107
 
108
parse_number:
108
parse_number:
109
; initialize high part of ax to zero
109
; initialize high part of ax to zero
110
        xor     ax, ax
110
        xor     ax, ax
111
; skip spaces
111
; skip spaces
112
        call    parse_char
112
        call    parse_char
113
        jc      .bad
113
        jc      .bad
114
; al should be a digit
114
; al should be a digit
115
        sub     al, '0'
115
        sub     al, '0'
116
        cmp     al, 9
116
        cmp     al, 9
117
        ja      .bad
117
        ja      .bad
118
; accumulate the value in cx
118
; accumulate the value in cx
119
        xchg    cx, ax
119
        xchg    cx, ax
120
@@:
120
@@:
121
        cmp     si, dx
121
        cmp     si, dx
122
        jae     .eof
122
        jae     .eof
123
        lodsb
123
        lodsb
124
        sub     al, '0'
124
        sub     al, '0'
125
        cmp     al, 9
125
        cmp     al, 9
126
        ja      .end
126
        ja      .end
127
        imul    cx, 10
127
        imul    cx, 10
128
        add     cx, ax
128
        add     cx, ax
129
        jmp     @b
129
        jmp     @b
130
; 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
131
.end:
131
.end:
132
        dec     si
132
        dec     si
133
.eof:
133
.eof:
134
        xchg    cx, ax
134
        xchg    cx, ax
135
        clc
135
        clc
136
        ret
136
        ret
137
.bad:
137
.bad:
138
        stc
138
        stc
139
        ret
139
        ret
140
 
140
 
141
parse_bool:
141
parse_bool:
142
; skip spaces
142
; skip spaces
143
        call    parse_char
143
        call    parse_char
144
        jc      .bad
144
        jc      .bad
145
; Boolean false can be represented as 0=no=off,
145
; Boolean false can be represented as 0=no=off,
146
; boolean true can be represented as 1=yes=on.
146
; boolean true can be represented as 1=yes=on.
147
        cmp     al, '0'
147
        cmp     al, '0'
148
        jz      .false
148
        jz      .false
149
        cmp     al, '1'
149
        cmp     al, '1'
150
        jz      .true
150
        jz      .true
151
        mov     ah, al
151
        mov     ah, al
152
        cmp     si, dx
152
        cmp     si, dx
153
        jae     .bad
153
        jae     .bad
154
        lodsb
154
        lodsb
155
        cmp     ax, 'n'*256 + 'o'
155
        cmp     ax, 'n'*256 + 'o'
156
        jz      .false
156
        jz      .false
157
        cmp     ax, 'o'*256 + 'f'
157
        cmp     ax, 'o'*256 + 'f'
158
        jz      .false
158
        jz      .false
159
        cmp     ax, 'y'*256 + 'e'
159
        cmp     ax, 'y'*256 + 'e'
160
        jz      .true
160
        jz      .true
161
        cmp     ax, 'o'*256 + 'n'
161
        cmp     ax, 'o'*256 + 'n'
162
        jz      .true
162
        jz      .true
163
.bad:
163
.bad:
164
        stc
164
        stc
165
        ret
165
        ret
166
.true:
166
.true:
167
        xor     ax, ax
167
        xor     ax, ax
168
        inc     ax
168
        inc     ax
169
        ret
169
        ret
170
.false:
170
.false:
171
        xor     ax, ax
171
        xor     ax, ax
172
        ret
172
        ret