memory-address

Sign or Zero Extension of address in 64bit mode for MOV moffs32?

别等时光非礼了梦想. 提交于 2019-12-01 17:31:36
问题 Let's have an instruction MOV EAX,[0xFFFFFFFF] encoded in 64bit mode as 67A1FFFFFFFF (effective address-size is toggled by 67 prefix from default 64 to 32 bits). Intel's instruction reference manual (doc Order Number: 325383-057US from December 2015) on page Vol. 2A 2-11 says: 2.2.1.3 Displacement Addressing in 64-bit mode uses existing 32-bit ModR/M and SIB encodings. The ModR/M and SIB sizes do not change. They remain 8 bits or 32 bits and are sign-extended to 64 bits. This suggests that

Inquiry about class variable declarations in C++

孤人 提交于 2019-12-01 17:14:07
问题 I have a class to represent a 3D vector of floats: class Vector3D { public: float x, y, z; float * const data; Vector3D() : x(0.0), y(0.0), z(0.0), data(&x) {} } My question is: are x, y, and z going to be allocated sequentially in memory such that I can assign the address of x to data and later use the subscript operator on data to access the vector components as an array? For example, sometimes I may want to access the vector components directly: Vector3D vec; vec.x = 42.0; vec.y = 42.0;

What is the meaning of the address of a pointer?

孤者浪人 提交于 2019-12-01 14:15:36
If we have code: int b = 10; int* a = &b; std::cout << a << " " << &a << " "; As the result, the addresses are different. But what's the meaning of address of a pointer? A pointer has the value of a variable's address, since we have a varaible in memory. But we don't have the value of address stored in memory, so why we have the address of an address? Maybe I have some misunderstandings, thank you for your help. Remember an address on your machine is going to be, itself, a 32 or 64-bit value (depending on your system architecture). In your example, you have the integer b that stores the value

MIPS Programming: Load Address

元气小坏坏 提交于 2019-12-01 13:54:19
The Background I am a student just beginning to learn MIPS for one of my courses, and my professor is not allowing the usage of pseudo-instructions such as Load Address ( la ) in our code. I am wondering what an example of the correct usage of standard instructions would look like to store the address of a declared variable into a register for use later in the code. My Solution I have currently been attempting to use this code, though I am getting a syntax error in the lui instruction. main: .data Array: .space 80 #Declares that Array will hold 20 integers .text lui $s0, Array #loads most

What is the meaning of the address of a pointer?

匆匆过客 提交于 2019-12-01 12:49:58
问题 If we have code: int b = 10; int* a = &b; std::cout << a << " " << &a << " "; As the result, the addresses are different. But what's the meaning of address of a pointer? A pointer has the value of a variable's address, since we have a varaible in memory. But we don't have the value of address stored in memory, so why we have the address of an address? Maybe I have some misunderstandings, thank you for your help. 回答1: Remember an address on your machine is going to be, itself, a 32 or 64-bit

can calloc or malloc be used to allocate ONLY physical memory in OSX?

混江龙づ霸主 提交于 2019-12-01 11:26:35
I am playing around with the c functions malloc and calloc and I have some questions. I want to see if I can use these 2 functions to allocate only physical memory, my mac has 4gb or ram and when I use malloc I can allocate way more than 4gb, which means malloc allocate both physical and virtual memory. I have a couple of questions: is there any function I can use, so that I can only allocate the physical memory (w/o allocating the virtual mem) when calling malloc and calloc and when the pointers return, is there any way I can use the pointers to determine how much physical memory are

MIPS Programming: Load Address

南笙酒味 提交于 2019-12-01 11:12:08
问题 The Background I am a student just beginning to learn MIPS for one of my courses, and my professor is not allowing the usage of pseudo-instructions such as Load Address ( la ) in our code. I am wondering what an example of the correct usage of standard instructions would look like to store the address of a declared variable into a register for use later in the code. My Solution I have currently been attempting to use this code, though I am getting a syntax error in the lui instruction. main:

can calloc or malloc be used to allocate ONLY physical memory in OSX?

一个人想着一个人 提交于 2019-12-01 09:21:49
问题 I am playing around with the c functions malloc and calloc and I have some questions. I want to see if I can use these 2 functions to allocate only physical memory, my mac has 4gb or ram and when I use malloc I can allocate way more than 4gb, which means malloc allocate both physical and virtual memory. I have a couple of questions: is there any function I can use, so that I can only allocate the physical memory (w/o allocating the virtual mem) when calling malloc and calloc and when the

Can an address be assigned to a variable in C?

旧城冷巷雨未停 提交于 2019-12-01 00:24:51
Is it possible to assign a variable the address you want, in the memory? I tried to do so but I am getting an error as "Lvalue required as left operand of assignment". int main() { int i = 10; &i = 7200; printf("i=%d address=%u", i, &i); } What is wrong with my approach? Is there any way in C in which we can assign an address we want, to a variable? Not directly. You can do this though : int* i = 7200; .. and then use i (ie. *i = 10) but you will most likely get a crash. This is only meaningful when doing low level development - device drivers, etc... with known memory addreses. Assuming you

c - cannot take address of bit-field

夙愿已清 提交于 2019-11-30 23:11:30
问题 Why cannot take address of bit-field? How do I make a pointer to bit-field? Here is the code... struct bitfield { unsigned int a: 1; unsigned int b: 1; unsigned int c: 1; unsigned int d: 1; }; int main(void) { struct bitfield pipe = { .a = 1, .b = 0, .c = 0, .d = 0 }; printf("%d %d %d %d\n", pipe.a, pipe.b, pipe.c, pipe.d); printf("%p\n", &pipe.a); /* OPPS HERE */ // error: cannot take address of bit-field ... return 0; } 回答1: Bitfields members are (typically) smaller than the granularity