Subversion Repositories Kolibri OS

Rev

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

Rev 5363 Rev 7121
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: 5363 $
8
$Revision: 7121 $
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
 
-
 
60
;parse_vrr:
-
 
61
;; vrr is a boolean setting
-
 
62
;        call    parse_bool
-
 
63
;        jc      .nothing
-
 
64
;; convert 0 to 2, 1 to 1
-
 
65
;        inc     ax
-
 
66
;        xor     al, 3
-
 
67
;        mov     [es:preboot_vrrm], al
-
 
68
;.nothing:
-
 
69
;        ret
-
 
70
 
59
 
71
parse_biosdisks:
60
parse_biosdisks:
72
; using biosdisks is a boolean setting
61
; using biosdisks is a boolean setting
73
        call    parse_bool
62
        call    parse_bool
74
        jc      .nothing
63
        jc      .nothing
75
; convert 0 to 2, 1 to 1
64
; convert 0 to 2, 1 to 1
76
        inc     ax
65
        inc     ax
77
        xor     al, 3
66
        xor     al, 3
78
        mov     [es:preboot_biosdisk], al
67
        mov     [es:preboot_biosdisk], al
79
.nothing:
68
.nothing:
80
        ret
69
        ret
81
 
70
 
82
parse_imgfrom:
71
parse_imgfrom:
83
; boot device (1-floppy 2-kolibri.img using primary loader)
72
; boot device (1-floppy 2-kolibri.img using primary loader)
84
        call    parse_number
73
        call    parse_number
85
        jc      .nothing
74
        jc      .nothing
86
        cmp     al, 1
75
        cmp     al, 1
87
        jb      .nothing
76
        jb      .nothing
88
        cmp     al, 2
77
        cmp     al, 2
89
        ja      .nothing
78
        ja      .nothing
90
        mov     [es:preboot_device], al
79
        mov     [es:preboot_device], al
91
.nothing:
80
.nothing:
92
        ret
81
        ret
93
 
82
 
94
parse_char:
83
parse_char:
95
; skip spaces and return the next character or CF if EOF.
84
; skip spaces and return the next character or CF if EOF.
96
        cmp     si, dx
85
        cmp     si, dx
97
        jae     .eof
86
        jae     .eof
98
        lodsb
87
        lodsb
99
        cmp     al, ' '
88
        cmp     al, ' '
100
        jbe     parse_char
89
        jbe     parse_char
101
        ret
90
        ret
102
.eof:
91
.eof:
103
        stc
92
        stc
104
        ret
93
        ret
105
 
94
 
106
parse_number:
95
parse_number:
107
; initialize high part of ax to zero
96
; initialize high part of ax to zero
108
        xor     ax, ax
97
        xor     ax, ax
109
; skip spaces
98
; skip spaces
110
        call    parse_char
99
        call    parse_char
111
        jc      .bad
100
        jc      .bad
112
; al should be a digit
101
; al should be a digit
113
        sub     al, '0'
102
        sub     al, '0'
114
        cmp     al, 9
103
        cmp     al, 9
115
        ja      .bad
104
        ja      .bad
116
; accumulate the value in cx
105
; accumulate the value in cx
117
        xchg    cx, ax
106
        xchg    cx, ax
118
@@:
107
@@:
119
        cmp     si, dx
108
        cmp     si, dx
120
        jae     .eof
109
        jae     .eof
121
        lodsb
110
        lodsb
122
        sub     al, '0'
111
        sub     al, '0'
123
        cmp     al, 9
112
        cmp     al, 9
124
        ja      .end
113
        ja      .end
125
        imul    cx, 10
114
        imul    cx, 10
126
        add     cx, ax
115
        add     cx, ax
127
        jmp     @b
116
        jmp     @b
128
; if the end is caused by non-digit, unwind the last character
117
; if the end is caused by non-digit, unwind the last character
129
.end:
118
.end:
130
        dec     si
119
        dec     si
131
.eof:
120
.eof:
132
        xchg    cx, ax
121
        xchg    cx, ax
133
        clc
122
        clc
134
        ret
123
        ret
135
.bad:
124
.bad:
136
        stc
125
        stc
137
        ret
126
        ret
138
 
127
 
139
parse_bool:
128
parse_bool:
140
; skip spaces
129
; skip spaces
141
        call    parse_char
130
        call    parse_char
142
        jc      .bad
131
        jc      .bad
143
; Boolean false can be represented as 0=no=off,
132
; Boolean false can be represented as 0=no=off,
144
; boolean true can be represented as 1=yes=on.
133
; boolean true can be represented as 1=yes=on.
145
        cmp     al, '0'
134
        cmp     al, '0'
146
        jz      .false
135
        jz      .false
147
        cmp     al, '1'
136
        cmp     al, '1'
148
        jz      .true
137
        jz      .true
149
        mov     ah, al
138
        mov     ah, al
150
        cmp     si, dx
139
        cmp     si, dx
151
        jae     .bad
140
        jae     .bad
152
        lodsb
141
        lodsb
153
        cmp     ax, 'n'*256 + 'o'
142
        cmp     ax, 'n'*256 + 'o'
154
        jz      .false
143
        jz      .false
155
        cmp     ax, 'o'*256 + 'f'
144
        cmp     ax, 'o'*256 + 'f'
156
        jz      .false
145
        jz      .false
157
        cmp     ax, 'y'*256 + 'e'
146
        cmp     ax, 'y'*256 + 'e'
158
        jz      .true
147
        jz      .true
159
        cmp     ax, 'o'*256 + 'n'
148
        cmp     ax, 'o'*256 + 'n'
160
        jz      .true
149
        jz      .true
161
.bad:
150
.bad:
162
        stc
151
        stc
163
        ret
152
        ret
164
.true:
153
.true:
165
        xor     ax, ax
154
        xor     ax, ax
166
        inc     ax
155
        inc     ax
167
        ret
156
        ret
168
.false:
157
.false:
169
        xor     ax, ax
158
        xor     ax, ax
170
        ret
159
        ret