Subversion Repositories Kolibri OS

Rev

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

  1. ; Copyright (c) 2009, <Lrz>
  2. ; All rights reserved.
  3. ;
  4. ; Redistribution and use in source and binary forms, with or without
  5. ; modification, are permitted provided that the following conditions are met:
  6. ;       * Redistributions of source code must retain the above copyright
  7. ;       notice, this list of conditions and the following disclaimer.
  8. ;       * Redistributions in binary form must reproduce the above copyright
  9. ;       notice, this list of conditions and the following disclaimer in the
  10. ;       documentation and/or other materials provided with the distribution.
  11. ;       * Neither the name of the <organization> nor the
  12. ;       names of its contributors may be used to endorse or promote products
  13. ;       derived from this software without specific prior written permission.
  14. ;
  15. ; THIS SOFTWARE IS PROVIDED BY Alexey Teplov nickname <Lrz> ''AS IS'' AND ANY
  16. ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. ; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
  19. ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. ;*****************************************************************************
  26.  
  27. ;áëîê ìàêðîñîâ ïî îáðàáîòêå ñåêöèè [loader]
  28. ;âõîäíûå äàííûå:
  29. ;es:di - óêàçàòåëü íà ñåêöèþ íà÷èíàþùèþñÿ ñ '[' âñòå÷àþùèþñÿ ïîñëå 0õa
  30. ;cx - ñ÷åò÷èê êîë-âî áàéò äëÿ ïðîâåðêå â êàäðå
  31. ;
  32. macro use_parse_loader
  33. {
  34. .parse_loader:
  35. ;//////////////////
  36. ;/ parse  [loader]
  37. ;//////////////////
  38.         mov     bx,cx   ;cîõðàíèì â ðåãèñòðû çíà÷åíèÿ ñ÷åò÷èêà è óêàçàòåëÿ
  39.         mov     ax,di
  40.  
  41. ;       mov     word [bp-4],.start  ;is alredy set, see up
  42.         mov     si,parse_loader
  43.         mov     cx,parse_loader_e - parse_loader
  44.         repe    cmpsb
  45.         jnz     error.rest_value        ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå  ò.å. áóäåì ñíîâà èñêàòü))
  46.  
  47.         ;ñîõðàíèì óêàçàòåëüíà loader, ÷òî áû ïîòîì áîëüøå åãî íå èñêàòü
  48.         mov     point_loader,ax
  49.         sub     bx,parse_loader_e - parse_loader ;correct cx
  50.         add     bx,cx
  51.         mov     cx,bx
  52.  
  53. if DEBUG        
  54.         pusha
  55.         mov     si,lm_l_found
  56.         call    printplain
  57.         popa
  58. end if  
  59. ;/////////////////end check [loader]. [loader] is found
  60. ;parsing section [loader]
  61. ;first found end section,let's found '[' -it's start next section
  62. ;in previosly steep bx =cx we are not need save cx, save only di - point
  63.         mov     dx,di
  64. @@:
  65.         call    get_firs_sym
  66.         jcxz    .loader_f_end ;.end_loader         ; end äàæå åñëè ìû íå íàøëè ñåêöèþ ïðåäïîëîæèì ÷òî ñåêöèÿ [loader] ñòîèò â êîíöå
  67.         cmp     al,'['
  68.         jnz     @b
  69.  
  70. .loader_f_end:
  71.         sub     bx,cx   ;bx = n byte presend in section [loader]
  72.         mov     di,dx   ;restore di
  73. ;////////////////parse parametrs in section [loader]
  74. ;//timeout=5
  75. ;//default=main
  76. ;        mov    di,dx   ;set pointer on section [loader]   i think it's not need
  77.         mov     cx,bx   ;set counter for parsing section [loader] cx= êîë-âó ñèìâîëîâ â ñåêöèè [loader]
  78.         mov     ret_on_ch,.get_next_str ; return point
  79. ;;;;;;; parse timeout & default
  80. .get_next_str:
  81.         call    get_firs_sym    ;get first symbol on new line
  82.  
  83.         test    cx,cx
  84.         jz      .end_loader
  85. ;        jcxz   .end_loader     ;çàâåðøåíèå ïàðñèíãà çíà÷åíèé timeout & default
  86.         cmp     al,'t'
  87.         jz      .loader_timeout
  88.         cmp     al,'d'
  89.         jnz     .get_next_str
  90. ;//////[loader].default
  91. ;input di point to data cx=size [loader]
  92.         mov     bx,cx
  93.         mov     ax,di
  94.  
  95.         mov     si,parse_l_default
  96.         mov     cx,parse_l_default_e - parse_l_default
  97.         repe    cmpsb
  98.  
  99.         jnz     error.rest_value      ;is not compare öåïî÷êà íå ñîâïàëà
  100.  
  101.         sub     bx,parse_l_default_e - parse_l_default ;correct cx
  102.         add     bx,cx
  103.         mov     cx,bx
  104.  
  105.         test    status_flag,flag_found_default
  106.         jz      .correct_is_not_set          
  107.  
  108.         mov     si,found_equal_default                          ;ìû íàøëè ÷òî ôëàã óæå óñòàíîâëåí, èíôîðìèðóåì
  109.         call    printplain
  110.         jmp     .get_next_str
  111.  
  112. .correct_is_not_set:
  113.         mov     ax,0x3d20          ;cut al=' ' ah='='
  114.         repe    scasb
  115.         test    cx,cx
  116.         jz      .end_loader
  117.        
  118.         cmp     ah,byte [es:di-1]    ;find '='
  119.         jnz     .get_next_str
  120.        
  121.         repe    scasb              ;cut ' '
  122.         inc     cx
  123.         dec     di
  124. ;ñåé÷àñ es:di óêàçûâàþò íà íàçâàíèå ñåêöèè, èìÿ ñåêöèè ïî äåôîëòó íå äîëæíî áûòü loader ò.å. èíà÷å âîçìîæíî çàöèêëèâàíèå
  125. ;óñòàíîâèì óêàçàòåëü si íà ýòî çíà÷åíèå è ñíà÷àëà ïðîâåðèì
  126.  
  127. ;ïîëó÷åíèå äëèííû ñåêöèè
  128. ; cx=bx ñîäåðæèò äëèííó îñòàòêà ñåêöèè
  129. ; di=ax óêàçàòåëü íà òåêóùèþ ñåêöèþ
  130.         mov     bx,cx
  131.         mov     dx,di
  132.  
  133. @@:     mov     al,byte [es:di]
  134.         inc     di
  135.         dec     cx
  136.         test    cx,cx
  137.         jz      error.error_get_size_d_sect  ;ïåðåõîä íà îáðàáîòêó îøèáêè ïî íàõîæäåíèþ äëèíû äåôîëòíîé ñåêöèè
  138.         cmp     al,' '
  139.         jz      @b
  140.         cmp     al,0xd
  141.         jz      .found_size_d_sect
  142.         cmp     al,0xa
  143.         jnz     @b
  144. .found_size_d_sect:
  145. ;
  146.         inc     cx      ;correct cx
  147.         mov     ax,bx
  148.         sub     bx,cx   ; â bx äëèíà ñåêöèè êîòîðàÿ îïðåäåëåíà ïî äåôîëòó
  149.         mov     save_cx_d,bx
  150.         mov     di,dx
  151.  
  152.         mov     cx,bx   ;set size default section
  153. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ïðîâåðêà íà =loader
  154. ;save in reg point and ñ÷åò÷èê
  155. ;check on loader
  156.         mov     bx,ax
  157.         mov     ax,dx
  158.  
  159.         mov     si,parse_loader
  160.         inc     si      ;set only loader and 6 char in counter
  161.         repe    cmpsb
  162.         jnz     .check_section        ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå )) çíà÷èò íå èñêëþ÷åíèå
  163.  
  164.         jmp     error.default_eq_loader    ;error êðèòè÷åñêàÿ îøèáêà ò.å. â äåôîëòå ïðèñóòñòâóåò èìÿ [loader]
  165.  
  166. .check_section:         ;ïîèñê ñîîòâåòñòâóþùåé ñåêöèè íàì íóæíî áóäåò óçíàòü àäðåñ ýòîé ñåêöèè
  167.         mov     cx,bx
  168.         mov     di,ax
  169.  
  170. ;/////////////////////////////
  171. ;       mov     ret_on_ch,.start_d     ;set return
  172.         mov     si,di   ;óñòàíîâèì óêàçàòåëü íà íàøó ñåêöèþ, êîòîðàÿ ïî äåôîëòó
  173.  
  174.         push    di      ;save point di
  175.  
  176.         push    cx      ;save cx
  177. ;óñòàíîâèì óêàçàòåëü es:di íà íà÷àëî ini ôàéëà
  178.         mov     cx,save_cx      ;it's placed size of ini file
  179.         les     di,dword [file_data]
  180.  
  181.  
  182.         mov     al,byte [es:di]
  183.         push    word .first_ret_d
  184.         cmp     al,' '
  185.         jz      .first_sp_1_d
  186.         jmp     get_firs_sym.not_space
  187. .first_sp_1_d:
  188.         jmp     get_firs_sym.first_sp
  189.  
  190. .start_d:
  191.         call    get_firs_sym    ;get first symbol on new line
  192. .first_ret_d:                     ;ïåðâûé âîçâðàò
  193.         jcxz    .correct_exit   ;.end_loader     ;found or not found parametrs in section  exit in section
  194.         cmp     al,'['
  195.         jz      .found_sect_d
  196.         jmp     .start_d
  197. ;ïðîñìàòðèâàåì ini ôàéë ñ íà÷àëà â ïîèñêàõ ñåêöèè óêàçàíîé êàê default
  198. ;èäåò ïðîâåðêà íà íàëè÷åå çíà÷åíèÿ timeout, äëÿ áîëåå áûñòðîé ðàáîòû, ýòîò ïàðàìåòð äîëæåí áûòü óæå îáðàáîòàí,ò.å. â ýòîì ñëó÷àå ïðè åãî =0 áóäåò ñôîðìèðîâàí óêàçàòåëü òîëüêî íà äåôîëòíóþ ñåêöèþ, èíà÷å èíôîðìàöèÿ áóäåò ñîáðàíà ïî âñåì ñåêöèÿì è ñîñòàâëåíû óêàçàòåëè â áëîêå ïàìÿòè       
  199. .found_sect_d:
  200.  
  201. ;check on name section
  202.         mov     bx,cx
  203.         mov     ax,di
  204.         push    si      ;save point
  205.        
  206. ;        mov     si,parse_loader
  207.         mov     cx,save_cx_d ;load size section
  208.         push    es
  209.         pop     ds     
  210.  
  211.         inc     di
  212.         repe    cmpsb
  213.         push    cs
  214.         pop     ds
  215.         pop     si
  216.  
  217.         jnz     .not_compare_d_s        ;öåïî÷êà íå ñîâïàëà :( ïåðåéäåì äàëåå )) çíà÷èò íå èñêëþ÷åíèå
  218.         cmp     byte[es:di],']'
  219.         jnz     .not_compare_d_s        ;íåò â êîíöå íàøåé ñåêöèè çàâåðøàþùåãî ñèìâîëà :(
  220.  
  221.  
  222.  
  223. ;set flag -we have found default -not enter again in this prosedure
  224.         or      status_flag,flag_found_default
  225.         pop     cx
  226.         pop     di
  227.         mov     point_default,ax        ;point to [
  228.  
  229. if DEBUG        
  230.         pusha
  231.         mov     si,lm_lf_default_f
  232.         call    printplain
  233.         popa
  234. end if  
  235.        
  236.         jmp     .get_next_str
  237.  
  238. .not_compare_d_s:
  239.  
  240.         mov     cx,bx
  241.         mov     di,ax
  242.         jmp     .start_d       
  243.  
  244. .correct_exit:
  245.         pop     cx ;âîññòàíîâèì çíà÷åíèå ñ÷åò÷èêà
  246.         pop     di
  247.  
  248.  
  249. if DEBUG        
  250.         pusha
  251.         mov     si,lm_lf_default
  252.         call    printplain
  253.         popa
  254. end if  
  255.         jmp     .get_next_str
  256.  
  257. ;//////////[loader].timeout
  258. .loader_timeout:
  259.         mov     bx,cx
  260.         mov     ax,di
  261.  
  262.         mov     si,parse_l_timeout
  263.         mov     cx,parse_l_timeout_e - parse_l_timeout
  264.         repe    cmpsb
  265.         jnz     error.rest_value           ;is not compare
  266.  
  267.         sub     bx,parse_l_timeout_e - parse_l_timeout ;correct cx
  268.         add     bx,cx
  269.         mov     cx,bx
  270.  
  271.         test    status_flag,flag_found_timeout
  272.         jz      .correct_is_not_set_t          
  273.  
  274.         mov     si,found_equal_timeout                          ;ìû íàøëè ÷òî ôëàã óæå óñòàíîâëåí, èíôîðìèðóåì
  275.         call    printplain
  276.         jmp     .get_next_str
  277.  
  278. .correct_is_not_set_t:
  279.         mov     ax,0x3d20          ;cut al=' ' ah='='
  280.         repe    scasb
  281.         jcxz    .timeout_sec_end_d          ;not found param timeout
  282.        
  283.         cmp     ah,byte [es:di-1]    ;find '='
  284.         jnz     .get_next_str
  285.        
  286.         repe    scasb              ;cut ' '
  287.         inc     cx
  288.         dec     di
  289. ;get timeout value
  290. ;2 çíàêa ìîæåò áûòü îáðàáîòàíî ò.å. çíà÷åíèå îò 0 äî 99 ñåêóíä
  291.         push    cx
  292.         xor     bx,bx
  293.         mov     cx,2
  294. @@:     mov     al,byte [es:di]
  295.         cmp     al,'0'
  296.         jb      .end_get_val_t
  297.         cmp     al,'9'
  298.         ja      .end_get_val_t
  299.         imul    bx,10
  300.         xor     al,0x30
  301.         add     bl,al
  302. .end_get_val_t:
  303.         inc     di
  304.         loop    @b
  305.         mov     word [value_timeout],bx
  306. ;       pop     cx
  307.  
  308. if DEBUG        
  309.         pusha
  310.         mov     si,lm_lf_timeout
  311.         call    printplain
  312.         popa
  313. end if  
  314.  
  315.         jmp     @f
  316. .timeout_sec_end_d:
  317.         mov     word [value_timeout],default_timeout_value
  318.         mov     si,set_default_timeout_val
  319.         call    printplain
  320. @@:     pop     cx
  321.         jmp     .get_next_str
  322.  
  323. ;///////here end block loader
  324. .end_loader:
  325. if DEBUG        
  326.         pusha
  327.         mov     si,lm_l_end
  328.         call    printplain
  329.         popa
  330. end if  
  331.  
  332. }