answersLogoWhite

0


Best Answer

Pointers to far objects are stored using four bytes (32 bits). The bytes are stored little endian or low to high order. The first word contains the 14-bit memory offset (bits 14 and 15 are always 0). The second word contains the page number (or segment number for function pointers). The memory address is calculated as follows: Variable Address = (Page * 0x4000L) + OffsetFunction Address = (Segment * 0x10000L) + Offset

User Avatar

Wiki User

16y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Pointers to far objects are stored using four bytes (32 bits). The bytes are stored little endian or low to high order. The first word contains the 14-bit memory offset (bits 14 and 15 are always 0). The second word contains the page number (or segment number for function pointers). The memory address is calculated as follows:

Variable Address (Page * 0x4000L) + Offset Function Address (Segment * 0x10000L) + Offset

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Treat the 32-bit address as being two 16-bit values, one for the segment and the other for the offset within that segment.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How would you obtain a far address from segment and offset address of a memory location?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is huge pointer generic pointer and far pointer?

Far Pointer is a pointer that is stored using four bytes (32 bits). The bytes are stored little endian or low to high order. A far pointer can access objects up to 16K in size in any memory area. Objects larger than 16K must be accessed using huge pointers This book is basic for c , download and Read this... must required !


Why you Use Memory Segmentation In 8086 Microprocessor?

The 8086/8088 is a 16 bit processor running on a 16 bit (8086) or 8 bit (8088) bus with a 20 bit address bus. In order to obtain the extra 4 bits of addressibility, Intel designed segment registers that are effectively multiplied by four and then added to the 16 bit offset address generated by the instruction. This yields 64K segments of 64KB each, although they overlap each other at a distance of 16 bytes.


What is dereferencing pointer?

They're related but not totally comparable.A pointer is an address in memory where a variable is located.An array is a conceptual data representation consisting of a list of more than one item of a particular scalar type (int, float, char, structure, etc.) where each element is accessed by its index. The index can be thought of as a counter or enumerator telling you how many elements you have to skip over to get to the one you're interested in. Here's where addresses come in ... the location of a particular element in memory is offset from the so-called base address (i.e. the address of the starting element) by the value(sizeof(one element) * index #)The C compiler is smart enough to take the sizeof() into account when you do pointer arithmetic, so you can find the address of the i-th element as (address of base) + i, rather than having to do the multiplication explicitly.The idea of element address as offset also accounts for C's use of zero-relative array definitions. Since the first element is offset by 0 positions from the first element its index in C is 0, not 1. The second (ordinal) element is offset from the first by 1 position so its index is 1, and so on.


How would you obtain the MAC address from a machine?

It depends on the machine. However, the MAC address is usually found in the network interface properties.


Are reference variables are NOT available in C?

Yes, reference variables are permitted in C. However a reference variable in C is simply another name for a pointer variable, because pointers can be dereferenced to allow indirect access to the memory they point at. However, in C++, references are neither pointers nor variables, they serve another purpose altogether, one which is not available in C. So the real answer is that C++ references are not available in C, but reference variables are. Although it is common practice to avoid using the term reference lest there be any confusion with a C++ reference, it doesn't alter the fact that a C pointer variable is also a C reference variable. They are one and the same thing. In C++, a reference is entirely different from a C reference. More specifically, it is an alias, an alternate name, for a memory address. Unlike pointer variables, a reference consumes no memory of its own. That is, you cannot obtain the address of a reference since there is none to obtain. Hence the 'address of' operator (&) is used during instantiation to signify that the instance name is actually a reference of the specified type, and not a variable of the type. The address being referred to must also be assigned to the reference when the reference is instantiated. That is, you cannot declare a reference and then assign a memory address to it elsewhere in your code. By the same token, you cannot subsequently reassign a reference while it remains in scope. Remember, references are not variables. What they refer to may be variable, but not the reference itself. In that respect it is not unlike like a constant pointer to a variable. References allow you to refer to the same memory address using one or more aliases. Since they consume no memory of their own, there is no practical limit to the number of aliases you can have in your C++ program. When compiled, all references to the same memory are effectively replaced with the actual memory address, or the address of a static location containing the actual memory address if the address was allocated dynamically. So while references are often implemented just as if they were pointers, this is only of concern to developers of C++ compilers. In more general C++ source code, the two concepts must be kept distinct. C++ references are also much easier to work with than pointers. Whereas pointers to allocated memory must be manually released when no longer required, references do not. When a referenced object falls from scope, the object's destructor is called automatically. More importantly, references can never be NULL so, if you have a reference, a valid object of the specified type is guaranteed to exist at the referred memory location. The only time you will encounter problems with references is when you point at them, and then delete the pointer! If you subsequently access the referenced memory or the reference falls from scope, your program will exhibit undefined behaviour. Obviously this is a programming error, but these type of problems exist with pointers in general, hence pointers are best avoided as much as is possible. If an object is guaranteed to exist, then refer to it, don't point at it. Only use a pointer when an object is not guaranteed to exist, or if you need to change the address being referred to. And if a pointer is non-NULL, refer to the object.

Related questions

What are array of string pointers?

An array of pointers to string would contain, per array position, a number dictating which memory address holds the string data. For example, position [0] in an array would contain a memory address. This memory address can be de-referenced to obtain the actual information held within that memory address.


A Explain the use of Code Segment CS and data segment DS register in 8086 microprocessor?

Code segment (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP) register. CS register cannot be changed directly. The CS register is automatically updated during far jump, far call and far return instructions. Data segment (DS) is a 16-bit register containing address of 64KB segment with program data. By default, the processor assumes that all data referenced by general registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment. DS register can be changed directly using POP and LDS instructions. Code segment (CS) is a 16-bit register containing address of 64 KB segment with processor instructions. The processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP) register. CS register cannot be changed directly. The CS register is automatically updated during far jump, far call and far return instructions. Data segment (DS) is a 16-bit register containing address of 64KB segment with program data. By default, the processor assumes that all data referenced by general registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment. DS register can be changed directly using POP and LDS instructions.


How do you state position of a value in a c plus plus program?

It's not clear what you mean by "position of a value" but I presume you mean it's position in memory. Static variables, constants and globals are allocated in static memory (the .data segment of the executable). Local named variables are allocated on the stack as and when they come into scope and are automatically released when they fall from scope. Anonymous variables are allocated on the heap. To obtain the actual address of a value you must hold a reference or pointer to it. Taking the address of a reference gives you the address of the object being referred to. Taking the value of a pointer gives you the address of the value being pointed at.


What are near far and huge pointers in C?

A near pointer is a 16 bit pointer to an object contained in the current segment, be it code segment, data segment, stack segment, or extra segment. The compiler can generate code with a near pointer and does not have to concern itself with segment addressing, so using near pointers is fastest, and generates smallest code. The limitation is that you can only access 64kb of data at a time, because that is the size of a segment - 64kb. A near pointer contains only the 16 bit offset of the object within the currently selected segment.A far pointer is a 32 bit pointer to an object anywhere in memory. In order to use it, the compiler must allocate a segment register, load it with the segment portion of the pointer, and then reference memory using the offset portion of the pointer relative to the newly loaded segment register. This takes extra instructions and extra time, so it is the slowest and largest method of accessing memory, but it can access memory that is larger than 64kb, sometimes, such as when dealing with video memory, a needful thing. A far pointer contains a 16 bit segment part and a 16 bit offset part. Still, at any one instant of time, without "touching" segment registers, the program only has access to four 64kb chunks, or segments of memory. If there is a 100kb object involved, code will need to be written to consider its segmentation, even with far pointers.Now, segments overlap. Each segment is 64kb in length, but each one overlaps the next and the prior by 65520 bytes. That means that every address in memory can be addressed by 64kb-1 different combinations of segment:offset pairs. The result is that the total addressible memory was only 1mb, and the total usable memory address space was 500kb to 600kb. That sounds odd, but Intel built it, Microsoft wrote it, and DOS/Windows 3.1 grew up around it. I still have that computer, and it still works just fine.Now the huge pointer. The far pointer suffers because you can not just add one to it and have it point the the next item in memory - you have to consider segment:offset rules, because of the 16 byte offset issue. The huge pointer is a monolithic pointer to some item with a large chunk of memory, and there are no segment:offset boundaries.Well, in order to get that, the pointer to segment:offset calculation has to be done every time you reference the pointer. It does allow you to create and manipulate a single monolithic object that is greater than 64kb, but it has its costs. Far pointers are the normalized pointers of four bytes which are used to access the main memory of the computer ...it can access both the data segment and code segment thus by modifing the offset you can modify refer two different addresses but refer to the same memory .In a generic OS , memory is organised in a segment:offset fashion. Now say, it is of "X" MB and this "X" MB is made up of say "S" number of segments of each segment having "B" Bytes where S*B Bytes=X MB.Near Pointer: A near pointer is that which will only point within the current segment say segment 3 (there are S number of segments numbered 0 to S-1) by containing only offset .Far Pointer: A far pointer is that which will point anywhere in the X MB across segments by containing segment+offset .The numbers X,S and B vary across diff operating system memory models under which you are programming .Say for MS-DOS,X=1MB;B=16 Bytes and S=1Mega Bytes/16 Bytes . Here, near pointer will have 4 bits to express address from 0 to 16 Bytes in a segment . Here, far pointer will have "l" bits for segment part of memory where 2^l=S (Here S should be a multiple of 16 bytes i.e; B=offset memory) and 4 bits for offset part of memory, so far poinetr will have l+4 bits.In DOS only 1 mb (10,48,580 bytes) of memory is accessible. Any of these memory locations are accessed using CPU registers. Under DOS the CPU registers are only 16 bits long. Therefore, the minimum value present in a CPU register could be 0, and maximum 65,535. Then how do we access memory locations beyond 65535th byte? By using two registers (segment and offset) in conjunction. For this the total memory (1 mb) is divided into a number of units each comprising 65,536 (64 kb) locations. Each such unit is called a segment. Each segment always begins at a location number which is exactly divisible by 16. The segment register contains the address where a segment begins, whereas the offset register contains the offset of the data/code from where the segment begins. For example, let us consider the first byte in B block of video memory. The segment address of video memory is B0000h (20-bit address), whereas the offset value of the first byte in the upper 32K block of this segment is 8000h. Since 8000h is a 16-bit address it can be easily placed in the offset register, but how do we store the 20-bit address B0000h in a 16-bit segment register? For this out of B0000h only first four hex digits (16 bits) are stored in segment register. We can afford to do this because a segment address is always a multiple of 16 and hence always contains a 0 as the last digit. Therefore, the first byte in the upper 32K chunk of B block of video memory is referred using segment:offset format as B000h:8000h. Thus, the offset register works relative to segment register. Using both these, we can point to a specific location anywhere in the 1 mb address space.Suppose we want to write a character `A' at location B000:8000. We must convert this address into a form which C understands. This is done by simply writing the segment and offset addresses side by side to obtain a 32 bit address. In our example this address would be 0xB0008000. Now whether C would support this 32 bit address or not depends upon the memory model in use. For example, if we are using a large data model (compact, large, huge) the above address is acceptable. This is because in these models all pointers to data are 32 bits long. As against this, if we are using a small data model (tiny, small, medium) the above address won't work since in these models each pointer is 16 bits long.What if we are working in small data model and still want to access the first byte of the upper 32K chunk of B block of video memory? In such cases both Microsoft C and Turbo C provide a keyword called far.normally Pointers are 32 bit length. which are divided as segment and offset.which are represent asseg : off 0000:0000 . . . 8000:FFFF. . . . FFFF:FFFFfirst 4 hexa digits are segment, last 4 hexa digits are offsetC Program will allocate 64KB (only one segment) memory for data Part (dynamic memory allocation, Local variables).by using 16 bit we can access that memory that's called near pointer(16 bit pointer).suppose we need more than 64KB memory to a program / we want to access a particular memory location (in TSR Program)at the time we neet 32 bit pointer. through 32 bit pointer we can access any segment and offset address.there are 2 types of 32 bit pointers 1. far pointer. 2. Huge Pointer.In TSR programming normally we use far Pointer.The Main Difference between Far and Huge Pointer isFar pointers are not Normalized.Huge pointers are Normalized.First let me state this is based on my current understanding. If someone can update or improve my version I will be grateful:1.For those in hurry far simply means "its not here find it somewhere else in memory" 2. far, near and huge and not a part of the C standard( am I right?)-So the answer to this is: "It depends" Its highly compiler specific and platform(processor) specific.Different processors have different ways to handle memory, and also different amount of memory.when you say "far" you are just telling the compiler find or put this data somewhere else.But the compiler does the hard work for you: writing the instructions to change the segment properly and accessing the correct memory location for you..and that's because it knows the processor..I think previous answers are mostly related to Pentium family of processors..and perhaps turbo C or similar compilers.But remember that is only one of them!Below are the examples which perhaps can have different meanings in different places:1. far int* near a; 2. far int* a; 3. far int *far a;So the best way is to try it out with your compiler and find out.Pointers can either be near, far, or huge. Near pointers refer to the current segment, so neither DS nor CS must be modified to dereference the pointer. They are the fastest pointers, but are limited to point to 64 kilobytes of memory (the current segment).Far pointers contain the new value of DS or CS within them. To use them the register must be changed, the memory dereferenced, and then the register restored. They may reference up to 1 megabyte of memory. Note that pointer arithmetic (addition and subtraction) does not modify the segment portion of the pointer, only its offset. Operations which exceed the bounds of zero or 65535 (0xFFFF) will undergo modulo 64K operation just as any normal 16 bit operation.For example, the code below will wrap around and overwrite itself: char far* myfarptr = (char far*) 0x50000000L ; unsigned long counter ; for(counter=0; counter


What is huge pointer generic pointer and far pointer?

Far Pointer is a pointer that is stored using four bytes (32 bits). The bytes are stored little endian or low to high order. A far pointer can access objects up to 16K in size in any memory area. Objects larger than 16K must be accessed using huge pointers This book is basic for c , download and Read this... must required !


How do you obtain network id from IP address?

how do you obtain network id from ip address


Why you Use Memory Segmentation In 8086 Microprocessor?

The 8086/8088 is a 16 bit processor running on a 16 bit (8086) or 8 bit (8088) bus with a 20 bit address bus. In order to obtain the extra 4 bits of addressibility, Intel designed segment registers that are effectively multiplied by four and then added to the 16 bit offset address generated by the instruction. This yields 64K segments of 64KB each, although they overlap each other at a distance of 16 bytes.


Can I obtain a gmail address from a Google plus ID?

You can obtain a Gmail address from a Google Plus ID, by following the accompanying link.


Addresses of kingdom halls in Lebanon?

To obtain this information write to the Branch Office of Jehovah's Witnesses in your area. You can obtain the address at www.watchtower.org/address.


Where does wizard obtain the IP address?

Fakeness


Can you get married in Ny with a license from pa?

No. You must obtain a valid marriage license in the location where you will be married. Each state has their own requirements.No. You must obtain a valid marriage license in the location where you will be married. Each state has their own requirements.No. You must obtain a valid marriage license in the location where you will be married. Each state has their own requirements.No. You must obtain a valid marriage license in the location where you will be married. Each state has their own requirements.


Where do ISPs get the public addresses that they assign to end users?

ISPs obtain address blocks from registry organizations.