-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaxnumArray.S
58 lines (48 loc) · 1.4 KB
/
MaxnumArray.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
using namespace std;
volatile uint16_t arr1[5]={7,16,9,24,20},mx,i;
int main()
{
cout<<"Hello World"<<endl;
mx = arr1[0];
for(i=1; i<5; i++)
{
//------------------ PROCESS --------------------------//
//if(arr1[i]>mx)
//{
// mx = arr1[i];
//}
L10:
asm goto
(
"movzx rax, word ptr [rip+i] \n"
"lea rcx, [rip+arr1] \n"
"mov cx, [rcx+rax*2] \n"
"mov dx, [rip+mx] \n"
"cmp cx, dx \n"
"jae %l[L20] \n"
"jmp %l[L30] \n"
:::"rax","rcx","dx":L20,L30
);
L20:
//mx = arr1[i];
asm volatile
(
"mov [rip+mx], cx \n"
);
L30:
asm volatile
(
"nop"
);
//------------------------------------------------------//
}
cout<<"mx= "<<mx<<endl;
return 0;
}