Subversion Repositories Kolibri OS

Rev

Rev 8092 | Details | Compare with Previous | Last modification | View Log | RSS feed

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