Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ;   LAUNCHER - €‚’Ž‡€“‘Š Žƒ€ŒŒ
  3. ;     Š®¤ ¯à®£à ¬¬ë ᮢᥬ ­¥ ®¯â¨¬¨§¨à®¢ ­, ­® ®ç¥­ì ¯à®áâ ¤«ï ¯®­¨¬ ­¨ï.
  4. ;     â®â « ã­ç¥à £à㧨⠨­ä®à¬ æ¨î ® ¯à®£à ¬¬ å ¤«ï § ¯ã᪠ ¨§ ä ©« 
  5. ;     AUTORUN.DAT. ”®à¬ â ®ç¥­ì ¯à®áâ ¨ ¢ ª®¬¬¥­â à¨ïå ­¥ ­ã¦¤ ¥âáï.
  6. ;
  7. ;   Š®¬¯¨«¨àã©â¥ á ¯®¬®éìî FASM 1.52 ¨ ¢ëè¥
  8. ;
  9. include "../../../macros.inc"
  10.  
  11.   use32
  12.   org    0x0
  13.   db     'MENUET01'              ; 8 byte id
  14.   dd     0x01                    ; header version
  15.   dd     START                   ; start of code
  16.   dd     I_END                   ; size of image
  17.   dd     0x8000                 ; memory for app
  18.   dd     0x8000                 ; esp
  19.   dd     0x0 , 0x0               ; I_Param , I_Icon
  20.  
  21. ;include "DEBUG.INC"
  22.  
  23. START:                           ; start of execution
  24.  
  25. ;   mov  eax, 5
  26. ;   mov  ebx, 10
  27. ;   mcall
  28.  
  29. ;   mcall 18,15
  30.  
  31.    mov  eax, 70               ; load AUTORUN.DAT
  32.    mov  ebx, autorun_dat_info
  33.    mcall
  34.    add  ebx, file_data
  35.    mov  [fileend], ebx
  36.  
  37. ; this cycle does not contain an obvious exit condition,
  38. ; but auxiliary procedures (like "get_string") will exit
  39. ; at EOF
  40.  start_program:
  41.    call skip_spaces
  42.    cmp  al,'#'
  43.    jz   skip_this_string
  44.    call clear_strings
  45.    mov  edi, program
  46.    call get_string
  47.    mov  edi, parameters
  48.    call get_string
  49.    call get_number
  50. ;dps <"STARTING A PROGRAM",13,10>
  51.    call run_program
  52.  skip_this_string:
  53.    call next_line
  54.    jmp  start_program
  55.  
  56.  exit:
  57.    or   eax, -1
  58.    mcall
  59.  
  60.  
  61.  run_program:     ; time to delay in eax
  62.    push eax
  63.    mcall 70, start_info
  64.    pop  ebx
  65.  
  66. ; if delay is negative, wait for termination
  67. ;   of the spawned process
  68.    test ebx, ebx
  69.    js   must_wait_for_termination
  70. ; otherwise, simply wait
  71.    mov  eax, 5
  72.    mcall
  73.    ret
  74.  must_wait_for_termination:
  75.    mov  esi, eax  ; save slot for the future
  76. ; get process slot
  77.    mov  ecx, eax
  78.    mcall 18, 21
  79. ; if an error has occured, exit
  80.    test eax, eax
  81.    jz   child_exited
  82.    mov  ecx, eax
  83. ; wait
  84.  wait_for_termination:
  85.    mcall 5, 1
  86.    mov  ebx, processinfo
  87.    mcall 9
  88.    cmp  word [ebx+50], 9 ; the slot was freed?
  89.    jz   child_exited
  90.    cmp  dword [ebx+30], esi ; the slot is still occupied by our child?
  91.    jz   wait_for_termination
  92.  child_exited:
  93.    ret
  94.  
  95.  clear_strings:   ; clears buffers
  96.    pushad
  97.  
  98.    mov  ecx, 60
  99.    mov  edi, program
  100.    xor  al, al ;mov  al, ' '
  101.    rep  stosb
  102.  
  103.    mov  ecx, 60
  104.    mov  edi, parameters
  105.    rep  stosb
  106.  
  107.    popad
  108.  ret
  109.  
  110.  
  111.  get_string: ; pointer to destination buffer in edi
  112.    pushad
  113.    call skip_spaces
  114.    mov  esi, [position]
  115. ;dpd esi
  116. ;dps <13,10>
  117.    add  esi, file_data
  118.    cmp  byte [esi], '"'
  119.    jz   .quoted
  120.   .start:
  121.    cmp  esi, [fileend]
  122.    jae  exit
  123.    lodsb
  124.    cmp  al, ' '
  125.    jbe  .finish
  126.    stosb
  127.    inc  [position]
  128.    jmp  .start
  129.   .finish:
  130.    popad
  131.    ret
  132.   .quoted:
  133.    inc  esi
  134.    inc  [position]
  135.   .quoted.start:
  136.    cmp  esi, [fileend]
  137.    jae  exit
  138.    lodsb
  139.    inc  [position]
  140.    cmp  al, '"'
  141.    je   .finish
  142.    stosb
  143.    jmp  .quoted.start
  144.  
  145.  
  146.  get_number:
  147.    push ebx esi
  148.    call skip_spaces
  149.    mov  esi, [position]
  150.    add  esi, file_data
  151.    xor  eax, eax
  152.    cmp  byte [esi], '-'
  153.    jnz  @f
  154.    inc  eax
  155.    inc  esi
  156.    inc  [position]
  157. @@:
  158.    push eax
  159.    xor  eax, eax
  160.    xor  ebx, ebx
  161.   .start:
  162.    cmp  esi, [fileend]
  163.    jae  .finish
  164.    lodsb
  165.    sub  al, '0'
  166.    cmp  al, 9
  167.    ja   .finish
  168.    lea  ebx,[ebx*4+ebx]
  169.    lea  ebx,[ebx*2+eax]
  170.    inc  [position]
  171.    jmp  .start
  172.   .finish:
  173.    pop  eax
  174.    dec  eax
  175.    jnz  @f
  176.    neg  ebx
  177. @@:
  178.    mov  eax, ebx
  179.    pop  esi ebx
  180.  ret
  181.  
  182.  
  183.  skip_spaces:
  184.    push esi
  185.    xor  eax, eax
  186.    mov  esi, [position]
  187.    add  esi, file_data
  188.   .start:
  189.    cmp  esi, [fileend]
  190.    jae  .finish
  191.    lodsb
  192.    cmp  al, ' '
  193.    ja   .finish
  194.    inc  [position]
  195.    jmp  .start
  196.   .finish:
  197. ;dps "NOW AL = "
  198. ;mov [tmp],al
  199. ;mov edx, tmp
  200. ;call debug_outstr
  201. ;dps <13,10>
  202.    pop  esi
  203.  ret
  204.  
  205.  
  206.  next_line:
  207.    mov  esi, [position]
  208.    add  esi, file_data
  209.   .start:
  210.    cmp  esi, [fileend]
  211.    jae  exit
  212.    lodsb
  213.    cmp  al, 13
  214.    je   .finish
  215.    cmp  al, 10
  216.    je   .finish
  217.    inc  [position]
  218.    jmp  .start
  219.   .finish:
  220.    inc  [position]
  221.    cmp  esi, [fileend]
  222.    jae  exit
  223.    lodsb
  224.    cmp  al, 13
  225.    je   .finish
  226.    cmp  al, 10
  227.    je   .finish
  228.    ret
  229.  
  230.  
  231.  
  232. ; DATA:
  233.  position          dd 0            ; position in file
  234.  
  235.  autorun_dat_info:                 ; AUTORUN.DAT
  236.    .mode           dd 0            ; read file
  237.    .start_block    dd 0            ; block to read
  238.                    dd 0
  239.    .blocks         dd 16*512       ; 16*512 bytes max
  240.    .address        dd file_data
  241.    db "AUTORUN.DAT",0
  242.  
  243.  start_info:
  244.    .mode           dd 7
  245.                    dd 0
  246.    .params         dd parameters
  247.                    dd 0
  248.                    dd 0
  249.    .path: ;      
  250.  
  251. I_END:
  252.  
  253.  program           rb 61 ; 60 + [0] char
  254.  parameters        rb 61
  255.  
  256.  processinfo       rb 1024
  257.  fileend           dd ?
  258.  
  259.  file_data         rb 16*512
  260.