Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.         use32
  2.  
  3. open:   cmp     edx,input_magic
  4.         jne     fail
  5.         mov     ebx,[edx]
  6.         ret
  7.  
  8. close:  cmp     ebx,[input_magic]
  9.         jne     fail
  10.         xor     ebx,ebx         ;CF=0
  11.         ret
  12.  
  13. lseek:  cmp     ebx,[input_magic]
  14.         jne     fail
  15.  
  16.         cmp     al,2
  17.         je      .end
  18.         cmp     al,1
  19.         je      .pos
  20.         cmp     al,0
  21.         jne     fail
  22.  
  23.       .str:
  24.         mov     eax,edx
  25.         cmp     eax,[input_size]
  26.         ja      fail
  27.         jmp     .ok
  28.  
  29.       .end:
  30.         mov     eax,[input_size]
  31.         neg     edx
  32.         add     eax,edx
  33.         jc      fail
  34.       .ok:
  35.         mov     [input_start],eax
  36.         clc
  37.         ret
  38.  
  39.       .pos:
  40.         mov     eax,[input_start]
  41.         add     eax,edx
  42.         cmp     eax,[input_size]
  43.         ja      fail
  44.         jmp     .ok
  45.  
  46. read:   cmp     ebx,[input_magic]
  47.         jne     fail
  48.         push    esi edi
  49.         mov     esi,[input_start]
  50.         add     esi,[input_code]
  51.         mov     eax,[input_size]
  52.         mov     edi,edx
  53.         cmp     eax,ecx
  54.         jnc     skip
  55.         mov     ecx,eax
  56. skip:   mov     eax,ecx
  57.         add     [input_start],eax
  58.         shr     ecx,2
  59.         cld
  60.         rep     movsd
  61.         mov     cl,al
  62.         and     cl,3
  63.         rep     movsb
  64.         pop     edi esi
  65.         clc
  66.         ret
  67.  
  68. write:  ;not implemented
  69. create: ;not implemented
  70.  
  71. fail:   stc
  72.         ret
  73.  
  74. make_timestamp:
  75.         xor     eax,eax         ;not implemented
  76. get_environment_variable:       ;not implemented
  77. display_block:                  ;not implemented
  78.         ret
  79.  
  80. assembler_error: fatal_error:
  81.         pop     [output_errs]
  82.         stc
  83.         jmp     stack_restore
  84.  
  85. Assemble:
  86.         xor     eax,eax
  87.         mov     [output_errs],eax
  88.         mov     [output_size],eax
  89.         mov     [input_start],eax
  90.  
  91.         mov     [input_file],input_magic
  92.         mov     [input_size],ecx
  93.         mov     [input_code],esi
  94.         mov     [input_stack],esp
  95.  
  96.         mov     [memory_start],StdMemStr
  97.         mov     [memory_end],StdMemEnd
  98.         mov     [additional_memory],AddMemStr
  99.         mov     [additional_memory_end],AddMemEnd
  100.  
  101.         lea     eax,[esp-4*1024]
  102.         mov     [stack_limit],eax
  103.  
  104.         call    preprocessor
  105.         call    parser
  106.         call    assembler
  107.  
  108.         mov     esi,[code_start]
  109.         mov     ecx,edi
  110.         sub     ecx,esi
  111.  
  112.         mov     eax,256
  113.         cmp     ecx,eax
  114.         jna     max_256
  115.         mov     ecx,eax
  116.       max_256:
  117.  
  118.         mov     [output_size],ecx
  119.         mov     edi,output_data
  120.         rep     movsb
  121.  
  122.      stack_restore:
  123.  
  124.         mov     esp,[input_stack]
  125.         mov     esi,[output_errs]
  126.         ret
  127.  
  128. include 'fasm\version.inc'
  129. include 'fasm\errors.inc'
  130. include 'fasm\symbdump.inc'
  131. include 'fasm\preproce.inc'
  132. include 'fasm\parser.inc'
  133. include 'fasm\exprpars.inc'
  134. include 'fasm\assemble.inc'
  135. include 'fasm\exprcalc.inc'
  136. include 'fasm\formats.inc'
  137. include 'fasm\x86_64.inc'
  138. include 'fasm\avx.inc'
  139.  
  140. include 'fasm\tables.inc'
  141. include 'fasm\messages.inc'
  142.  
  143. iglobal
  144. input_magic     dd 55AA55AAh
  145. endg
  146. uglobal
  147. input_code      dd ?
  148. input_size      dd ?
  149. input_start     dd ?
  150. input_stack     dd ?
  151. output_size     dd ?
  152. output_errs     dd ?
  153. output_data     rb 256
  154. include 'fasm\variable.inc'
  155. endg
  156.