Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 0.75 KB | None | 0 0
  1. const int arrLen = 5;
  2.     int arr[arrLen] = { 5,5,4,3,1 };
  3.     int c;
  4.     int i;
  5.     __asm
  6.     {
  7.         mov ecx, arrLen
  8.         xor eax, eax; max val
  9.         xor esi, esi; max pos
  10.  
  11.         xor ebx, ebx; min val
  12.         xor edi, edi; min pos
  13.        
  14.         mov eax, arr[ecx * 4 - 4]
  15.         mov edi, ecx
  16.  
  17.         mov ebx, arr[ecx * 4 - 4]
  18.         mov esi, ecx
  19.        
  20.         beg :
  21.         cmp eax, arr[ecx * 4 - 4];
  22.         jg maxchange
  23.        
  24.         cmp ebx, arr[ecx * 4 - 4];
  25.         jle minchange
  26.        
  27.         cont:
  28.         loop beg
  29.         jmp endf
  30.  
  31.         maxchange:
  32.         mov eax, arr[ecx * 4 - 4]
  33.         mov esi, ecx
  34.         jmp cont
  35.  
  36.         minchange:
  37.         mov ebx, arr[ecx * 4 - 4]
  38.         mov edi, ecx
  39.         jmp cont
  40.  
  41.         endf:
  42.         sub ebx, eax
  43.         mov c, ebx
  44.  
  45.         sub edi, esi
  46.         js nominus
  47.         jmp endP
  48.  
  49.         nominus:
  50.         neg edi
  51.  
  52.         endP:
  53.         mov i,edi
  54.            
  55.     }
  56.     cout << c;
  57.     cout << i;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement