-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddressing.S
More file actions
48 lines (32 loc) · 1.2 KB
/
Copy pathAddressing.S
File metadata and controls
48 lines (32 loc) · 1.2 KB
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
/******************************************************************************
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.
*******************************************************************************/
#pragma GCC optimize ("Og")
#include <iostream>
using namespace std;
volatile uint16_t a=5,b;
int main()
{
cout<<"Hello World"<<endl;
b=a;
//Direccionamiento "Directo": no se usa registro que contenga direccion
asm volatile
(
"mov ax,[rip+a] \n" //Ax copia tiene el cotenido de a
"mov [rip+b],ax \n"
:::"rax"
);
//Direccionamiento Indirecto: se usa registro que contiene direccion
asm volatile
(
"lea rax,[rip+a] \n"//Calculamos la direccion y guardamos en rax necesitamos 64 bits //rax <-- dir de a //lea para direccionamiento Indirecto
"mov ax, [rax] \n" //ax <-- (a) //obligatorios []
"mov [rip+b],ax"
:::"rax"
);
cout<<"b = "<<b<<endl;
return 0;
}