Advertisement
Guest User

Untitled

a guest
May 16th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include console.inc
  2. .stack 4096
  3. .data
  4.     b1 db ?
  5.     b2 db ?
  6.     b3 db ?
  7.     w1 dw ?
  8.     w2 dw ?
  9.     w3 dw ?
  10.     d1 dd ?
  11.     d2 dd ?
  12.     d3 dd ?
  13.     q1 dq 66042
  14.     q2 dq 124853
  15.     q3 dq 223333
  16.     h1 dq ?
  17.     consterror db "Ошибка: все три параметра макроса - константы.", 0
  18.     sizeerror db "Ошибка: недопустимые размеры параметров макроса.", 0
  19. .code
  20. addthree macro a, b, c
  21.     if ('&a&' ne 'eax') and ('&b&' ne 'eax') and ('&c&' ne 'eax') and ('&a&' ne 'ax') and ('&b&' ne 'ax') and ('&c&' ne 'ax') and ('&a&' ne 'ah') and ('&b&' ne 'ah') and ('&c&' ne 'ah') and ('&a&' ne 'al') and ('&b&' ne 'al') and ('&c&' ne 'al')
  22.         if type a eq 0
  23.             if type b eq 0
  24.                 if type c eq 0
  25.                     outstr offset consterror
  26.                 elseif (type c eq 1) or (type c eq 2) or (type c eq 4)
  27.                     add c, a
  28.                     add c, b
  29.                 else
  30.                     add dword ptr c, a
  31.                     adc dword ptr c+4, 0
  32.                     add dword ptr c, b
  33.                     adc dword ptr c+4, 0
  34.                 endif
  35.             elseif type b lt type c
  36.                 outstr offset sizeerror
  37.             elseif type b eq 1
  38.                 mov al, c
  39.                 add b, a
  40.                 add b, al
  41.             elseif type b eq 2
  42.                 if type c eq 1
  43.                     movzx ax, c
  44.                 else
  45.                     mov ax, c
  46.                 endif
  47.                 add b, a
  48.                 add b, ax
  49.             elseif type b eq 4
  50.                 if (type c eq 0) or (type c eq 4)
  51.                     mov eax, c
  52.                 else
  53.                     movzx eax, c
  54.                 endif
  55.                 add b, a
  56.                 add b, eax
  57.             else
  58.                 if (type c eq 0) or (type c eq 1) or (type c eq 2) or (type c eq 4)
  59.                     if (type c eq 0) or (type c eq 4)
  60.                         mov eax, c
  61.                     else
  62.                         movzx eax, c
  63.                     endif
  64.                     add dword ptr b, eax
  65.                     adc dword ptr b+4, 0
  66.                     add dword ptr b, a
  67.                     adc dword ptr b+4, 0
  68.                 else
  69.                     mov eax, dword ptr c
  70.                     add dword ptr b, eax
  71.                     mov eax, dword ptr c+4
  72.                     adc dword ptr b+4, eax
  73.                     add dword ptr b, a
  74.                     adc dword ptr b+4, 0
  75.                 endif
  76.             endif
  77.         elseif (type a lt type b) or (type a lt type c)
  78.             outstr offset sizeerror
  79.         elseif type a eq 1
  80.             mov al, b
  81.             add al, c
  82.             add a, al
  83.         elseif type a eq 2
  84.             if type b eq 1
  85.                 movzx ax, b
  86.             else
  87.                 mov ax, b
  88.             endif
  89.             if type c eq 1
  90.                 add al, c
  91.                 adc ah, 0
  92.             else
  93.                 add ax, c
  94.             endif
  95.             add a, ax
  96.         elseif type a eq 4
  97.             if (type b eq 4) or (type b eq 0)
  98.                 mov eax, b
  99.             else
  100.                 movzx eax, b
  101.             endif
  102.             if (type c eq 4) or (type c eq 0)
  103.                 add eax, c
  104.             elseif type c eq 1
  105.                 add al, c
  106.                 adc ah, 0
  107.                 jnc m3
  108.                 add eax, 65536
  109.                 m3:
  110.             else
  111.                 add ax, c
  112.                 jnc m4
  113.                 add eax, 65536
  114.                 m4:
  115.             endif
  116.             add a, eax
  117.         else
  118.             if (type b eq 0) or (type b eq 4)
  119.                 mov dword ptr h1+4, 0
  120.                 mov eax, b
  121.                 mov dword ptr h1, eax
  122.             elseif (type b eq 1) or (type b eq 2)
  123.                 mov dword ptr h1+4, 0
  124.                 movzx eax, b
  125.                 mov dword ptr h1, eax
  126.             else
  127.                 mov eax, dword ptr b
  128.                 mov dword ptr h1, eax
  129.                 mov eax, dword ptr b+4
  130.                 mov dword ptr h1+4, eax
  131.             endif; в h1 лежит b
  132.             if (type c eq 0) or (type c eq 4)
  133.                 mov eax, c
  134.                 add dword ptr h1, eax
  135.                 adc dword ptr h1+4, 0
  136.             elseif (type c eq 1) or (type c eq 2)
  137.                 movzx eax, c
  138.                 add dword ptr h1, eax
  139.                 adc dword ptr h1+4, 0
  140.             else
  141.                 mov eax, dword ptr c
  142.                 add dword ptr h1, eax
  143.                 mov eax, dword ptr c+4
  144.                 adc dword ptr h1+4, eax
  145.             endif
  146.             mov eax, dword ptr h1
  147.             add dword ptr a, eax
  148.             mov eax, dword ptr h1+4
  149.             adc dword ptr a+4, eax
  150.         endif
  151.     elseif ('&a&' ne 'ebx') and ('&b&' ne 'ebx') and ('&c&' ne 'ebx') and ('&a&' ne 'bx') and ('&b&' ne 'bx') and ('&c&' ne 'bx') and ('&a&' ne 'bh') and ('&b&' ne 'bh') and ('&c&' ne 'bh') and ('&a&' ne 'bl') and ('&b&' ne 'bl') and ('&c&' ne 'bl')  
  152.         if type a eq 0
  153.             if type b eq 0
  154.                 if type c eq 0
  155.                     outstr offset consterror
  156.                 elseif type c ne 8
  157.                     add c, a
  158.                     add c, b
  159.                 else
  160.                     add dword ptr c, a
  161.                     adc dword ptr c+4, 0
  162.                     add dword ptr c, b
  163.                     adc dword ptr c+4, 0
  164.                 endif
  165.             elseif type b lt type c
  166.                 outstr offset sizeerror
  167.             elseif type b eq 1
  168.                 mov bl, c
  169.                 add b, a
  170.                 add b, bl
  171.             elseif type b eq 2
  172.                 if type c eq 1
  173.                     movzx bx, c
  174.                 else
  175.                     mov bx, c
  176.                 endif
  177.                 add b, a
  178.                 add b, bx
  179.             elseif type b eq 4
  180.                 if (type c eq 0) or (type c eq 4)
  181.                     mov ebx, c
  182.                 else
  183.                     movzx ebx, c
  184.                 endif
  185.                 add b, a
  186.                 add b, ebx
  187.             else
  188.                 if type c ne 8
  189.                     if (type c eq 0) or (type c eq 4)
  190.                         mov ebx, c
  191.                     else
  192.                         movzx ebx, c
  193.                     endif
  194.                     add dword ptr b, ebx
  195.                     adc dword ptr b+4, 0
  196.                     add dword ptr b, a
  197.                     adc dword ptr b+4, 0
  198.                 else
  199.                     mov ebx, dword ptr c
  200.                     add dword ptr b, ebx
  201.                     mov ebx, dword ptr c+4
  202.                     adc dword ptr b+4, ebx
  203.                     add dword ptr b, a
  204.                     adc dword ptr b+4, 0
  205.                 endif
  206.             endif
  207.         elseif (type a lt type b) or (type a lt type c)
  208.             outstr offset sizeerror
  209.         elseif type a eq 1
  210.             mov bl, b
  211.             add bl, c
  212.             add a, bl
  213.         elseif type a eq 2
  214.             if type b eq 1
  215.                 movzx bx, b
  216.             else
  217.                 mov bx, b
  218.             endif
  219.             if type c eq 1
  220.                 add bl, c
  221.                 adc bh, 0
  222.             else
  223.                 add bx, c
  224.             endif
  225.             add a, bx
  226.         elseif type a eq 4
  227.             if (type b eq 4) or (type b eq 0)
  228.                 mov ebx, b
  229.             else
  230.                 movzx ebx, b
  231.             endif
  232.             if (type c eq 4) or (type c eq 0)
  233.                 add ebx, c
  234.             elseif type c eq 1
  235.                 add bl, c
  236.                 adc bh, 0
  237.                 jnc m3
  238.                 add ebx, 65536
  239.                 m3:
  240.             else
  241.                 add bx, c
  242.                 jnc m4
  243.                 add ebx, 65536
  244.                 m4:
  245.             endif
  246.             add a, ebx
  247.         else
  248.             if (type b eq 0) or (type b eq 4)
  249.                 mov dword ptr h1+4, 0
  250.                 mov ebx, b
  251.                 mov dword ptr h1, ebx
  252.             elseif (type b eq 1) or (type b eq 2)
  253.                 mov dword ptr h1+4, 0
  254.                 movzx ebx, b
  255.                 mov dword ptr h1, ebx
  256.             else
  257.                 mov ebx, dword ptr b
  258.                 mov dword ptr h1, ebx
  259.                 mov ebx, dword ptr b+4
  260.                 mov dword ptr h1+4, ebx
  261.             endif; в h1 лежит b
  262.             if (type c eq 0) or (type c eq 4)
  263.                 mov ebx, c
  264.                 add dword ptr h1, ebx
  265.                 adc dword ptr h1+4, 0
  266.             elseif (type c eq 1) or (type c eq 2)
  267.                 movzx ebx, c
  268.                 add dword ptr h1, ebx
  269.                 adc dword ptr h1+4, 0
  270.             else
  271.                 mov ebx, dword ptr c
  272.                 add dword ptr h1, ebx
  273.                 mov ebx, dword ptr c+4
  274.                 adc dword ptr h1+4, ebx
  275.             endif
  276.             mov ebx, dword ptr h1
  277.             add dword ptr a, ebx
  278.             mov ebx, dword ptr h1+4
  279.             adc dword ptr a+4, ebx
  280.         endif
  281.     elseif ('&a&' ne 'ecx') and ('&b&' ne 'ecx') and ('&c&' ne 'ecx') and ('&a&' ne 'cx') and ('&b&' ne 'cx') and ('&c&' ne 'cx') and ('&a&' ne 'ch') and ('&b&' ne 'ch') and ('&c&' ne 'ch') and ('&a&' ne 'cl') and ('&b&' ne 'cl') and ('&c&' ne 'cl')
  282.         if type a eq 0
  283.             if type b eq 0
  284.                 if type c eq 0
  285.                     outstr offset consterror
  286.                 elseif type c ne 8
  287.                     add c, a
  288.                     add c, b
  289.                 else
  290.                     add dword ptr c, a
  291.                     adc dword ptr c+4, 0
  292.                     add dword ptr c, b
  293.                     adc dword ptr c+4, 0
  294.                 endif
  295.             elseif type b lt type c
  296.                 outstr offset sizeerror
  297.             elseif type b eq 1
  298.                 mov cl, c
  299.                 add b, a
  300.                 add b, cl
  301.             elseif type b eq 2
  302.                 if type c eq 1
  303.                     movzx cx, c
  304.                 else
  305.                     mov cx, c
  306.                 endif
  307.                 add b, a
  308.                 add b, cx
  309.             elseif type b eq 4
  310.                 if (type c eq 0) or (type c eq 4)
  311.                     mov ecx, c
  312.                 else
  313.                     movzx ecx, c
  314.                 endif
  315.                 add b, a
  316.                 add b, ecx
  317.             else
  318.                 if type c ne 8
  319.                     if (type c eq 0) or (type c eq 4)
  320.                         mov ecx, c
  321.                     else
  322.                         movzx ecx, c
  323.                     endif
  324.                     add dword ptr b, ecx
  325.                     adc dword ptr b+4, 0
  326.                     add dword ptr b, a
  327.                     adc dword ptr b+4, 0
  328.                 else
  329.                     mov ecx, dword ptr c
  330.                     add dword ptr b, ecx
  331.                     mov ecx, dword ptr c+4
  332.                     adc dword ptr b+4, ecx
  333.                     add dword ptr b, a
  334.                     adc dword ptr b+4, 0
  335.                 endif
  336.             endif
  337.         elseif (type a lt type b) or (type a lt type c)
  338.             outstr offset sizeerror
  339.         elseif type a eq 1
  340.             mov cl, b
  341.             add cl, c
  342.             add a, cl
  343.         elseif type a eq 2
  344.             if type b eq 1
  345.                 movzx cx, b
  346.             else
  347.                 mov cx, b
  348.             endif
  349.             if type c eq 1
  350.                 add cl, c
  351.                 adc ch, 0
  352.             else
  353.                 add cx, c
  354.             endif
  355.             add a, cx
  356.         elseif type a eq 4
  357.             if (type b eq 4) or (type b eq 0)
  358.                 mov ecx, b
  359.             else
  360.                 movzx ecx, b
  361.             endif
  362.             if (type c eq 4) or (type c eq 0)
  363.                 add ecx, c
  364.             elseif type c eq 1
  365.                 add cl, c
  366.                 adc ch, 0
  367.                 jnc m3
  368.                 add ecx, 65536
  369.                 m3:
  370.             else
  371.                 add cx, c
  372.                 jnc m4
  373.                 add ecx, 65536
  374.                 m4:
  375.             endif
  376.             add a, ecx
  377.         else
  378.             if (type b eq 0) or (type b eq 4)
  379.                 mov dword ptr h1+4, 0
  380.                 mov ecx, b
  381.                 mov dword ptr h1, ecx
  382.             elseif (type b eq 1) or (type b eq 2)
  383.                 mov dword ptr h1+4, 0
  384.                 movzx ecx, b
  385.                 mov dword ptr h1, ecx
  386.             else
  387.                 mov ecx, dword ptr b
  388.                 mov dword ptr h1, ecx
  389.                 mov ecx, dword ptr b+4
  390.                 mov dword ptr h1+4, ecx
  391.             endif; в h1 лежит b
  392.             if (type c eq 0) or (type c eq 4)
  393.                 mov ecx, c
  394.                 add dword ptr h1, ecx
  395.                 adc dword ptr h1+4, 0
  396.             elseif (type c eq 1) or (type c eq 2)
  397.                 movzx ecx, c
  398.                 add dword ptr h1, ecx
  399.                 adc dword ptr h1+4, 0
  400.             else
  401.                 mov ecx, dword ptr c
  402.                 add dword ptr h1, ecx
  403.                 mov ecx, dword ptr c+4
  404.                 adc dword ptr h1+4, ecx
  405.             endif
  406.             mov ecx, dword ptr h1
  407.             add dword ptr a, ecx
  408.             mov ecx, dword ptr h1+4
  409.             adc dword ptr a+4, ecx
  410.         endif
  411.     else
  412.         if type a eq 0
  413.             if type b eq 0
  414.                 if type c eq 0
  415.                     outstr offset consterror
  416.                 elseif type c ne 8
  417.                     add c, a
  418.                     add c, b
  419.                 else
  420.                     add dword ptr c, a
  421.                     adc dword ptr c+4, 0
  422.                     add dword ptr c, b
  423.                     adc dword ptr c+4, 0
  424.                 endif
  425.             elseif type b lt type c
  426.                 outstr offset sizeerror
  427.             elseif type b eq 1
  428.                 mov dl, c
  429.                 add b, a
  430.                 add b, dl
  431.             elseif type b eq 2
  432.                 if type c eq 1
  433.                     movzx dx, c
  434.                 else
  435.                     mov dx, c
  436.                 endif
  437.                 add b, a
  438.                 add b, dx
  439.             elseif type b eq 4
  440.                 if (type c eq 0) or (type c eq 4)
  441.                     mov edx, c
  442.                 else
  443.                     movzx edx, c
  444.                 endif
  445.                 add b, a
  446.                 add b, edx
  447.             else
  448.                 if type c ne 8
  449.                     if (type c eq 0) or (type c eq 4)
  450.                         mov edx, c
  451.                     else
  452.                         movzx edx, c
  453.                     endif
  454.                     add dword ptr b, edx
  455.                     adc dword ptr b+4, 0
  456.                     add dword ptr b, a
  457.                     adc dword ptr b+4, 0
  458.                 else
  459.                     mov edx, dword ptr c
  460.                     add dword ptr b, edx
  461.                     mov edx, dword ptr c+4
  462.                     adc dword ptr b+4, edx
  463.                     add dword ptr b, a
  464.                     adc dword ptr b+4, 0
  465.                 endif
  466.             endif
  467.         elseif (type a lt type b) or (type a lt type c)
  468.             outstr offset sizeerror
  469.         elseif type a eq 1
  470.             mov dl, b
  471.             add dl, c
  472.             add a, dl
  473.         elseif type a eq 2
  474.             if type b eq 1
  475.                 movzx dx, b
  476.             else
  477.                 mov dx, b
  478.             endif
  479.             if type c eq 1
  480.                 add dl, c
  481.                 adc dh, 0
  482.             else
  483.                 add dx, c
  484.             endif
  485.             add a, dx
  486.         elseif type a eq 4
  487.             if (type b eq 4) or (type b eq 0)
  488.                 mov edx, b
  489.             else
  490.                 movzx edx, b
  491.             endif
  492.             if (type c eq 4) or (type c eq 0)
  493.                 add edx, c
  494.             elseif type c eq 1
  495.                 add dl, c
  496.                 adc dh, 0
  497.                 jnc m3
  498.                 add edx, 65536
  499.                 m3:
  500.             else
  501.                 add dx, c
  502.                 jnc m4
  503.                 add edx, 65536
  504.                 m4:
  505.             endif
  506.             add a, edx
  507.         else
  508.             if (type b eq 0) or (type b eq 4)
  509.                 mov dword ptr h1+4, 0
  510.                 mov edx, b
  511.                 mov dword ptr h1, edx
  512.             elseif (type b eq 1) or (type b eq 2)
  513.                 mov dword ptr h1+4, 0
  514.                 movzx edx, b
  515.                 mov dword ptr h1, edx
  516.             else
  517.                 mov edx, dword ptr b
  518.                 mov dword ptr h1, edx
  519.                 mov edx, dword ptr b+4
  520.                 mov dword ptr h1+4, edx
  521.             endif; в h1 лежит b
  522.             if (type c eq 0) or (type c eq 4)
  523.                 mov edx, c
  524.                 add dword ptr h1, edx
  525.                 adc dword ptr h1+4, 0
  526.             elseif (type c eq 1) or (type c eq 2)
  527.                 movzx edx, c
  528.                 add dword ptr h1, edx
  529.                 adc dword ptr h1+4, 0
  530.             else
  531.                 mov edx, dword ptr c
  532.                 add dword ptr h1, edx
  533.                 mov edx, dword ptr c+4
  534.                 adc dword ptr h1+4, edx
  535.             endif
  536.             mov edx, dword ptr h1
  537.             add dword ptr a, edx
  538.             mov edx, dword ptr h1+4
  539.             adc dword ptr a+4, edx
  540.         endif
  541.     endif
  542. endm
  543. Start:
  544.     mov edi, 13
  545.     mov bp, 243
  546.     mov d1, 12
  547.     addthree 2, q1, q3
  548.     outu q1
  549.     exit
  550.     end Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement