Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include console.inc
- .stack 4096
- .data
- b1 db ?
- b2 db ?
- b3 db ?
- w1 dw ?
- w2 dw ?
- w3 dw ?
- d1 dd ?
- d2 dd ?
- d3 dd ?
- q1 dq 66042
- q2 dq 124853
- q3 dq 223333
- h1 dq ?
- consterror db "Ошибка: все три параметра макроса - константы.", 0
- sizeerror db "Ошибка: недопустимые размеры параметров макроса.", 0
- .code
- addthree macro a, b, c
- 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')
- if type a eq 0
- if type b eq 0
- if type c eq 0
- outstr offset consterror
- elseif (type c eq 1) or (type c eq 2) or (type c eq 4)
- add c, a
- add c, b
- else
- add dword ptr c, a
- adc dword ptr c+4, 0
- add dword ptr c, b
- adc dword ptr c+4, 0
- endif
- elseif type b lt type c
- outstr offset sizeerror
- elseif type b eq 1
- mov al, c
- add b, a
- add b, al
- elseif type b eq 2
- if type c eq 1
- movzx ax, c
- else
- mov ax, c
- endif
- add b, a
- add b, ax
- elseif type b eq 4
- if (type c eq 0) or (type c eq 4)
- mov eax, c
- else
- movzx eax, c
- endif
- add b, a
- add b, eax
- else
- if (type c eq 0) or (type c eq 1) or (type c eq 2) or (type c eq 4)
- if (type c eq 0) or (type c eq 4)
- mov eax, c
- else
- movzx eax, c
- endif
- add dword ptr b, eax
- adc dword ptr b+4, 0
- add dword ptr b, a
- adc dword ptr b+4, 0
- else
- mov eax, dword ptr c
- add dword ptr b, eax
- mov eax, dword ptr c+4
- adc dword ptr b+4, eax
- add dword ptr b, a
- adc dword ptr b+4, 0
- endif
- endif
- elseif (type a lt type b) or (type a lt type c)
- outstr offset sizeerror
- elseif type a eq 1
- mov al, b
- add al, c
- add a, al
- elseif type a eq 2
- if type b eq 1
- movzx ax, b
- else
- mov ax, b
- endif
- if type c eq 1
- add al, c
- adc ah, 0
- else
- add ax, c
- endif
- add a, ax
- elseif type a eq 4
- if (type b eq 4) or (type b eq 0)
- mov eax, b
- else
- movzx eax, b
- endif
- if (type c eq 4) or (type c eq 0)
- add eax, c
- elseif type c eq 1
- add al, c
- adc ah, 0
- jnc m3
- add eax, 65536
- m3:
- else
- add ax, c
- jnc m4
- add eax, 65536
- m4:
- endif
- add a, eax
- else
- if (type b eq 0) or (type b eq 4)
- mov dword ptr h1+4, 0
- mov eax, b
- mov dword ptr h1, eax
- elseif (type b eq 1) or (type b eq 2)
- mov dword ptr h1+4, 0
- movzx eax, b
- mov dword ptr h1, eax
- else
- mov eax, dword ptr b
- mov dword ptr h1, eax
- mov eax, dword ptr b+4
- mov dword ptr h1+4, eax
- endif; в h1 лежит b
- if (type c eq 0) or (type c eq 4)
- mov eax, c
- add dword ptr h1, eax
- adc dword ptr h1+4, 0
- elseif (type c eq 1) or (type c eq 2)
- movzx eax, c
- add dword ptr h1, eax
- adc dword ptr h1+4, 0
- else
- mov eax, dword ptr c
- add dword ptr h1, eax
- mov eax, dword ptr c+4
- adc dword ptr h1+4, eax
- endif
- mov eax, dword ptr h1
- add dword ptr a, eax
- mov eax, dword ptr h1+4
- adc dword ptr a+4, eax
- endif
- 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')
- if type a eq 0
- if type b eq 0
- if type c eq 0
- outstr offset consterror
- elseif type c ne 8
- add c, a
- add c, b
- else
- add dword ptr c, a
- adc dword ptr c+4, 0
- add dword ptr c, b
- adc dword ptr c+4, 0
- endif
- elseif type b lt type c
- outstr offset sizeerror
- elseif type b eq 1
- mov bl, c
- add b, a
- add b, bl
- elseif type b eq 2
- if type c eq 1
- movzx bx, c
- else
- mov bx, c
- endif
- add b, a
- add b, bx
- elseif type b eq 4
- if (type c eq 0) or (type c eq 4)
- mov ebx, c
- else
- movzx ebx, c
- endif
- add b, a
- add b, ebx
- else
- if type c ne 8
- if (type c eq 0) or (type c eq 4)
- mov ebx, c
- else
- movzx ebx, c
- endif
- add dword ptr b, ebx
- adc dword ptr b+4, 0
- add dword ptr b, a
- adc dword ptr b+4, 0
- else
- mov ebx, dword ptr c
- add dword ptr b, ebx
- mov ebx, dword ptr c+4
- adc dword ptr b+4, ebx
- add dword ptr b, a
- adc dword ptr b+4, 0
- endif
- endif
- elseif (type a lt type b) or (type a lt type c)
- outstr offset sizeerror
- elseif type a eq 1
- mov bl, b
- add bl, c
- add a, bl
- elseif type a eq 2
- if type b eq 1
- movzx bx, b
- else
- mov bx, b
- endif
- if type c eq 1
- add bl, c
- adc bh, 0
- else
- add bx, c
- endif
- add a, bx
- elseif type a eq 4
- if (type b eq 4) or (type b eq 0)
- mov ebx, b
- else
- movzx ebx, b
- endif
- if (type c eq 4) or (type c eq 0)
- add ebx, c
- elseif type c eq 1
- add bl, c
- adc bh, 0
- jnc m3
- add ebx, 65536
- m3:
- else
- add bx, c
- jnc m4
- add ebx, 65536
- m4:
- endif
- add a, ebx
- else
- if (type b eq 0) or (type b eq 4)
- mov dword ptr h1+4, 0
- mov ebx, b
- mov dword ptr h1, ebx
- elseif (type b eq 1) or (type b eq 2)
- mov dword ptr h1+4, 0
- movzx ebx, b
- mov dword ptr h1, ebx
- else
- mov ebx, dword ptr b
- mov dword ptr h1, ebx
- mov ebx, dword ptr b+4
- mov dword ptr h1+4, ebx
- endif; в h1 лежит b
- if (type c eq 0) or (type c eq 4)
- mov ebx, c
- add dword ptr h1, ebx
- adc dword ptr h1+4, 0
- elseif (type c eq 1) or (type c eq 2)
- movzx ebx, c
- add dword ptr h1, ebx
- adc dword ptr h1+4, 0
- else
- mov ebx, dword ptr c
- add dword ptr h1, ebx
- mov ebx, dword ptr c+4
- adc dword ptr h1+4, ebx
- endif
- mov ebx, dword ptr h1
- add dword ptr a, ebx
- mov ebx, dword ptr h1+4
- adc dword ptr a+4, ebx
- endif
- 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')
- if type a eq 0
- if type b eq 0
- if type c eq 0
- outstr offset consterror
- elseif type c ne 8
- add c, a
- add c, b
- else
- add dword ptr c, a
- adc dword ptr c+4, 0
- add dword ptr c, b
- adc dword ptr c+4, 0
- endif
- elseif type b lt type c
- outstr offset sizeerror
- elseif type b eq 1
- mov cl, c
- add b, a
- add b, cl
- elseif type b eq 2
- if type c eq 1
- movzx cx, c
- else
- mov cx, c
- endif
- add b, a
- add b, cx
- elseif type b eq 4
- if (type c eq 0) or (type c eq 4)
- mov ecx, c
- else
- movzx ecx, c
- endif
- add b, a
- add b, ecx
- else
- if type c ne 8
- if (type c eq 0) or (type c eq 4)
- mov ecx, c
- else
- movzx ecx, c
- endif
- add dword ptr b, ecx
- adc dword ptr b+4, 0
- add dword ptr b, a
- adc dword ptr b+4, 0
- else
- mov ecx, dword ptr c
- add dword ptr b, ecx
- mov ecx, dword ptr c+4
- adc dword ptr b+4, ecx
- add dword ptr b, a
- adc dword ptr b+4, 0
- endif
- endif
- elseif (type a lt type b) or (type a lt type c)
- outstr offset sizeerror
- elseif type a eq 1
- mov cl, b
- add cl, c
- add a, cl
- elseif type a eq 2
- if type b eq 1
- movzx cx, b
- else
- mov cx, b
- endif
- if type c eq 1
- add cl, c
- adc ch, 0
- else
- add cx, c
- endif
- add a, cx
- elseif type a eq 4
- if (type b eq 4) or (type b eq 0)
- mov ecx, b
- else
- movzx ecx, b
- endif
- if (type c eq 4) or (type c eq 0)
- add ecx, c
- elseif type c eq 1
- add cl, c
- adc ch, 0
- jnc m3
- add ecx, 65536
- m3:
- else
- add cx, c
- jnc m4
- add ecx, 65536
- m4:
- endif
- add a, ecx
- else
- if (type b eq 0) or (type b eq 4)
- mov dword ptr h1+4, 0
- mov ecx, b
- mov dword ptr h1, ecx
- elseif (type b eq 1) or (type b eq 2)
- mov dword ptr h1+4, 0
- movzx ecx, b
- mov dword ptr h1, ecx
- else
- mov ecx, dword ptr b
- mov dword ptr h1, ecx
- mov ecx, dword ptr b+4
- mov dword ptr h1+4, ecx
- endif; в h1 лежит b
- if (type c eq 0) or (type c eq 4)
- mov ecx, c
- add dword ptr h1, ecx
- adc dword ptr h1+4, 0
- elseif (type c eq 1) or (type c eq 2)
- movzx ecx, c
- add dword ptr h1, ecx
- adc dword ptr h1+4, 0
- else
- mov ecx, dword ptr c
- add dword ptr h1, ecx
- mov ecx, dword ptr c+4
- adc dword ptr h1+4, ecx
- endif
- mov ecx, dword ptr h1
- add dword ptr a, ecx
- mov ecx, dword ptr h1+4
- adc dword ptr a+4, ecx
- endif
- else
- if type a eq 0
- if type b eq 0
- if type c eq 0
- outstr offset consterror
- elseif type c ne 8
- add c, a
- add c, b
- else
- add dword ptr c, a
- adc dword ptr c+4, 0
- add dword ptr c, b
- adc dword ptr c+4, 0
- endif
- elseif type b lt type c
- outstr offset sizeerror
- elseif type b eq 1
- mov dl, c
- add b, a
- add b, dl
- elseif type b eq 2
- if type c eq 1
- movzx dx, c
- else
- mov dx, c
- endif
- add b, a
- add b, dx
- elseif type b eq 4
- if (type c eq 0) or (type c eq 4)
- mov edx, c
- else
- movzx edx, c
- endif
- add b, a
- add b, edx
- else
- if type c ne 8
- if (type c eq 0) or (type c eq 4)
- mov edx, c
- else
- movzx edx, c
- endif
- add dword ptr b, edx
- adc dword ptr b+4, 0
- add dword ptr b, a
- adc dword ptr b+4, 0
- else
- mov edx, dword ptr c
- add dword ptr b, edx
- mov edx, dword ptr c+4
- adc dword ptr b+4, edx
- add dword ptr b, a
- adc dword ptr b+4, 0
- endif
- endif
- elseif (type a lt type b) or (type a lt type c)
- outstr offset sizeerror
- elseif type a eq 1
- mov dl, b
- add dl, c
- add a, dl
- elseif type a eq 2
- if type b eq 1
- movzx dx, b
- else
- mov dx, b
- endif
- if type c eq 1
- add dl, c
- adc dh, 0
- else
- add dx, c
- endif
- add a, dx
- elseif type a eq 4
- if (type b eq 4) or (type b eq 0)
- mov edx, b
- else
- movzx edx, b
- endif
- if (type c eq 4) or (type c eq 0)
- add edx, c
- elseif type c eq 1
- add dl, c
- adc dh, 0
- jnc m3
- add edx, 65536
- m3:
- else
- add dx, c
- jnc m4
- add edx, 65536
- m4:
- endif
- add a, edx
- else
- if (type b eq 0) or (type b eq 4)
- mov dword ptr h1+4, 0
- mov edx, b
- mov dword ptr h1, edx
- elseif (type b eq 1) or (type b eq 2)
- mov dword ptr h1+4, 0
- movzx edx, b
- mov dword ptr h1, edx
- else
- mov edx, dword ptr b
- mov dword ptr h1, edx
- mov edx, dword ptr b+4
- mov dword ptr h1+4, edx
- endif; в h1 лежит b
- if (type c eq 0) or (type c eq 4)
- mov edx, c
- add dword ptr h1, edx
- adc dword ptr h1+4, 0
- elseif (type c eq 1) or (type c eq 2)
- movzx edx, c
- add dword ptr h1, edx
- adc dword ptr h1+4, 0
- else
- mov edx, dword ptr c
- add dword ptr h1, edx
- mov edx, dword ptr c+4
- adc dword ptr h1+4, edx
- endif
- mov edx, dword ptr h1
- add dword ptr a, edx
- mov edx, dword ptr h1+4
- adc dword ptr a+4, edx
- endif
- endif
- endm
- Start:
- mov edi, 13
- mov bp, 243
- mov d1, 12
- addthree 2, q1, q3
- outu q1
- exit
- end Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement