Subversion Repositories Kolibri OS

Rev

Rev 7121 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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