Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %macro pushd 0
- push eax
- push ebx
- push ecx
- push edx
- %endmacro
- %macro popd 0
- pop edx
- pop ecx
- pop ebx
- pop eax
- %endmacro
- %macro print 2
- pushd
- mov edx, %1
- mov ecx, %2
- mov ebx, 1
- mov eax, 4
- int 0x80
- popd
- %endmacro
- %macro dprint 0;
- pushd
- mov ecx, 10
- mov bx, 0
- _divide:
- xor edx, edx
- div ecx
- push dx
- inc bx
- test eax, eax
- jnz _divide
- _digit:
- pop ax
- add ax, '0'
- mov [reminder], ax
- print 1, reminder
- dec bx
- cmp bx, 0
- jg _digit
- popd
- %endmacro
- %macro sqrt 1
- finit
- fild dword [%1]
- fsqrt
- fist dword [%1]
- %endmacro
- section .text
- global _start
- _start:
- mov ebx, 0
- mov ecx, 0
- mov eax, 0
- _for1:
- mov ecx, ebx
- add ecx, 4
- _for2:
- mov al, [x+ecx]
- mov dl, [x+ebx]
- sub al, dl
- imul al
- mov [res1], al
- mov al, 0
- mov dl, 0
- mov al, [y+ecx]
- mov dl, [y+ebx]
- sub al, dl
- imul al
- add al, [res1]
- mov [res1], al
- sqrt res1
- mov al,[res1]
- cmp al, [max]
- jg _max
- jmp _end
- _max:
- mov [max], al
- _end:
- add ecx, 4
- mov al, 0
- mov dl, 0
- cmp ecx, len
- jl _for2
- add ebx,4
- cmp ebx, len
- jl _for1
- mov eax, [max]
- dprint
- print nlen, newline
- mov eax, 1
- int 0x80
- section .data
- res1 dd 0
- max dd 0
- x dd 10, 1, 3, 4, 5, 5, 1
- y dd 2, 3, 5, 7, 10, 3, 2
- len equ $ - y
- newline db 0xA, 0xD
- nlen equ $ - newline
- section .bss
- reminder resb 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement