2010-10-01 11:21:55 +02:00
|
|
|
|
; Copyright (c) 2009, <Lrz>
|
|
|
|
|
; All rights reserved.
|
|
|
|
|
;
|
|
|
|
|
; Redistribution and use in source and binary forms, with or without
|
|
|
|
|
; modification, are permitted provided that the following conditions are met:
|
|
|
|
|
; * Redistributions of source code must retain the above copyright
|
|
|
|
|
; notice, this list of conditions and the following disclaimer.
|
|
|
|
|
; * Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
; notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
; documentation and/or other materials provided with the distribution.
|
|
|
|
|
; * Neither the name of the <organization> nor the
|
|
|
|
|
; names of its contributors may be used to endorse or promote products
|
|
|
|
|
; derived from this software without specific prior written permission.
|
|
|
|
|
;
|
|
|
|
|
; THIS SOFTWARE IS PROVIDED BY Alexey Teplov nickname <Lrz> ''AS IS'' AND ANY
|
|
|
|
|
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
|
|
|
|
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
;*****************************************************************************
|
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;блок макросов по обработке секции [loader]
|
|
|
|
|
;входные данные:
|
|
|
|
|
;es:di - указатель на секцию начинающиюся с '[' встечающиюся после 0хa
|
|
|
|
|
;cx - счетчик кол-во байт для проверке в кадре
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;
|
|
|
|
|
macro use_parse_loader
|
|
|
|
|
{
|
|
|
|
|
.parse_loader:
|
|
|
|
|
;//////////////////
|
|
|
|
|
;/ parse [loader]
|
|
|
|
|
;//////////////////
|
2013-05-28 21:09:31 +02:00
|
|
|
|
mov bx, cx ;cохраним в регистры значения счетчика и указателя
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ax, di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
; mov word [bp-4],.start ;is alredy set, see up
|
|
|
|
|
mov si, parse_loader
|
|
|
|
|
mov cx, parse_loader_e - parse_loader
|
|
|
|
|
repe cmpsb
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz error.rest_value ;цепочка не совпала :( перейдем далее т.е. будем снова искать))
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;сохраним указательна loader, что бы потом больше его не искать
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov point_loader, ax
|
|
|
|
|
sub bx, parse_loader_e - parse_loader;correct cx
|
|
|
|
|
add bx, cx
|
|
|
|
|
mov cx, bx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, lm_l_found
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
end if
|
|
|
|
|
;/////////////////end check [loader]. [loader] is found
|
|
|
|
|
;parsing section [loader]
|
|
|
|
|
;first found end section,let's found '[' -it's start next section
|
|
|
|
|
;in previosly steep bx =cx we are not need save cx, save only di - point
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov dx, di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
@@:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call get_firs_sym
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jcxz .loader_f_end ;.end_loader ; end даже если мы не нашли секцию предположим что секция [loader] стоит в конце
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp al, '['
|
|
|
|
|
jnz @b
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.loader_f_end:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
sub bx, cx ;bx = n byte presend in section [loader]
|
|
|
|
|
mov di, dx ;restore di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;////////////////parse parametrs in section [loader]
|
|
|
|
|
;//timeout=5
|
|
|
|
|
;//default=main
|
2012-03-08 09:33:38 +01:00
|
|
|
|
; mov di,dx ;set pointer on section [loader] i think it's not need
|
2013-05-28 21:09:31 +02:00
|
|
|
|
mov cx, bx ;set counter for parsing section [loader] cx= кол-ву символов в секции [loader]
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ret_on_ch, .get_next_str; return point
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;;;;;;; parse timeout & default
|
|
|
|
|
.get_next_str:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call get_firs_sym ;get first symbol on new line
|
|
|
|
|
|
|
|
|
|
test cx, cx
|
|
|
|
|
jz .end_loader
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; jcxz .end_loader ;завершение парсинга значений timeout & default
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp al, 't'
|
|
|
|
|
jz .loader_timeout
|
|
|
|
|
cmp al, 'd'
|
|
|
|
|
jnz .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;//////[loader].default
|
|
|
|
|
;input di point to data cx=size [loader]
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov bx, cx
|
|
|
|
|
mov ax, di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, parse_l_default
|
|
|
|
|
mov cx, parse_l_default_e - parse_l_default
|
|
|
|
|
repe cmpsb
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz error.rest_value ;is not compare цепочка не совпала
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
sub bx, parse_l_default_e - parse_l_default;correct cx
|
|
|
|
|
add bx, cx
|
|
|
|
|
mov cx, bx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
test status_flag, flag_found_default
|
|
|
|
|
jz .correct_is_not_set
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
mov si, found_equal_default ;мы нашли что флаг уже установлен, информируем
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call printplain
|
|
|
|
|
jmp .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.correct_is_not_set:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ax, 0x3d20 ;cut al=' ' ah='='
|
|
|
|
|
repe scasb
|
|
|
|
|
test cx, cx
|
|
|
|
|
jz .end_loader
|
|
|
|
|
|
|
|
|
|
cmp ah, byte [es:di-1] ;find '='
|
|
|
|
|
jnz .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
repe scasb ;cut ' '
|
|
|
|
|
inc cx
|
|
|
|
|
dec di
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;сейчас es:di указывают на название секции, имя секции по дефолту не должно быть loader т.е. иначе возможно зацикливание
|
|
|
|
|
;установим указатель si на это значение и сначала проверим
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;получение длинны секции
|
|
|
|
|
; cx=bx содержит длинну остатка секции
|
|
|
|
|
; di=ax указатель на текущию секцию
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov bx, cx
|
|
|
|
|
mov dx, di
|
|
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
mov al, byte [es:di]
|
|
|
|
|
inc di
|
|
|
|
|
dec cx
|
|
|
|
|
test cx, cx
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jz error.error_get_size_d_sect ;переход на обработку ошибки по нахождению длины дефолтной секции
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp al, ' '
|
|
|
|
|
jz @b
|
|
|
|
|
cmp al, 0xd
|
|
|
|
|
jz .found_size_d_sect
|
|
|
|
|
cmp al, 0xa
|
|
|
|
|
jnz @b
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.found_size_d_sect:
|
|
|
|
|
;
|
2012-03-08 09:33:38 +01:00
|
|
|
|
inc cx ;correct cx
|
|
|
|
|
mov ax, bx
|
2013-05-28 21:09:31 +02:00
|
|
|
|
sub bx, cx ; в bx длина секции которая определена по дефолту
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov save_cx_d, bx
|
|
|
|
|
mov di, dx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov cx, bx ;set size default section
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;проверка на =loader
|
|
|
|
|
;save in reg point and счетчик
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;check on loader
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov bx, ax
|
|
|
|
|
mov ax, dx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, parse_loader
|
|
|
|
|
inc si ;set only loader and 6 char in counter
|
|
|
|
|
repe cmpsb
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz .check_section ;цепочка не совпала :( перейдем далее )) значит не исключение
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jmp error.default_eq_loader ;error критическая ошибка т.е. в дефолте присутствует имя [loader]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
.check_section: ;поиск соответствующей секции нам нужно будет узнать адрес этой секции
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov cx, bx
|
|
|
|
|
mov di, ax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
;/////////////////////////////
|
2012-03-08 09:33:38 +01:00
|
|
|
|
; mov ret_on_ch,.start_d ;set return
|
2013-05-28 21:09:31 +02:00
|
|
|
|
mov si, di ;установим указатель на нашу секцию, которая по дефолту
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push di ;save point di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push cx ;save cx
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;установим указатель es:di на начало ini файла
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov cx, save_cx ;it's placed size of ini file
|
|
|
|
|
les di, dword [file_data]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, byte [es:di]
|
|
|
|
|
push word .first_ret_d
|
|
|
|
|
cmp al, ' '
|
|
|
|
|
jz .first_sp_1_d
|
|
|
|
|
jmp get_firs_sym.not_space
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.first_sp_1_d:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jmp get_firs_sym.first_sp
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.start_d:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call get_firs_sym ;get first symbol on new line
|
2013-05-28 21:09:31 +02:00
|
|
|
|
.first_ret_d: ;первый возврат
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jcxz .correct_exit ;.end_loader ;found or not found parametrs in section exit in section
|
|
|
|
|
cmp al, '['
|
|
|
|
|
jz .found_sect_d
|
|
|
|
|
jmp .start_d
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;просматриваем ini файл с начала в поисках секции указаной как default
|
|
|
|
|
;идет проверка на наличее значения timeout, для более быстрой работы, этот параметр должен быть уже обработан,т.е. в этом случае при его =0 будет сформирован указатель только на дефолтную секцию, иначе информация будет собрана по всем секциям и составлены указатели в блоке памяти
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.found_sect_d:
|
|
|
|
|
|
|
|
|
|
;check on name section
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov bx, cx
|
|
|
|
|
mov ax, di
|
|
|
|
|
push si ;save point
|
|
|
|
|
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; mov si,parse_loader
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov cx, save_cx_d;load size section
|
|
|
|
|
push es
|
|
|
|
|
pop ds
|
|
|
|
|
|
|
|
|
|
inc di
|
|
|
|
|
repe cmpsb
|
|
|
|
|
push cs
|
|
|
|
|
pop ds
|
|
|
|
|
pop si
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz .not_compare_d_s ;цепочка не совпала :( перейдем далее )) значит не исключение
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp byte[es:di], ']'
|
2013-05-28 21:09:31 +02:00
|
|
|
|
jnz .not_compare_d_s ;нет в конце нашей секции завершающего символа :(
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;set flag -we have found default -not enter again in this prosedure
|
2012-03-08 09:33:38 +01:00
|
|
|
|
or status_flag, flag_found_default
|
|
|
|
|
pop cx
|
|
|
|
|
pop di
|
|
|
|
|
mov point_default, ax ;point to [
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, lm_lf_default_f
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
|
|
|
|
|
|
jmp .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.not_compare_d_s:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov cx, bx
|
|
|
|
|
mov di, ax
|
|
|
|
|
jmp .start_d
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.correct_exit:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
pop cx ;восстановим значение счетчика
|
2012-03-08 09:33:38 +01:00
|
|
|
|
pop di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if DEBUG
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, lm_lf_default
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
end if
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jmp .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
;//////////[loader].timeout
|
|
|
|
|
.loader_timeout:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov bx, cx
|
|
|
|
|
mov ax, di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, parse_l_timeout
|
|
|
|
|
mov cx, parse_l_timeout_e - parse_l_timeout
|
|
|
|
|
repe cmpsb
|
|
|
|
|
jnz error.rest_value ;is not compare
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
sub bx, parse_l_timeout_e - parse_l_timeout;correct cx
|
|
|
|
|
add bx, cx
|
|
|
|
|
mov cx, bx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
test status_flag, flag_found_timeout
|
|
|
|
|
jz .correct_is_not_set_t
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2013-05-28 21:09:31 +02:00
|
|
|
|
mov si, found_equal_timeout ;мы нашли что флаг уже установлен, информируем
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call printplain
|
|
|
|
|
jmp .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.correct_is_not_set_t:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ax, 0x3d20 ;cut al=' ' ah='='
|
|
|
|
|
repe scasb
|
|
|
|
|
jcxz .timeout_sec_end_d ;not found param timeout
|
|
|
|
|
|
|
|
|
|
cmp ah, byte [es:di-1] ;find '='
|
|
|
|
|
jnz .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
repe scasb ;cut ' '
|
|
|
|
|
inc cx
|
|
|
|
|
dec di
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;get timeout value
|
2013-05-28 21:09:31 +02:00
|
|
|
|
;2 знакa может быть обработано т.е. значение от 0 до 99 секунд
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push cx
|
|
|
|
|
xor bx, bx
|
|
|
|
|
mov cx, 2
|
|
|
|
|
@@:
|
|
|
|
|
mov al, byte [es:di]
|
|
|
|
|
cmp al, '0'
|
|
|
|
|
jb .end_get_val_t
|
|
|
|
|
cmp al, '9'
|
|
|
|
|
ja .end_get_val_t
|
|
|
|
|
imul bx, 10
|
|
|
|
|
xor al, 0x30
|
|
|
|
|
add bl, al
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.end_get_val_t:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
inc di
|
|
|
|
|
loop @b
|
|
|
|
|
mov word [value_timeout], bx
|
|
|
|
|
; pop cx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
if DEBUG
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, lm_lf_timeout
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
end if
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jmp @f
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.timeout_sec_end_d:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov word [value_timeout], default_timeout_value
|
|
|
|
|
mov si, set_default_timeout_val
|
|
|
|
|
call printplain
|
|
|
|
|
@@:
|
|
|
|
|
pop cx
|
|
|
|
|
jmp .get_next_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
;///////here end block loader
|
|
|
|
|
.end_loader:
|
|
|
|
|
if DEBUG
|
|
|
|
|
pusha
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov si, lm_l_end
|
2010-10-01 11:21:55 +02:00
|
|
|
|
call printplain
|
|
|
|
|
popa
|
|
|
|
|
end if
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
}
|