memory-address

How is a physical address generated in 8086?

∥☆過路亽.° 提交于 2019-11-30 22:02:49
In the 8086 architecture, the memory space is 1 MiB in size and divided into logical segments of up to 64 KiB each. i.e. it has 20 address lines thus the following method is used: That the data segment register is shifted left 4 bits then added to the offset register My question is: How we do the shift operation although all the registers are only 16 bits Address translation is done internally by a special unit without using the registers available to user code to store intermediate results - it just fetches 16-bit values and does the translation inside - it is not reflected anywhere where the

Can an address be assigned to a variable in C?

六月ゝ 毕业季﹏ 提交于 2019-11-30 18:17:16
问题 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? 回答1: 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

How to manually symbolicate a crash log with atos

强颜欢笑 提交于 2019-11-30 10:06:16
After searching all over the internet to find a way to symbolicate my crash logs I received from Apple, I finally figured out how to use the atos command in terminal to symbolicate the crash logs. I have the dSYM file, the .app file and the crash logs in the same folder, and using atos -arch armv7 -o APPNAME I have been able to enter memory addresses, and sometimes (but quite rarely) a method name has come up. To be perfectly honest, I don't have much experience with terminal, or crash logs. Attempting to symbolicate the crash logs from Xcode's organiser has unfortunately done absolutely

What memory address spaces are there?

让人想犯罪 __ 提交于 2019-11-30 04:46:20
What forms of memory address spaces have been used? Today, a large flat virtual address space is common. Historically, more complicated address spaces have been used, such as a pair of a base address and an offset, a pair of a segment number and an offset, a word address plus some index for a byte or other sub-object, and so on. From time to time, various answers and comments assert that C/C++ pointers are essentially integers. That is an incorrect model for C/C++, since the variety of address spaces is undoubtedly the cause of some of the C rules about pointer operations. For example, not

Unique address for constexpr variable

痞子三分冷 提交于 2019-11-30 02:30:33
问题 Is it possible to have a unique address allocated for a constexpr variable, i.e. the same for all translation units where the variable is available (usually through a header)? Consider the following example: // foo.hh #include <iostream> constexpr int foo = 42; // a.cc #include "foo.hh" void a(void) { std::cout << "a: " << &foo << std::endl; } // b.cc #include "foo.hh" extern void a(void); int main(int argc, char** argv) { a(); std::cout << "b: " << &foo << std::endl; } Compiling a.cc and b

One memory location in a computer stores how much data?

孤街醉人 提交于 2019-11-30 01:54:01
Assume 32 Bit OS. One memory location in a computer stores how much data? Whats the basic unit of memory storage in a computer? For Example to a store a integer what will be the memory addresses required? If basic unit is BYTE the integer requires 4 bytes. So if I need to store a byte then if start putting in the 1st byte in memory location 0001 then will my integer end at 0003 memory location? Please correct me if am wrong? Most commonly, modern systems are what you call "byte-accessible" This means: One memory location stores 1 Byte (8 bits). The basic storage unit for memory is 1 byte. If

Pointers to elements of STL containers

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 23:07:59
Given an STL container (you may also take boost::unordered_map and boost::multi_index_container into account) that is non-contiguous, is it guaranteed that the memory addresses of the elements inside the container never changes if no element is removed, (but new ones can be added)? e.g. class ABC { }; // //... // std::list<ABC> abclist; ABC abc; abclist.insert(abc); ABC * abc_ptr = &(*abclist.begin()); In other word will abc_ptr be pointed to abc throughout the execution, if I do not remove abc from abc_list . I am asking this because I am going to wrap the class ABC in C++/Cli, so I need

this pointer and member function address

丶灬走出姿态 提交于 2019-11-29 17:49:58
I'm trying to get the address of a member function, but I don't know how. I would appreciate if somebody could tell me what I'm doing wrong. As you can see in my example below, neither (long)&g nor (long)&this->g work and I can't figure out the correct syntax: /* Create a class that (redundantly) performs data member selection and a member function call using the this keyword (which refers to the address of the current object). */ #include<iostream> using namespace std; #define PR(STR) cout << #STR ": " << STR << endl; class test { public: int a, b; int c[10]; void g(); }; void f() { cout <<

How is Memory Allocated to variables of different data types?

六眼飞鱼酱① 提交于 2019-11-29 13:06:10
I wrote the following Code. #include<stdio.h> int main() { int x = 1 ; int *j = &x ; int y = 2 ; int *t = &y ; printf("%p\n" , (void *)j); printf("%p" , (void *)t); } Output is 0028FF14 0028FF10 . The Point I want to make is that the difference between the addresses is `4'. Whereas in this case #include<stdio.h> int main() { char x = 't' ; char *j = &x ; char y = 'f' ; char *t = &y ; printf("%p\n" , (void *)j); printf("%p" , (void *)t); } Output is 0028FF17 0028FF16 The difference is 1 . Difference In First Case is 4 . Whereas in the second case it is 1 . Why is it so? And What will I get if I

Accessing direct memory addresses and obtaining the values in C++

两盒软妹~` 提交于 2019-11-29 11:33:21
问题 I was wondering if it was possible to access a direct block of memory using C/C++ and grab the value. For example: int i = 15; int *p = &i; cout << &i; If I took the printed value here, that would give me the address of the variable i, which contains the value 15. I will just say it printed out 0x0ff9c1 for this example. If I have a separate program which declares a pointer like so... int *p = 0x0ff9c1; cout << *p; Would it be possible to print out that 15 that the other application placed in