;; пример файла макросов для дизассемблера DeWin
;; Copyright 1998, Milukov Alexander
;;

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,[
mov     si,[
mov     di,[
call    far ptr 
push    dx
push    bx
push    ax
;; рассматриваем строки относительно левого края
<base>48
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
push ( <mid 0,11,0> <mid 6,16,0> <mid 3,11,0> )

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,[
mov     si,[
mov     di,[
call    far ptr 
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
<mid 0,11,0> <mid 6,16,0> <mid 3,11,0>

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,<xdigit>
mov     si,<xdigit>
mov     di,<xdigit>
call    far ptr 
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
<mid 0,11,0> <mid 6,16,0> <real <mid 3,11,0>, <mid 4,11,0>, <mid 5,11,0>>

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,<xdigit>
xor     si,si
mov     di,<xdigit>
call    far ptr 
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
<mid 0,11,0> <mid 6,16,0> <real <mid 3,11,0>, 0, <mid 5,11,0>>

<find>
mov     cx,<xdigit>
xor     si,si
mov     di,<xdigit>
call    far ptr 
<repl>
;; proc_name     2nd arg
<mid 3,16,0> <real <mid 0,11,0>, 0, <mid 2,11,0>>

<find>
mov     ax,[bp
mov     bx,[bp
mov     dx,[bp
xor     cx,cx
xor     si,si
xor     di,di
call    far ptr _compReal
<repl>
;; 1st arg     proc_name     2nd arg
<mid 0,11,0> <mid 6,16,0> <real 0, 0, 0>

<find>
xor     cx,cx
xor     si,si
xor     di,di
call    far ptr _compReal
<repl>
;; proc_name     2nd arg
<mid 3,16,0> <real 0, 0, 0>

<find>
les     di,dword ptr [bp
mov     ax,es:[di
mov     bx,es:[di
mov     dx,es:[di
mov     cx,[
mov     si,[
mov     di,[
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;; 1st arg                   proc_name     2nd arg         двухместная операция
push ( *[<mid 0,11,0>]<mid 1,17,']'> <mid 7,16,0> <mid 4,11,0> )

<find>
les     di,dword ptr [bp
mov     ax,es:[di
mov     bx,es:[di
mov     dx,es:[di
mov     cx,[
mov     si,[
mov     di,[
call    far ptr 
<repl>
;; 1st arg                   proc_name     2nd arg         двухместная операция
*[<mid 0,11,0>]<mid 1,17,']'> <mid 7,16,0> <mid 4,11,0>

<find>
mov     ax,es:[
mov     bx,es:[
mov     dx,es:[
mov     cx,[
mov     si,[
mov     di,[
call    far ptr 
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
<mid 0,11,0> <mid 6,16,0> <mid 3,11,0>

<find>
mov     cx,<xdigit>
mov     si,<xdigit>
mov     di,<xdigit>
call    far ptr 
<repl>
<mid 3,16,0> <real <mid 0,11,0>, <mid 1,11,0>, <mid 2,11,0>>

<find>
mov     cx,es:[di+<xdigit>]
mov     si,es:[di+<xdigit>]
mov     di,es:[di+<xdigit>]
call    far ptr 
<repl>
<mid 3,16,0> <mid 0,11,0>

<find>
mov     cx,<xdigit>
xor     si,si
xor     di,di
call    far ptr 
<repl>
<mid 3,16,0> <real <mid 0,11,0>, 0, 0>

<find>
mov     ax,[
mov     bx,[
mov     dx,[
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;; 1st arg    proc_name   
push ( <mid 0,11,0> <mid 3,16,0> )

<find>
mov     cx,[bp
mov     si,[bp
mov     di,[bp
call    far ptr 
<repl>
;; proc_name  1st arg     
<mid 3,16,0> <mid 0,11,0>

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
call    far ptr 
<repl>
;; 1st arg    proc_name   
<mid 0,11,0> <mid 3,16,0>

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,<astring>
mov     si,<astring>
mov     di,<astring>
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
push ( <mid 0,11,0> <mid 6,16,0> <mid 3,11,0> )

<find>
mov     ax,[
mov     bx,[
mov     dx,[
mov     cx,<astring>
mov     si,<astring>
mov     di,<astring>
call    far ptr 
<repl>
;; 1st arg    proc_name     2nd arg         двухместная операция
<mid 0,11,0> <mid 6,16,0> <mid 3,11,0>

<find>
pop     cx
pop     si
pop     di
<repl>
pop   B : real

<find>
mov     ax,[
mov     bx,[
mov     dx,[
and     dh,7Fh
mov     cx,<xdigit>
mov     si,<xdigit>
mov     di,<xdigit>
call    far ptr 
<repl>
;; 1st arg            proc_name     2nd arg         двухместная операция
abs( <mid 0,11,0> ) <mid 7,16,0> <real <mid 4,11,0>, <mid 5,11,0>, <mid 6,11,0>>

;; ---------------- расчет индексов массивов Lines ---------------------------
<find>
mov     di,[bp?<xdigit>]
mov     si,di
shl     di,1
shl     di,1
add     di,si
add     di,offset Lines.p?
push    ds
pop     es
mov     [bp-<xdigit>],di
mov     [bp-<xdigit>],es
<repl>
;; лок.имя                    массив           индекс                  
<mid 8,8,','> := MK_FP( DS, &<mid 5,18,0>[ <mid 0,11,0> ] )

<find>
mov     di,es:[di]
mov     si,di
shl     di,1
shl     di,1
add     di,si
add     di,offset Lines.p?
push    ds
pop     es
mov     [bp-<xdigit>],di
mov     [bp-<xdigit>],es
<repl>
;; лок.имя                    массив           индекс                  
<mid 8,8,','> := MK_FP( DS, &<mid 5,18,0>[ <mid 0,11,0> ] )

<find>
;; создание указателя на массив xxxxx
imul    di,word ptr [bp?<xdigit>],1Ah
add     di,offset <astring>
push    ds
pop     es
mov     [bp-<xdigit>],di
mov     [bp-<xdigit>],es
<repl>
;; лок.имя                    массив           индекс                  
<mid 4,8,','> := MK_FP( DS, &<mid 1,18,0>[ word <mid 0,20,','> ] )

<find>
;; расчет индексов массивов
mov     di,[bp?<xdigit>]
mov     si,di
shl     di,1
shl     di,1
add     di,si
mov     al,Lines.fl[di]
<repl>
al := Lines[ <mid 0,11,0> ].fl

<find>
;; расчет индексов массивов
mov     di,[bp?<xdigit>]
mov     si,di
shl     di,1
shl     di,1
add     di,si
mov     Lines.fl[di],al
<repl>
Lines[ <mid 0,11,0> ].fl := al

<find>
;; расчет индексов массивов
mov     di,[bp?<xdigit>]
mov     si,di
shl     di,1
shl     di,1
add     di,si
<repl>
di = <mid 0,11,0> x 5

<find>
;; запись real по указателю
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
les     di,dword ptr [bp
mov     es:[di],ax
mov     es:[di+2],bx
mov     es:[di+4],dx
<repl>
*[ <mid 3,11,0> ] := (real) <mid 0,11,0>

<find>
;; запись real по указателю плюс 6
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
les     di,dword ptr [bp
mov     es:[di+6],ax
mov     es:[di+8],bx
mov     es:[di+0Ah],dx
<repl>
*[ <mid 3,11,0> ]+6 := (real) <mid 0,11,0>

<find>
;; запись real по указателю плюс 12.
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
les     di,dword ptr [bp
mov     es:[di+0Ch],ax
mov     es:[di+0Eh],bx
mov     es:[di+10h],dx
<repl>
*[ <mid 3,11,0> ]+12 := (real) <mid 0,11,0>

<find>
;; запись real по указателю плюс что-то
les     di,dword ptr [bp
mov     es:[di
mov     es:[di+<xdigit>],bx
mov     es:[di+<xdigit>],dx
<repl>
*[ <mid 0,11,0> ]<mid 1,14,']'> := (real) A

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;;       proc_name2      имя до [    индекс до ,            proc_name1   массив        индекс2
push    <mid 9,16,0>(<mid 1,11,'['>[ word <mid 0,20,','> ] <mid 8,16,0> <mid 5,11,'['>[ word <mid 4,20,','> ])

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;; имя до [    индекс до ,      proc_name   
push    <mid 1,11,'['>[ word <mid 0,20,','> ] <mid 8,16,0> <mid 5,11,'['>[ word <mid 4,20,','> ]

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
<repl>
;; имя до [    индекс до ,      proc_name   
<mid 1,11,'['>[ word <mid 0,20,','> ] <mid 8,16,0> <mid 5,11,'['>[ word <mid 4,20,','> ]

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr [bp?<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
;; лок.имя до ,   имя до [           индекс до ,         
<mid 4,8,','> := <mid 1,11,'['>[ word <mid 0,20,','> ]

<find>
;; операции с элементами массива точек RotPoints.??[i], где  i x 0x12
imul    di,word ptr es:[di+<xdigit>],12h
mov     ax,RotPoints.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
;; лок.имя до ,   имя до [           индекс до ,         
<mid 4,8,','> := <mid 1,11,'['>[ word <mid 0,20,','> ]

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr es:[di+<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
;; лок.имя до ,   имя до [           индекс до ,         
<mid 4,8,','> := <mid 1,11,'['>[ word <mid 0,20,','> ]

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr es:[di+<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     cx,[bp
mov     si,[bp
mov     di,[bp
call    far ptr 
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
;; лок.имя        массив до [      индекс до ,          proc name         
<mid 8,8,','> := <mid 1,11,'['>[ word <mid 0,20,','> ] <mid 7,16,0> <mid 4,11,0>

<find>
;; операции с элементами массива точек Points.??[i], где  i x 0x1A
imul    di,word ptr es:[di+<xdigit>],<xdigit>
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     cx,[bp
mov     si,[bp
mov     di,[bp
call    far ptr 
<repl>
;; массив до [   индекс до ,          proc name         
<mid 1,11,'['>[ word <mid 0,20,','> ] <mid 7,16,0> <mid 4,11,0>

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
leave
retn
<repl>
;;             1st arg
RETURN (real)<mid 0,11,0>

<find>
mov     al,[bp-
leave
retn
<repl>
;;             1st arg
RETURN byte <mid 0,11,0>

<find>
mov     ax,<xdigit>
call    far ptr _stacklen
sub     sp,<xdigit>
<repl>
_stacklen( <mid 0,11,0> )

<find>
xor     ax,ax
call    far ptr _stacklen
<repl>
_stacklen( 0 )

<find>
push    <xdigit>
call    far ptr _setcolor
<repl>
_setcolor( <mid 0,8,0> )

<find>
push    <xdigit>
call    far ptr _setActivePage
<repl>
_setActivePage( <mid 0,8,0> )

<find>
push    <xdigit>
push    <xdigit>
push    <xdigit>
push    <xdigit>
push    <xdigit>
call    far ptr _setviewport
<repl>
_setviewport( <dec 0,8>, <dec 1,8>, <dec 2,8>, <dec 3,8>, <dec 4,8> )

<find>
push    <xdigit>
push    <xdigit>
push    <xdigit>
push    <xdigit>
call    far ptr 
;; вызовы _bar, _line, _rectangle
<repl>
<mid 4,16,0>( <dec 0,8>, <dec 1,8>, <dec 2,8>, <dec 3,8> )

<find>
cwd
call    far ptr _int2real
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
<mid 2,8,','> := _int2real( ax )

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
imul    di,word ptr [bp-<xdigit>],12h
mov     RotPoints.?[di],ax
mov     <astring>[di],bx
mov     <astring>[di],dx
<repl>
;; имя до [         индекс до ','       локальная перем.         
<mid 4,8,'['>[ word <mid 3,20,','> ] := <mid 0,11,0>

<find>
imul    di,word ptr es:[di],1Ah
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
;; лок.имя        массив до [      индекс до ,                  
<mid 4,8,','> := <mid 1,11,'['>[ word <mid 0,20,','> ]

<find>
mov     ax,[bp
mov     bx,[bp
mov     dx,[bp
les     di,dword ptr [bp-
imul    di,word ptr es:[di],1Ah
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
<repl>
;; лок.имя        1й арг        proc name   массив до [    значение по указателю
<mid 4,8,','> := <mid 0,11,0> <mid 8,16,0> <mid 5,11,'['>[ *(word *)(<mid 3,11,0>) ]


<find>
;; организация указателя на элемент массива
imul    di,<astring>,1Ah
add     di,offset Points.?
push    ds
pop     es
mov     [bp-<xdigit>],di
mov     [bp-<xdigit>],es
<repl>
;; лок.имя               массив       индекс до ,                  
<mid 4,8,','> := MK_FP( DS, &<mid 1,18,0>[ <mid 0,11,','> ] )

<find>
;; работа с scrLines[]
mov     di,
shl     di,2
mov     ax,scrLines.?[di]
<repl>
ax = <mid 2,11,'['>[ <mid 0,11,0> ]

<find>
;; работа с scrLines[]
mov     di,
shl     di,2
push    scrLines.?[di]
<repl>
push  ( <mid 2,8,'['>[ <mid 0,11,0> ] )

<find>
;; работа с scrLines[]
mov     di,
shl     di,2
mov     scrLines.?[di],ax
<repl>
<mid 2,8,'['>[ <mid 0,11,0> ] := ax

<find>
;; работа с scrLines[]
mov     di,
shl     di,2
sub     ax,scrLines.?[di]
<repl>
ax -= <mid 2,11,'['>[ <mid 0,11,0> ]

<find>
;; работа с &scrLines[]
mov     di,
shl     di,2
add     di,offset scrLines.?
push    ds
push    di
<repl>
push  ( MK_FP( ds, &<mid 2,11,0>[ <mid 0,11,0> ] ))

<find>
les     di,dword ptr [bp-
imul    di,word ptr es:[di+2],1Ah
mov     ax,Points.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
les     di,dword ptr [bp-
imul    di,word ptr es:[di],1Ah
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
push    dx
push    bx
push    ax
<repl>
;;         массив         индекс               proc name
push    <mid 2,11,'['>[ *(<mid 0,11,0> +2) ] <mid 10,16,0> <mid 7,11,'['>[ *(<mid 5,11,0>) ]

<find>
les     di,dword ptr [bp
mov     ax,es:[di
mov     bx,es:[di+<xdigit>]
mov     dx,es:[di+<xdigit>]
les     di,dword ptr [bp
mov     cx,es:[di
mov     si,es:[di+<xdigit>]
mov     di,es:[di+<xdigit>]
call    far ptr 
<repl>
;;   1st ptr
*[<mid 0,11,0>]<mid 1,17,']'> <mid 8,16,0> *[<mid 4,11,0>]<mid 5,17,']'>

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
les     di,dword ptr [bp-<xdigit>]
mov     cx,es:[di]
mov     si,es:[di+2]
mov     di,es:[di+4]
call    far ptr 
<repl>
<mid 0,11,0> <mid 7,16,0> *[ <mid 3,11,0> ]

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
imul    di,word ptr [bp-<xdigit>],1Ah
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
<mid 8,8,','> := <mid 0,11,0> <mid 7,16,0> <mid 4,11,'['>[ <mid 3,11,','> ]

<find>
mov     ax,[bp-
mov     bx,[bp-
mov     dx,[bp-
imul    di,word ptr [bp-<xdigit>],1Ah
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
<repl>
<mid 0,11,0> <mid 7,16,0> <mid 4,11,'['>[ <mid 3,11,','> ]

<find>
imul    di,word ptr [bp-<xdigit>],1Ah
mov     cx,Points.?[di]
mov     si,<astring>[di]
mov     di,<astring>[di]
call    far ptr 
mov     <astring>,ax
mov     <astring>,bx
mov     <astring>,dx
<repl>
<mid 5,8,','> := A <mid 4,16,0> <mid 1,11,'['>[ <mid 0,11,','> ]

<find>
mov     ax,[bp
mov     bx,[bp
mov     dx,[bp
mov     <astring>,ax
mov     <astring>,bx
mov     <astring>,dx
<repl>
<mid 3,8,','> := <mid 0,11,0>

<find>
les     di,dword ptr [bp
imul    di,word ptr es:[di],12h
mov     ax,RotPoints.?[di]
mov     bx,<astring>[di]
mov     dx,<astring>[di]
mov     [bp-<xdigit>],ax
mov     [bp-<xdigit>],bx
mov     [bp-<xdigit>],dx
<repl>
<mid 5,8,','> := (real) <mid 2,11,'['>[ *[<mid 0,11,0>] ]

<find>
mov     ax,RotPoints.?[di]
mov     bx,data_545[di]
mov     dx,data_546[di]
mov     cx,[bp
mov     si,[bp
mov     di,[bp
call    far ptr 
mov     [bp-3Ch],ax
mov     [bp-3Ah],bx
mov     [bp-38h],dx
<repl>
<mid 7,8,','> := <mid 0,11,0> <mid 6,16,0> <mid 3,11,0>

<find>
les     di,dword ptr [bp
mov     es:[di],ax
<repl>
*(word *)(<mid 0,11,0>) := ax

<find>
les     di,dword ptr [bp
mov     ax,es:[di]
mov     [bp-<xdigit>],ax
<repl>
<mid 2,8,','> := *(word *)(<mid 0,11,0>)

<find>
mov     ax,<astring>
mov     [bp-<xdigit>],ax
<repl>
<mid 1,8,','> = <mid 0,11,0>

<find>
les     di,dword ptr [bp
mov     ax,es:[di]
<repl>
ax := *(word *)(<mid 0,11,0>)

<find>
les     di,dword ptr [bp
mov     es:[di],al
<repl>
*(word *)(<mid 0,11,0>) := al

<find>
les     di,dword ptr [bp
mov     al,es:[di]
<repl>
al := *(word *)(<mid 0,11,0>)

<find>
lea     di,[bp
push    ss
push    di
<repl>
push    &[ ss:<mid 0,11,0> ]

<find>
xor     ax,ax
mov     [bp-<xdigit>],ax
<repl>
<mid 1,8,','> := (int) 0

<find>
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
push    word ptr [bp-
call    Vector3DLength
;; на входе три числа real, на выходе длина вектора
<repl>
Vector3DLength( <mid 2,17,0>, <mid 5,17,0>, <mid 8,17,0>) ; три числа real

<find>
les     di,dword ptr [bp
mov     byte ptr es:[di],<xdigit>
<repl>
*[ <mid 0,11,0> ] := (int) <mid 1,25,0>

<find>
mov     di,
mov     si,di
shl     di,1
shl     di,1
add     di,si
mov     Lines.p?[di],ax
<repl>
<mid 5,8,'['>[ <mid 0,11,0> ] := ax

;;---------------------------------------------------------------------------

<end>
