In computer science , the offset within an array or other object of the data structure is an integer indicating the distance (offset) between the beginning of the object and the given element or point, presumably inside the same object [1] . The concept of distance is only valid if all elements of the object are the same size (usually given in bytes or “words” (an ordered set of bytes or bits )).
For example, in array A , with the content "abcdef" , the fourth element containing the character 'd' has an offset of three from the beginning of A
In assembly language
In computer engineering and low-level programming (such as assembly language ), an offset usually refers to the number of addresses that must be added to the base address in order to obtain a specific absolute address . In this value, only the base address block, usually an 8-bit byte, is used to indicate the size of the offset. In this context, the offset is sometimes referred to as a "relative address".
In IBM System / 360 instructions , the 12-bit offset embedded in specific commands contains a range from 0 to 4096 bytes. For example, in the unconditional jump instruction (X'47F0Fxxx '), the 12-bit hexadecimal offset “xxx” provided a byte offset from the base register (15) to the branch [2] . An odd offset will lead to a program check (unless the base register contains an odd address), since the instructions must be aligned at the half-word boundaries for execution without software or hardware interruption [3] .
The previous example describes an indirect way to access a memory cell in segment format: offset. For example, suppose we want to reference memory location 0xF867. One way this can be achieved is to first identify the segment with the start address 0xF000, and then determine the offset 0x0867. In addition, it is also allowed to shift the hexadecimal segment to reach the final absolute memory address. It should be noted here that you can achieve the final absolute address in various ways.
Notes
- ↑ Dandamudi, Sivarama P., 1955-. Introduction to Assembly language programming: for Pentium and RISC processors . - 2nd ed. - New York: Springer, 2005 .-- S. 76. - 1 online resource (xxiii, 690 pages) p. - ISBN 0387271554 .
- ↑ IBM Knowledge Center . www.ibm.com. Date of treatment January 8, 2018.
- ↑ One-time data transfer (LDR, STR) . www.gaw.ru. Date of treatment January 8, 2018.