-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSum.S
29 lines (25 loc) · 950 Bytes
/
Sum.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
/******************************************************************************
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 a=45000,b=15000,c;
int main()
{
cout<<"Hello World"<<endl;
//c = a + b;
asm volatile
(
"mov ax, [rip+a] \n" //[rip+variable] para traerlo de memoria
"mov bx, [rip+b] \n"
//"add ax,bx \n" //Suma en 16-bits sin ser algotítmico ax <-- a+b
"add ax,[rip+b] \n" //Un operando puede estar en memoria
"mov [rip+c],ax \n"
:::"rax","rbx"
);
cout<<"c = " << c << endl;
return 0;
}