Subversion Repositories Kolibri OS

Rev

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

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