Subversion Repositories Kolibri OS

Rev

Rev 5363 | 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: 7121 $
  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, 2
  78.         ja      .nothing
  79.         mov     [es:preboot_device], al
  80. .nothing:
  81.         ret
  82.  
  83. parse_char:
  84. ; skip spaces and return the next character or CF if EOF.
  85.         cmp     si, dx
  86.         jae     .eof
  87.         lodsb
  88.         cmp     al, ' '
  89.         jbe     parse_char
  90.         ret
  91. .eof:
  92.         stc
  93.         ret
  94.  
  95. parse_number:
  96. ; initialize high part of ax to zero
  97.         xor     ax, ax
  98. ; skip spaces
  99.         call    parse_char
  100.         jc      .bad
  101. ; al should be a digit
  102.         sub     al, '0'
  103.         cmp     al, 9
  104.         ja      .bad
  105. ; accumulate the value in cx
  106.         xchg    cx, ax
  107. @@:
  108.         cmp     si, dx
  109.         jae     .eof
  110.         lodsb
  111.         sub     al, '0'
  112.         cmp     al, 9
  113.         ja      .end
  114.         imul    cx, 10
  115.         add     cx, ax
  116.         jmp     @b
  117. ; if the end is caused by non-digit, unwind the last character
  118. .end:
  119.         dec     si
  120. .eof:
  121.         xchg    cx, ax
  122.         clc
  123.         ret
  124. .bad:
  125.         stc
  126.         ret
  127.  
  128. parse_bool:
  129. ; skip spaces
  130.         call    parse_char
  131.         jc      .bad
  132. ; Boolean false can be represented as 0=no=off,
  133. ; boolean true can be represented as 1=yes=on.
  134.         cmp     al, '0'
  135.         jz      .false
  136.         cmp     al, '1'
  137.         jz      .true
  138.         mov     ah, al
  139.         cmp     si, dx
  140.         jae     .bad
  141.         lodsb
  142.         cmp     ax, 'n'*256 + 'o'
  143.         jz      .false
  144.         cmp     ax, 'o'*256 + 'f'
  145.         jz      .false
  146.         cmp     ax, 'y'*256 + 'e'
  147.         jz      .true
  148.         cmp     ax, 'o'*256 + 'n'
  149.         jz      .true
  150. .bad:
  151.         stc
  152.         ret
  153. .true:
  154.         xor     ax, ax
  155.         inc     ax
  156.         ret
  157. .false:
  158.         xor     ax, ax
  159.         ret
  160.